-
Notifications
You must be signed in to change notification settings - Fork 56
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
Second proposal for connection reauthing: using auth#authorise() #261
Conversation
this.method = 'basic'; | ||
this.key = authOptions.key; | ||
this.basicKey = toBase64(authOptions.key); | ||
this.tokenParams = defaultTokenParams || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this?
A few comments but otherwise lgtm |
this.tokenParams.clientId = options.clientId; | ||
this.clientId = options.clientId | ||
} | ||
|
||
/* decide default auth method */ | ||
var key = options.key; | ||
if(key) { | ||
if(!options.clientId && !options.useTokenAuth) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be checking if any token auth params are provided as well. Also clientId
could be passed in with defaultTokenParams.clientId
which would then be ignored and basic auth assumed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be checking if any token auth params are provided as well.
The logic of when to use basic vs token auth isn't something I changed here - ably-js has always used basic if a key is given as long as useTokenAuth
isn't set. That said, looking at RSA4
, you're right, the logic not spec-compliant. I'll add a separate commit to fix that.
Also clientId could be passed in with defaultTokenParams.clientId which would then be ignored and basic auth assumed.
I'm not sure I agree with this bit - should merely providing defaultTokenParams
really force token auth used if it wouldn't otherwise have been used? That seems surprising. If someone wants an identified client they should pass a clientId
in clientOptions
directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree with this bit - should merely providing defaultTokenParams really force token auth used if it wouldn't otherwise have been used?
True, you are right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 998b6a4 for RSA4 compliance
Few comments, but on the whole I think it's a good solution and sets the groundwork for an improved authentication upgrade process in future. |
So to be clear, are we all in agreement that:
|
s/default/previous, but yes
There are no client library initial defaults though, for either tokenParams or authOptions. If you don't supply any authOptions, the library will just throw an exception; if you don't supply any tokenParams, it won't pass any to realtime, so realtime will use its own defaults. (I can't find it now, but IIRC we had a long discussion about this, and we changed the spec such that the client lib would not supply its own defaults). So this is equivalent to "replaces the current values".
All the other authOptions apart from
Yeah, I guess that would make sense (since {authUrl, authCallback, token, tokenDetails, key} are special: they're not independent settings, they're alternative ways to authenticate. Cleaner to split out actual toggleable settings). I don't have a good answer to the naming/organisation thing though. I dunno, maybe an |
There are, see https://www.ably.io/documentation/realtime/types#auth-options. All I am saying is that the default behaviour of the client lib remains if an option is not provided in the Hash with loosely typed languages.
I am not sure I understand what you're saying here because I don't think either
If we were starting from scratch perhaps, but I don't think that big a change is a good idea. Simply removing |
@SimonWoolf Can you update this please to reflect the latest spec proposal, and then add some tests so I can test my realtime changes? |
Added 83b563b for latest reauth spec compliance. @paddybyers the new |
also 1516466. grumble node vm contexts grumble |
Just a note. Before this lands, we need to ensure the connection recovery documentation states that capabilities can be changed because currently it's not |
Closing in favour of #269 |
Merged as 31f70cb |
Alternative to https://github.com/ably/ably-js/pull/260/files, as requested
Also fixes #237
One of the tests added (
reauth_tokenDetails
) currently fails due to https://github.com/ably/realtime/issues/534