Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSA10 #94

Merged
merged 34 commits into from
Jan 15, 2016
Merged

RSA10 #94

merged 34 commits into from
Jan 15, 2016

Conversation

ricardopereira
Copy link
Contributor

No description provided.

@ricardopereira
Copy link
Contributor Author

(RSA10c) Will not create a new token unless no previous token exists or current token has expired.

Not implemented:

Please note that a buffer of 15s for token expiry is recommended to avoid race conditions where the token is valid at the time of the request, but invalid when it reaches the server. Therefore, we recommend that a token is considered expired 15s before the time field expires

@ricardopereira
Copy link
Contributor Author

(RSA10e) Adheres to the implementation of requestToken when issuing new tokens

I need to think about it. Right now I do not have a clue how to achieve this.

@ricardopereira
Copy link
Contributor Author

Not implemented:

(RSA10g) Stores the AuthOptions and TokenParams arguments as defaults for subsequent authorisations

@mattheworiordan
Copy link
Member

(RSA10c) Will not create a new token unless no previous token exists or current token has expired.

Not implemented:
Please note that a buffer of 15s for token expiry is recommended to avoid race conditions where the token is valid at the time of the request, but invalid when it reaches the server. Therefore, we recommend that a token is considered expired 15s before the time field expires

@ricardopereira that is fine, but why?

(RSA10e) Adheres to the implementation of requestToken when issuing new tokens

I need to think about it. Right now I do not have a clue how to achieve this.

Surely you just need to have a test that proves that requesting a token through an authorise call leads to a requestToken call with the arguments provided? If you do that, then it adheres to the spec.

Not implemented:
(RSA10g) Stores the AuthOptions and TokenParams arguments as defaults for subsequent authorisations

Why not? This is quite an important requirement.

BOOL requestNewToken = NO;
BOOL useTheForce = options ? options.force : false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useTheForce? Sounds like something out of Star Wars. Why not simply forceTokenRenewal?

@mattheworiordan
Copy link
Member

A few comments, but largely good progress, 👍

@ricardopereira
Copy link
Contributor Author

@mattheworiordan Done

@ricardopereira
Copy link
Contributor Author

Tests are failing because of bug #114. (test Auth.swift#L801)
Should I fix?

@mattheworiordan
Copy link
Member

Tests are failing because of bug #114. (test Auth.swift#L801)
Should I fix?

Well up to you, it would be nice to not introduce PRs that change the build from green to red. I think you should look at fixing the issue as part of this PR so that this PR passes, but do no more than necessary, and anything else should go in a separate PR to address the issue. Alternatively, and probably better, perhaps fix #114 in a new PR, and then rebase this one on top of that afterwards.

@@ -30,7 +30,7 @@ ART_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak) ARTLog *logger;

@property (art_nullable, readonly, getter=getClientId) NSString *clientId;
@property (art_nullable, nonatomic, readonly, strong) ARTAuthTokenDetails *tokenDetails;
@property (art_nullable, nonatomic, readwrite, strong) ARTAuthTokenDetails *tokenDetails;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this readwrite? I assume this means a consumer of this API could explicitly update the tokenDetails without using the correct API. Is this intentional? If so, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a mistake. I removed the setTokenDetails and I change it to readwrite just to compile the code successfully and continue the remaining work of this spec.

@mattheworiordan
Copy link
Member

Few comments, but mostly looks good

@ricardopereira
Copy link
Contributor Author

Needs #123.

if (mergedOptions.authUrl) {
NSMutableURLRequest *request = [self buildRequest:mergedOptions withParams:currentTokenParams];

[self.logger debug:__FILE__ line:__LINE__ message:@"using authUrl (%@ %@)", request.HTTPMethod, request.URL];

[_rest executeRequest:request withAuthOption:ARTAuthenticationUseBasic completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) {
[_rest executeRequest:request withAuthOption:ARTAuthenticationOff completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ARTAuthenticationOff, what does that mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARTAuthenticationOff means the host does not require authentication (no Authorization http header)

@mattheworiordan
Copy link
Member

Few small comments, please address and will merge. Also, this won't merge automatically now unfottunately

 - It is possible to request a token either with an API key,
authCallback or authUrl
 - The `authCallback` was calling the wrong callback.
 - Generate a token request with one RestClient and one other to test
the `authCallback`
The token retrieved is assumed by the library to be a token string if
the response has Content-Type "text/plain", or taken to be a
TokenRequest or TokenDetails object if the response has Content-Type
"application/json"
 - added `ARTJsonEncoder.encodeTokenDetails` to use with echo.ably.io
service
 - added `getTestTokenDetails()`
 - Added custom nimble matcher `beCloseTo` for NSDates
@ricardopereira
Copy link
Contributor Author

Rebased with one change c670e8f.

@mattheworiordan
Copy link
Member

LGTM

1 similar comment
@tcard
Copy link
Contributor

tcard commented Jan 15, 2016

LGTM

tcard added a commit that referenced this pull request Jan 15, 2016
@tcard tcard merged commit a434a5f into master Jan 15, 2016
@ricardopereira ricardopereira deleted the RSA10 branch January 19, 2016 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants