Repository navigation
docs: Elements reads the user key from the environment's user key claim (PER-17237) #686
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,27 @@ To confirm that the JWKS contains the key for your tokens, compare the `kid` in | |
|
|
||
| To configure a JWKS without the dashboard, update the environment with `PATCH /v2/projects/{proj_id}/envs/{env_id}` and set the `jwks` field. The `jwks` field accepts a `jwks` object with a `keys` array, or a `url`, and an optional `ttl`: the time in seconds Permit caches the JWKS (default `600`). See the [Environments API reference](https://api.permit.io/v2/redoc#tag/Environments). | ||
|
|
||
| ## Set the user key claim \{#user-key-claim} | ||
|
|
||
| When a user logs in to Permit Elements with `LoginMethod.frontendOnly`, or approves an Elements invite with their JWT, Permit reads the user's Permit key from one claim of the JWT. That claim is `sub` unless you set another one on the environment. If your identity provider puts the user key in a different claim, set `user_key_claim` in the `jwks` field: | ||
|
|
||
| ```bash | ||
| curl -X PATCH 'https://api.permit.io/v2/projects/{proj_id}/envs/{env_id}' \ | ||
| -H 'authorization: Bearer API_SECRET_KEY' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{"jwks": {"url": "<YOUR_JWKS_URL>", "user_key_claim": "<CLAIM_NAME>"}}' | ||
| ``` | ||
|
|
||
| - **Name only a claim your identity provider sets.** Permit refuses claims that the user or the client can set, such as an OIDC `nonce`, `name` or `aud`. A custom claim filled from profile data the user can edit is just as unsafe. | ||
| - **The value must be a non-empty string or an integer.** Permit reads an integer as its decimal string. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [LOW] Say this rule is about the claim's value in the token Problem: "The value" can be read as the value of the Suggestion: - **The claim's value in the token must be a non-empty string or an integer.** Permit reads an integer as its decimal string.Introduced in bb3e455 |
||
| - **`email` needs a verified email.** Permit accepts the `email` claim only from a token whose `email_verified` claim is the JSON boolean `true`. Tokens without `email_verified`, such as Entra ID's, or with the string `"true"` can't use it. A user keyed by email changes key when their email changes at the identity provider. | ||
| - **On a shared identity provider, also set `issuer` and `audience`.** For a JWKS URL on Entra ID, Google, Apple, Salesforce, LinkedIn or Facebook, a request that sets or changes `user_key_claim` needs `issuer` and `audience` in the same configuration. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [LOW] Say what Problem: No other docs page mentions the
While Suggestion: Name the fields and show them in a request body, for example: - **On a shared identity provider, also set `issuer` and `audience`.** For a JWKS URL on Entra ID, Google, Apple, Salesforce, LinkedIn or Facebook, a request that sets or changes `user_key_claim` needs both in the same `jwks` object: `issuer` is the `iss` your tokens carry, and `audience` is a value of their `aud`. For example: `{"jwks": {"url": "<YOUR_JWKS_URL>", "issuer": "<YOUR_ISSUER>", "audience": "<YOUR_AUDIENCE>", "user_key_claim": "<CLAIM_NAME>"}}`. While `user_key_claim` is set, neither can be cleared.Introduced in bb3e455 |
||
| - **Changing the claim changes which user each token logs in as.** Users whose Permit key matches the old claim's value don't match the new one. | ||
|
|
||
| To go back to `sub`, send `"user_key_claim": null`. Removing the whole configuration with `"jwks": null` removes it as well. | ||
|
|
||
| `permit.elements.login()` and the invite approval request also accept a `userKeyClaim` (`user_key_claim`) parameter. Set the claim on the environment instead. If you pass the parameter, it must be `sub` or the environment's `user_key_claim`. When the environment sets `user_key_claim`, Permit rejects any other value. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Drop the conditional last sentence Problem: The sentence before it already gives the rule for this parameter: if you pass it, it must be Suggestion: Delete "When the environment sets `permit.elements.login()` and the invite approval request also accept a `userKeyClaim` (`user_key_claim`) parameter. Set the claim on the environment instead. If you pass the parameter, it must be `sub` or the environment's `user_key_claim`, or Permit rejects the request.Introduced in bb3e455 |
||
|
|
||
| ## Next steps | ||
|
|
||
| - [Embed Permit Elements in your application](/embeddable-uis/embedding-elements) | ||
|
|
||
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.
[LOW] Say that the
jwksobject replaces the stored configurationProblem: A
PATCHreplaces the storedjwksobject with the one in the request. Onlyissuer,audienceanduser_key_claimare kept when the request leaves them out. Readers who copy this example may not expect three things:jwks.keyshas to send its keys again (the example shows onlyurl);ttlgoes back to600unless it is sent again;jwksobject that carries onlyuser_key_claimis rejected with 422. That includes the"user_key_claim": nullon line 94, which also needs theurlorjwks.keys.Suggestion: Add a sentence after the example, and point line 94 at it:
At line 94, for example: "To go back to
sub, send the same configuration with"user_key_claim": null."Introduced in bb3e455