Stop specifying a clientId forcing token authentication#345
Stop specifying a clientId forcing token authentication#345SimonWoolf merged 2 commits intomaster-1-1from
Conversation
b2f9a97 to
0912a1e
Compare
|
I must admit I am nervous about this change as I know we previously intended for this behaviour. I know that in the case of REST publishes now, we would (in the current proposal) now have to mutate the messages to now include an explicit clientId when a clientId is specified in ClientOptions if API key auth is used. This feels very wrong. @paddybyers has suggested we could solve this with a new param or header perhaps. We'd need to implement this though in the spec. I'll wait for him to review :) |
|
We don't currently, but we can easily bind a |
Which |
For realtime connections we already do this, I checked before writing rsa7e1. If you meant for REST publishes, I'm not sure I see the point. The way REST messages can have a clientId is with |
I am only referring to REST as, as you say, realtime WS endpoints support clientId.
Currently, if you specify a clientId in the ClientOptions and publish a message like Now, with your proposal, it would be received with no If the client lib then sets the Hence why I was saying over REST we need to set the |
The message object delivered to the subscribers will include a Seems odd to me that we're considering adding more complication to the rest api in order to make it so that technically it's realtime that actually adds the field, on the instruction of the client lib, rather than the client lib just adding it itself. |
Because this:
|
05319e9 to
3fed1e0
Compare
|
OK, fair enough, I see where you're coming from. Added 3fed1e0 accordingly. (By analogy with |
|
Thanks, LGTM 👍 |
| ** @(RSA7d)@ If @clientId@ is provided in @ClientOptions@ and @RSA4@ indicates that token auth is to be used, the @clientId@ field in the @TokenParams@ (@TK2c@) should be set to that @clientId@ when requesting a token | ||
| ** @(RSA7e)@ If @clientId@ is provided in @ClientOptions@ and @RSA4@ indicates that basic auth is to be used, then: | ||
| *** @(RSA7e1)@ For realtime clients, the connect request should include the @clientId@ as a querystring parameter, @clientId@ | ||
| *** @(RSA7e2)@ For REST clients, all requests should include an @X-Ably-ClientId@ header with value set to the @clientId@, Base64 encoded |
There was a problem hiding this comment.
@SimonWoolf I assume you don't think it's necessary to specify how JS handles this? Good suggestion re: Base64 btw.
There was a problem hiding this comment.
What's the reasoning behind having a header instead of a query param?
There was a problem hiding this comment.
I assume you don't think it's necessary to specify how JS handles this?
as in, for when custom headers aren't supported (i.e. IE<10)? Nah, I don't think it's necessary to put it in the spec, it just complicates things for everyone else. Similar to how we do the Authorization header -- realtime also supports auth by qs param for old IEs, but the spec only mentions the main (header) way.
(I think this is justified because it's only temporary -- at some point, maybe not too far away, non-websocket webbrowsers will drop below ε% usage share, and we can drop all the jsonp, comet, upgrade etc. crap from ably-js entirely)
There was a problem hiding this comment.
What's the reasoning behind having a header instead of a query param?
Consistency with the Authorization: Basic ... header (RSA11). Since that's how auth is already done for REST requests, adding a second header can be done just by adding it to the existing Auth#getAuthHeaders (or equivalent in another client lib) method.
Since there's currently no query param that should be applies to all rest requests, client libs probably don't have an existing mechanism to add one, so doing it that way would be a more work for most client libs.
(Though realtime will still have to support both for jsonp, so I'm trading off realtime ease of implementation for client lib ease of implementation)
There was a problem hiding this comment.
I too prefer headers, although I don't have a good reason why 😉
It just feels a whole load cleaner that the REST URL endpoint is the same regardless of your identity.
mattheworiordan
left a comment
There was a problem hiding this comment.
@paddybyers @SimonWoolf happy to go with this if you are. It does mean more functionality for our client 1.1 SDK release, but unavoidable. 👍
Per discussion in #312.
(This section is numbered a bit weirdly -- 'Auth#clientId attribute is not null when:' is RSA7b, but its sibling 'Auth#clientId attribute is null when:', also a child or RSA7, is RSA12. But I'm a bit hesitant to renumber more sensibly as that'd make updating the spec spreadsheet and any references in client lib tests even more of a PITA...)