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

Clarify that authorize can be given just a token #186

Closed
wants to merge 3 commits into from

Conversation

SimonWoolf
Copy link
Member

tpr was pointing out in #client-libraries today that the auth#authorize spec doesn't make clear whether you can give it a token and it should use that -- https://ably-real-time.slack.com/archives/client-libraries/p1478012497000052. Proposed clarification

@trenouf
Copy link
Contributor

trenouf commented Nov 1, 2016

Thanks, LGTM.

trenouf pushed a commit to ably/ably-java that referenced this pull request Nov 1, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
@@ -1057,6 +1058,8 @@ h4. AuthOptions
* @(AO1)@ A class providing configurable authentication options used when authenticating or issuing tokens explicitly. These options are used when invoking @Auth#authorize@, @Auth#requestToken@, @Auth#createTokenRequest@ and @Auth#authorize@
* @(AO2)@ The attributes of @AuthOptions@ consist of:
** @(AO2a)@ @key@ string - Full Ably key string, as obtained from dashboard, used when signing token requests locally
** @(AO2h)@ @token@ string - An authentication token string issued for this application
** @(AO2i)@ @tokenDetails@ @TokenDetails@ - An authentication token issued for this application
Copy link
Member

Choose a reason for hiding this comment

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

An authentication token and associated details issued for this application ?

Copy link
Member

Choose a reason for hiding this comment

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

Why and associated details?

Copy link
Member

Choose a reason for hiding this comment

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

I mean just saying "an authentication token" might be understood to be the token string, whereas here we're talking about a TokenDetails, ie including expiry and other attributes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added 0203f19 to clarify tokenDetails

trenouf pushed a commit to ably/ably-java that referenced this pull request Nov 2, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
trenouf pushed a commit to ably/ably-java that referenced this pull request Nov 4, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
trenouf pushed a commit to ably/ably-java that referenced this pull request Nov 4, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
trenouf pushed a commit to ably/ably-java that referenced this pull request Nov 4, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
@SimonWoolf
Copy link
Member Author

Addressed comment, believe this is ready for merging

@mattheworiordan
Copy link
Member

mattheworiordan commented Nov 23, 2016

I don't specifically think there is anything wrong with this proposal, but I am wondering why we are introducing this complexity. Under what conditions will people provide a token value and a means to obtain a token in reality? Also, should we even encourage people to provide tokens directly as part of AuthOptions when in most cases this will be wrong?

Is there a strong enough use case to warrant this additional complexity versus simply rejecting authorize requests where customers explicitly provide a token?

The only situation I can think is that perhaps a client receives a message (as a normal message or via another means) notifying it it should get a new token, and instead of just calling authorize they instead get the token and pass it to authorize. In that case though, why don't we rather encourage people to just call authorize and be done with it?

