-
Notifications
You must be signed in to change notification settings - Fork 46
[FTF-468] Several docs changes to highlight token auth over API key auth, as well as more info on using JWTs #3085
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
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
paddybyers
left a comment
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've commented on much of this but stopped around half way through. I think it needs significant revision to make JWT the primary recommended route. The narrative and examples all need updating to reflect this.
A lot of this is slop - it's been AI-generated and not critically reviewed.
| ```javascript | ||
| // ALWAYS use token authentication in browsers | ||
| const realtime = new Ably.Realtime({ | ||
| authUrl: '/api/ably-token', |
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 are we suggesting authURL instead of callback here? Does it not need at least some comment?
|
|
||
| ## Server auth endpoint template | ||
|
|
||
| Your server needs an endpoint that creates tokens. Here's a minimal example: |
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 is this using native tokens, instead of generating a JWT?
| ``` | ||
| </Code> | ||
|
|
||
| ## Security comparison |
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 convinced this section adds anything. It feels like slop.
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.
really a duplciate of https://ably-docs-authchanges-py2loc0j.herokuapp.com/docs/auth#selecting-auth. I do thinkg repetition is good at times, but why here?
| - [Token authentication reference](/docs/auth/token) - Full token auth documentation | ||
| - [Capabilities](/docs/auth/capabilities) - Fine-grained permission control | ||
|
|
||
| ## Troubleshooting |
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.
These are not the only things that could go wrong, or even the most likely things that could go wrong.
Error 40103: Token expired
Not according to https://github.com/ably/ably-common/blob/main/protocol/errors.json#L40
If we're going to retain this section we should also refer to:
40160: incorrect capabilities
80019: error in auth callback/url
40171: no means to renew token
Perhaps we should defer adding this section until we've got the more thorough error code documentation landed?
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 do we need troubleshooting at all? We have error codes and paths. Do we think people are going to read this and pre-empty troubles?
src/pages/docs/auth/token.mdx
Outdated
|
|
||
| ### TokenRequest <a id="choosing-tokenrequest"/> | ||
|
|
||
| **Best for:** Standard web and mobile applications using Ably SDKs. |
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 don't agree with this. We recommend JWT in all circumstances that they can be used. There are only two situations where you would use native tokens:
- where the capabilities list is so large that a literal token is unworkable;
- where the capabilities or clientId are sensitive in some way, and there is a desired to keep them confidential, even if inspecting the token.
Of these, I'm not sure we should even mention the second one because it's such an unusual case.
| Occupancy generates messages on any client entering/leaving a room, and so increases the number of billable messages sent in a room - as such, it is disabled by default and needs to be [enabled](/docs/chat/rooms#create) when creating or retrieving a room. | ||
| </Aside> | ||
|
|
||
| <Aside data-type='note'> |
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.
This is irrelevant. I suggest removing it.
| The presence feature of a chat room enables online users to advertise to others that they are online. Use this feature to build online status indicators to display who is online in a chat room. Users can also share additional information such as avatar URLs or custom statuses. | ||
|
|
||
| <Aside data-type='note'> | ||
| **Authentication required:** Presence requires an authenticated client with a `clientId`. Clients without a `clientId` cannot enter the presence set. Use [token authentication](/docs/auth/token) with server-assigned client IDs for production applications. See the [Chat setup guide](/docs/chat/setup#authentication) for examples. |
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.
This should refer to identified clients.
|
|
||
| Room reactions are ephemeral and not stored or aggregated by Ably. The intention being that they show the overall sentiment of a room at a point in time. | ||
|
|
||
| <Aside data-type='note'> |
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.
This is incorrect advice. It should state instead that a client needs to be identified in order to use certain reaction types. It does not imply the use of token auth.
src/pages/docs/chat/rooms/typing.mdx
Outdated
| Typing indicators enable you to display which users are currently writing a message in a room. This feature can be used to display a message such as *Sandi is typing...*, or when a certain threshold is reached you could instead display *Multiple people are typing...* or *12 people are typing...*. Typing events are emitted whenever a user starts or stops typing. | ||
|
|
||
| <Aside data-type='note'> | ||
| **Authentication required:** Typing indicators display the `clientId` of users who are typing. Use [token authentication](/docs/auth/token) to ensure these identities are trustworthy. See the [Chat setup guide](/docs/chat/setup#authentication) for examples. |
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 don't understand why this comment is here. Doesn't the chat SDK ensure that a client is always identified?
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.
Yes it does, this is needless information as they cannot connect without a clientId
|
|
||
| Your server needs an endpoint that: | ||
| 1. Verifies the user is authenticated (check session, JWT, etc.) | ||
| 2. Creates an Ably TokenRequest with the user's identity |
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.
Again, we should be recommending JWT auth.
mattheworiordan
left a comment
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.
Thanks for submitting. Good to see you take a stab at dealing with the LLM auth issues, but I think this PR needs a lot more human review by yourself before it's sent for others to review. Lots of obvious problems as it appears to have been pumped out directly from an LLM, which is great to move quickly, but thiks is our docs, and is representative of whether we care to customers.
|
|
||
| ## Approach 1: Separate Ably JWT <a id="separate-jwt"/> | ||
|
|
||
| Your existing auth flow validates the user, then you create an Ably JWT using any JWT library. No Ably SDK is required on your server. |
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 am not sure this is what we'd recommend, always sending both tokens instead of just the one you need? Why would a single endpoint be used for Ably and app auth, when both only need one of the two JWTs?
| authCallback: async (tokenParams, callback) => { | ||
| // On token refresh, fetch new Ably JWT | ||
| try { | ||
| const response = await fetch('/auth/ably-token', { |
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.
This URL doesn't match the server example you have above
| // On token refresh, fetch new Ably JWT | ||
| try { | ||
| const response = await fetch('/auth/ably-token', { | ||
| headers: { 'Authorization': `Bearer ${appToken}` }, |
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.
This approach is broken in that a new app token cannot be generated as it's cached at the time of login, instead of obtaining one at the time it's needed
| 'x-ably-token': ablyToken.token, | ||
| }, | ||
| process.env.APP_JWT_SECRET, | ||
| { expiresIn: '1h' } // Must not exceed Ably token expiry |
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.
If that's teh case, why are you not specifying a TTL when issuing the token?
| ``` | ||
| </Code> | ||
|
|
||
| ## Integrating with AWS Cognito <a id="cognito"/> |
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 am not sure we should be just listing out integrations with random providers like this. It doesn't really flow, at the start we're talking about issuing JWTs ,then we are showing random integrations where with this one we're just showing how to issue a token with Lambda, and then we move onto token renewal. It doesn' feel well thought through, why this order?
|
|
||
| If your `authUrl` endpoint is slow or unreliable, tokens may expire before refresh completes. Ensure your auth endpoint responds quickly (under 5 seconds) and is highly available. | ||
|
|
||
| ## Next steps |
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 have you introduced Next Steps? We've not used this in the docs.
|
|
||
| The Ably SDK automatically calls your `authCallback` before the current token expires, ensuring seamless token rotation. | ||
|
|
||
| ## Next steps |
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 have you introduced Next Steps? We've not used this in the docs.
|
|
||
| If your `authUrl` endpoint is slow or unreliable, tokens may expire before refresh completes. Ensure your auth endpoint responds quickly (under 5 seconds) and is highly available. | ||
|
|
||
| ## Next steps |
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 have you introduced Next Steps? We've not used this in the docs.
src/pages/docs/chat/rooms/typing.mdx
Outdated
| Typing indicators enable you to display which users are currently writing a message in a room. This feature can be used to display a message such as *Sandi is typing...*, or when a certain threshold is reached you could instead display *Multiple people are typing...* or *12 people are typing...*. Typing events are emitted whenever a user starts or stops typing. | ||
|
|
||
| <Aside data-type='note'> | ||
| **Authentication required:** Typing indicators display the `clientId` of users who are typing. Use [token authentication](/docs/auth/token) to ensure these identities are trustworthy. See the [Chat setup guide](/docs/chat/setup#authentication) for examples. |
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.
Yes it does, this is needless information as they cannot connect without a clientId
src/pages/docs/spaces/avatar.mdx
Outdated
| Subscribe to the `space.members` namespace in order to keep your avatar stack updated in realtime. | ||
|
|
||
| <Aside data-type='note'> | ||
| **Authentication required:** This feature uses the client's `clientId` for identification. Use [token authentication](/docs/auth/token) with server-assigned client IDs to prevent identity spoofing. See the [Spaces setup guide](/docs/spaces/setup#authenticate) for examples. |
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.
This is not necessary. If this is needed, the problem of which auth mechanism t use is surely solved?
8d4649e to
4e56d1a
Compare
|
Thanks both @mattheworiordan @paddybyers I should've made it clear I had not yet reviewed the LLM output, so this at the very least should've been a draft only! I mostly put it up to get a gauge on the kind of content we think we were missing and the placement of it. However, your comments have massively helped me in understanding the scope of what needs changing in our auth docs, as well as highlighting my limited understanding of exactly what we're trying to tell and recommend to our customers. I've got a session with Mark and Paddy shortly to understand exactly what our position is re: Auth with Ably, what we're trying to tell our customers, and some historical context of how auth has evolved to the point we seem to have deviations in our docs. I'm trying to solely use LLMs for this, so again, some of these changes are likely subpar as I get a better understanding of the problem later today. For the time-being, I've gone back and forth with Claude to "resolve" (or at least have a stab at resolving) your current comments. I would ignore this for now until I've had a chance to capture and implement the findings from our meeting later today - this is purely to move the needle and help my own understanding from what you've presented in the comments so far. Comments on auth/quick-reference.mdx (12 comments)
Comments on auth/token.mdx (8 comments)
Comments on auth/jwt-integration.mdx (8 comments)
Comments on chat/authentication.mdx (12 comments)
Comments on Chat Room Features (6 comments)
Comments on chat/setup.mdx (1 comment)
Comments on spaces/authentication.mdx & spaces/avatar.mdx (2 comments)
Key Changes Made
|
…ll as more info on using JWTs
4e56d1a to
0d61283
Compare
0906ade to
43cd265
Compare
43cd265 to
2115ab9
Compare
2115ab9 to
4b0b630
Compare
paddybyers
left a comment
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.
This is really hard to review because it's dominated by changes to the path for the auth docs. Please at least make all of those changes in a separate commit (but I don't see why it's not a separate PR). Then the other material changes can be reviewed.
that's fair - the change was from our meeting in which we wanted auth docs under platform with shorter product auth guides in their respective sections. This then meant leaving the path as |
4b0b630 to
f76e713
Compare
|
@paddybyers I also unified the messaging we had when pointing people to the token auth docs... I'll revert this and do that as a separate PR.. just a moment |
f76e713 to
6e4871d
Compare
6e4871d to
48f754c
Compare
48f754c to
178dc16
Compare
|
Previous comments should be addressed. There was a fair few more changes that I'll instead add in a subsequent PR (adding asides to current basic auth code examples which highlight using JWT token in prod, and redirects to ensure links point to the new auth docs location under platform) |
src/pages/docs/protocols/mqtt.mdx
Outdated
|
|
||
| ### JWT Authentication <a id="jwt-auth"/> | ||
|
|
||
| <Aside data-type='note'> |
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.
remove this... duplicate
178dc16 to
0854b3e
Compare
…ll as more info on using JWTs
0854b3e to
3a2d796
Compare
|
Undone all nav changes for this PR... All auth docs changes are now isolated to their original location (under pubsub) and new product specific auth pages e.g. Chat and Spaces. Upcoming PR(s) will reintroduce:
cc: @m-hulbert |
paddybyers
left a comment
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.
Please see the comments. I think this still needs some work.
Discussions relating to auth have lots of scope for ambiguity so please use precise language. Every word has one meaning, and every meaning has one word.
@m-hulbert I'll defer to you on whether or not the restructure makes sense wrt the nav.
Someone from the Chat team needs to review the chat parts - having the ::$chat directive in the capability expression I'm sure is wrong (@splindsay-92 )
| Capabilities can be set when creating a token or token request, as shown in the following example: | ||
| #### Using JWT (recommended) <a id="jwt-capabilities"/> | ||
|
|
||
| Set capabilities in a JWT using the `x-ably-capability` claim. No Ably SDK is required—any JWT library will work: |
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.
| Set capabilities in a JWT using the `x-ably-capability` claim. No Ably SDK is required—any JWT library will work: | |
| Set capabilities in a JWT using the `x-ably-capability` claim. No Ably SDK is required - any JWT library will work: |
Please no em-dashes
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.
Maybe worth just adding
This example uses jsonwebtoken
?
| capability := map[string][]string{ | ||
| "*": {"*"}, | ||
| } | ||
| If JWT is not suitable, use the Ably SDK to create a TokenRequest with capabilities: |
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.
This says nothing about why JWT might not be suitable
|
|
||
| ### Token capability determination <a id="capability-determination"/> | ||
|
|
||
| The capabilities for tokens are determined based on those of the issuing API key and those requested by the token. |
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 think this needs to be more explicit. The capabilities of the resulting token are the intersection of the request capabilities, and those of the issuing API key. (This is also true for JWT.)
The requestToken() request will fail if the intersection is empty - ie the token would have no rights.
This should also mention the gotcha: this intersection behaviour means that a call to requestToken() will succeed, but can fail to provide a token with all of the requested capabilities. If the capabilities of the issuing key are not known by the client, then a successful response to requestToken() should be followed by a check that all of the requested capabilities are present.
| ## Custom restrictions on channels <a id="custom-restrictions"/> | ||
|
|
||
| <Aside data-type='important'> | ||
| **JWT-only feature:** Channel-scoped user claims are only available when using [Ably JWT authentication](/docs/auth/token#choosing-jwt). They are not available with TokenRequest authentication. See [JWT-only features](/docs/auth/token#jwt-only-features) for a complete list of capabilities exclusive to JWT authentication. |
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.
@m-hulbert Are we happy that "TokenRequest authentication" is the appropriate name in these docs for the native token mechanism?
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 think the high-level mechanism should be 'Ably Tokens' personally.
|
|
||
| It is possible for JWTs to contain authenticated claims for users that can be used to allow or disallow certain interactions in your channels. | ||
|
|
||
| Messages can be annotated with trusted metadata copied from the client's authentication token by Ably servers. Clients are unable to directly publish messages with user claim metadata, and claims contained within the authentication token are signed to prevent tampering. Claims can be scoped to individual channels or to namespaces of [channels](/docs/channels). The most specific user claim will be added to the message as part of the `extras` object. Note that this does not apply to presence or metadata messages. |
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.
Note that this does not apply to presence
I thought we support that now - pls check
| * Ably [TokenRequest](#token-request) is created by your servers and passed to clients. | ||
| * An [Ably Token](#ably-token) is issued by your servers and passed to clients. | ||
|
|
||
| Note that the machine on which you are running your auth server should have an accurate clock, as tokens and `TokenRequest` contain a timestamp. You can use an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd), or if you are not able to control your server's clock, you can wish to use the `queryTime` [auth option](/docs/api/rest-sdk/types#auth-options). |
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.
| Note that the machine on which you are running your auth server should have an accurate clock, as tokens and `TokenRequest` contain a timestamp. You can use an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd), or if you are not able to control your server's clock, you can wish to use the `queryTime` [auth option](/docs/api/rest-sdk/types#auth-options). | |
| Note that the machine on which you are running your auth server should have an accurate clock, as tokens and `TokenRequest` contain a timestamp and have limited validity. You can use an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd), or if you are not able to control your server's clock, you can wish to use the `queryTime` [auth option](/docs/api/rest-sdk/types#auth-options). |
|
|
||
| ### Multi-tenant SaaS with user roles <a id="scenario-multitenant"/> | ||
|
|
||
| **Recommendation: Ably JWT with channel claims** |
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.
Please do not use bold like this. Use a heading if appropriate, or just plain text.
I don't understand why these channel claims are relevant to this use-case - can you explain?
| ``` | ||
| </Code> | ||
|
|
||
| Other clients can read these trusted claims from presence or message metadata. |
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 is this relevant to a multi-tenanted system?
| { | ||
| 'x-ably-capability': JSON.stringify({ | ||
| // Only allow access to a specific room | ||
| 'your-room::$chat': ['publish', 'subscribe', 'presence', 'history'], |
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 think this is incorrect. A resource specifier in a capability expression will match on the channel name without the directive part.
|
|
||
| <Aside data-type='important'> | ||
| The examples use basic authentication to demonstrate features for convenience. In your own applications, basic authentication should never be used on the client-side as it exposes your Ably API key. Instead, use token authentication. | ||
| **Security requirement:** Client-side applications must use [JWT token authentication](/docs/auth/token#choosing-jwt). Never expose your API key in client-side code. |
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.
Please don't use bold like this.
Please don't use the word "security" like this. There are words that mean the specific thing you're trying to say.
m-hulbert
left a comment
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.
Thanks Umair.
I can see this starting to take shape, but I think we need to make some larger changes, as we've made a long page even longer (and arguably more complicated) - with the actual code to get up and running 40% down the page.
I think we should split up the token authentication page into 3/4 separate ones;
- Overview
- Covers anything that is true for all forms of token authentication.
- I think this needs to mention that authentication is handled by the Pub/Sub SDK and what that means for other products.
- JWTs
- Just info on JWTs with a mention at the top that it's recommended.
authCallbackused in examples in all languages -authUrlcan be further down with associated examples, but most people will use the callback. - Note on when you'd use Ably native Tokens instead in the intro.
- Just info on JWTs with a mention at the top that it's recommended.
- Ably Tokens
- Note at the top that JWTs are recommended and you'd only use Ably Tokens in these circumstances.
- All info on Ably Token mechanisms. (I'd also include a token embedded in a JWT on this page personally, but defer to @paddy on the popularity of that).
- Token revocation
- Makes sense to nest this if we create this section.
We've also added a lot of "JWT is recommended" in places, but I feel we should just stick to the points around length of the JWT and its publicly visible claims. If we create a token authentication overview, I feel all we need to state is 'use JWT authentication unless...". And then reiterate that at the top of the JWT and Ably Token pages.
Can we also ensure we have full coverage for all languages whilst we're updating this please?
|
|
||
| ## Token mechanism comparison <a id="comparison"/> | ||
|
|
||
| | Feature | Ably JWT (Recommended) | Embedded JWT | TokenRequest | |
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 feel this is sort of trying to justify the use of JWTs which I'm not sure is strictly necessary if we position it as the recommended approach. Would be curious on other opinions though.
|
|
||
| | Feature | Ably JWT (Recommended) | Embedded JWT | TokenRequest | | ||
| |---------|:----------------------:|:------------:|:------------:| | ||
| | **Server SDK required** | No | Yes | Yes | |
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 why some of these rows are bold and others aren't.
| meta_description: "Configure authentication for Chat applications with the required capabilities." | ||
| --- | ||
|
|
||
| This page covers Chat-specific capabilities and room scoping. For client setup and server implementation, see [SDK setup](/docs/chat/setup). |
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.
We don't tend to write 'this page covers'. This should dive straight into what Chat authentication is, and that it's handled by the Pub/Sub SDK.
We also spoke about this replacing the SDK setup page, so I don't think we should be updating that page, and adding this one as it's just splitting the info between two pages. Especially when this page (which should be the go-to for auth) is only showing JS examples.
|
|
||
| Capabilities are permissions that control what operations a client can perform. When you create a token for a Chat user, you specify which capabilities they have. Each Chat feature requires specific capabilities: | ||
|
|
||
| | Feature | Required Capabilities | |
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.
We seem to have taken the table from the existing setup page and added more rows unnecessarily.
| // Server-side JWT with room-scoped capabilities | ||
| import jwt from 'jsonwebtoken'; | ||
|
|
||
| const [keyName, keySecret] = process.env.ABLY_API_KEY.split(':'); |
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.
We should be using the variable for a demo key in all code examples please.
|
|
||
| - **Token lifecycle**: Tokens expire and the SDK automatically refreshes them via your `authCallback` - see [Token authentication](/docs/auth/token) | ||
| - **Revoke access**: You can instantly revoke tokens for compromised or banned users - see [Token revocation](/docs/auth/revocation) | ||
| - **Dynamic permissions**: Users can get new capabilities by re-authenticating (e.g., when a moderator grants permissions) - see [Capabilities](/docs/auth/capabilities) |
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.
Can we ensure links are included inline rather than having 'see X' or 'read more' everywhere please.
| @@ -0,0 +1,115 @@ | |||
| --- | |||
| title: Spaces authentication | |||
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 think most of my comments from chat are relevant here.
|
|
||
| ## Space-scoped capabilities | ||
|
|
||
| You can restrict tokens to specific spaces. Spaces uses multiple channels per space: |
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.
This is the first point we're mentioning that space is equivalent to a channel. Before now you have no idea or concept of their relationship.
| ## Space-scoped capabilities | ||
|
|
||
| You can restrict tokens to specific spaces. Spaces uses multiple channels per space: | ||
| - The main space channel (`your-space`) handles presence and member locations |
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.
IIRC the channel name is your-space::$space. I'm not 100% if spaces directives are handled in capabilities automatically the same way that chat ones are though.
|
|
||
| Use `authCallback` to fetch JWTs from your auth server: | ||
|
|
||
| <Code> |
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.
Also needs React.
Description
Motivations/Objectives:
Checklist