@@ -107,6 +107,7 @@ h3(#rest-auth). Auth
*** @(RSA4c1)@An @ErrorInfo@ with @code@ @80019@ and description of the underlying failure should be emitted with the state change, in the @errorReason@ and/or in the callback as appropriate
*** @(RSA4c2)@If the connection is @CONNECTING@, then the connection attempt should be treated as unsuccessful, and as such the connection should transition to the @DISCONNECTED@ or @SUSPENDED@ state as defined in "RTN14":#RTN14 and "RTN15":#RTN15
*** @(RSA4c3)@If the connection is @CONNECTED@, then the connection should remain @CONNECTED@
** @(RSA4d)@ If multiple @authOptions@ are used to initialize the library, the preference ordering among them is identical to @Auth#authorize@, defined in @RSA10e@
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "multiple authOptions" is confusing. What's an authOption? The formatting seems to indicate it's something formal in the code, like a specified field or type.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed.

@@ -159,7 +160,7 @@ h3(#rest-auth). Auth
** @(RSA10j)@ Method signature is @authorize(TokenParams, AuthOptions)@. @TokenParams@ and @AuthOptions@ are optional. When the arguments are present, even if empty, the @TokenParams@ and @AuthOptions@ supersede any previously client library configured @TokenParams@ and @AuthOptions@. For example, if a client is initialised with @TokenParams#ttl@ configured with a custom value, and a @TokenParams@ object is passed in as an argument to @#authorize@ with a @null@ or missing value for @ttl@, then the @ttl@ used for every subsequent authorization will be @null@
** @(RSA10b)@ Supports all @AuthOptions@ and @TokenParams@ in the function arguments
** @(RSA10k)@ If the @AuthOption@ argument's @queryTime@ attribute is true, it will obtain the server time once and persist the offset from the local clock. All future token requests generated directly or indirectly via a call to @authorize@ will not obtain the server time, but instead use the local clock offset to calculate the server time. The client library itself MAY internally discard the cached local clock offset in situations in which it may have been invalidated, such as if there is a local change to the date, time, or timezone, of the client device. For clarity however, there is no requirement for this cache invalidation to be available to consumers of the client library API.
** @(RSA10e)@ Adheres to the implementation of @requestToken@ when issuing new tokens
** @(RSA10e)@ If the @authOptions@ contains a way of obtaining a token (an @authCallback@, @authUrl@, or @key@), that should be used to obtain a new token, as per @requestToken@ (@RSA8@). If it contains a token (@token@ or @tokenDetails@), that should be used as-is. If it contains both a token and a way of obtaining a token, the token should be used, with the way of obtaining a token being stored per @RSA10g@ for when the token expires. (Ordering of preference within those groups is not defined and is left up to individual implementations)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: either "authOptions" or "the AuthOptions". (I prefer the latter since we don't name the arguments in RSA10j, just the types.)

Copy link
Member

Choose a reason for hiding this comment

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

👍 for this change.

@tcard
Copy link
Contributor

tcard commented Nov 24, 2016

I am wondering why we are introducing this complexity

I think this proposal reduces complexity, and instead making a special case out of it like causing authorize to fail would increase it.

Plus, if we give them liberty to provide a token on initialization I don't see why we should restrict it afterwards. We ask for authUrl, authCallback, etc. so that we can reauthorize at any point on our terms but the whole point of authorize is to let them reauthorize at any point too, and authUrl/authCallback is not specially relevant in that case.

@mattheworiordan
Copy link
Member

Plus, if we give them liberty to provide a token on initialization I don't see why we should restrict it afterwards. We ask for authUrl, authCallback, etc. so that we can reauthorize at any point on our terms but the whole point of authorize is to let them reauthorize at any point too, and authUrl/authCallback is not specially relevant in that case.

Ok, but let's push this into 0-10 please and base on that branch

psolstice pushed a commit to ably/ably-java that referenced this pull request Dec 7, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
psolstice pushed a commit to ably/ably-java that referenced this pull request Dec 23, 2016
As in proposed RSA10e spec clarification in PR
ably/docs#186
@SimonWoolf SimonWoolf added this to the 0.10 spec milestone Jan 2, 2017
@mattheworiordan
Copy link
Member

Can this be rebased onto 0-10-source please?

paddybyers pushed a commit to ably/ably-java that referenced this pull request Jan 8, 2017
As in proposed RSA10e spec clarification in PR
ably/docs#186
paddybyers pushed a commit to ably/ably-java that referenced this pull request Jan 17, 2017
As in proposed RSA10e spec clarification in PR
ably/docs#186
@mattheworiordan
Copy link
Member

@SimonWoolf this now needs to be rebased on master-1-1

Copy link
Member

@mattheworiordan mattheworiordan left a comment

Choose a reason for hiding this comment

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

LGTM. Just need to decide which client lib ver this goes into.

@@ -107,6 +107,7 @@ h3(#rest-auth). Auth
*** @(RSA4c1)@An @ErrorInfo@ with @code@ @80019@ and description of the underlying failure should be emitted with the state change, in the @errorReason@ and/or in the callback as appropriate
*** @(RSA4c2)@If the connection is @CONNECTING@, then the connection attempt should be treated as unsuccessful, and as such the connection should transition to the @DISCONNECTED@ or @SUSPENDED@ state as defined in "RTN14":#RTN14 and "RTN15":#RTN15
*** @(RSA4c3)@If the connection is @CONNECTED@, then the connection should remain @CONNECTED@
** @(RSA4d)@ If multiple @authOptions@ are used to initialize the library, the preference ordering among them is identical to @Auth#authorize@, defined in @RSA10e@
Copy link
Member

Choose a reason for hiding this comment

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

Agreed.

@@ -159,7 +160,7 @@ h3(#rest-auth). Auth
** @(RSA10j)@ Method signature is @authorize(TokenParams, AuthOptions)@. @TokenParams@ and @AuthOptions@ are optional. When the arguments are present, even if empty, the @TokenParams@ and @AuthOptions@ supersede any previously client library configured @TokenParams@ and @AuthOptions@. For example, if a client is initialised with @TokenParams#ttl@ configured with a custom value, and a @TokenParams@ object is passed in as an argument to @#authorize@ with a @null@ or missing value for @ttl@, then the @ttl@ used for every subsequent authorization will be @null@
** @(RSA10b)@ Supports all @AuthOptions@ and @TokenParams@ in the function arguments
** @(RSA10k)@ If the @AuthOption@ argument's @queryTime@ attribute is true, it will obtain the server time once and persist the offset from the local clock. All future token requests generated directly or indirectly via a call to @authorize@ will not obtain the server time, but instead use the local clock offset to calculate the server time. The client library itself MAY internally discard the cached local clock offset in situations in which it may have been invalidated, such as if there is a local change to the date, time, or timezone, of the client device. For clarity however, there is no requirement for this cache invalidation to be available to consumers of the client library API.
** @(RSA10e)@ Adheres to the implementation of @requestToken@ when issuing new tokens
** @(RSA10e)@ If the @authOptions@ contains a way of obtaining a token (an @authCallback@, @authUrl@, or @key@), that should be used to obtain a new token, as per @requestToken@ (@RSA8@). If it contains a token (@token@ or @tokenDetails@), that should be used as-is. If it contains both a token and a way of obtaining a token, the token should be used, with the way of obtaining a token being stored per @RSA10g@ for when the token expires. (Ordering of preference within those groups is not defined and is left up to individual implementations)
Copy link
Member

Choose a reason for hiding this comment

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

👍 for this change.

@SimonWoolf
Copy link
Member Author

Merged into master-1-1 as 6ce7fba

@SimonWoolf SimonWoolf closed this Nov 6, 2017
@SimonWoolf SimonWoolf deleted the authorize-clarification branch November 6, 2017 19:20
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.

5 participants