Skip to content

Commit aab889e

Browse files
docs: restore JWT Claims Mapping section to authentication.mdx
The JWT Claims Mapping section was inadvertently removed during the merge conflict resolution in commit da30906. This commit restores the complete Claims Mapping documentation including: - Default mapping paths explanation - claims_mapping configuration option details - Custom override examples with JSON Pointer syntax - Example JWT payload and resulting metadata - Notes about invalid expressions being silently ignored Co-authored-by: Mark Phelps <[email protected]>
1 parent 4e40008 commit aab889e

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

v2/configuration/authentication.mdx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,3 +527,70 @@ authentication:
527527
528528
audiences: https://flipt.io/, https://flipt.com/ # at least one audience must match
529529
```
530+
531+
#### Claims Mapping
532+
533+
By default, Flipt extracts user attributes from JWT claims using predefined paths within the JWT payload. The default mappings are:
534+
535+
- `email` from `/user/email`
536+
- `name` from `/user/name`
537+
- `sub` from `/user/sub`
538+
- `picture` from `/user/image`
539+
- `role` from `/user/role`
540+
541+
You can customize these mappings using the `claims_mapping` configuration option. This allows you to specify [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) expressions to extract user attributes from different locations in the JWT payload.
542+
543+
The custom mappings are merged with the default mappings, so you can override specific attributes while keeping the defaults for others.
544+
545+
<Note>
546+
Only the predefined attribute names (`email`, `name`, `sub`, `picture`,
547+
`role`) are supported in claims mapping. Custom attribute names are not
548+
allowed to ensure compatibility with consuming code.
549+
</Note>
550+
551+
```yaml config.yaml
552+
authentication:
553+
required: true
554+
methods:
555+
jwt:
556+
enabled: true
557+
claims_mapping:
558+
email: "/user/email" # Override default (same path)
559+
name: "/profile/displayName" # Override default (custom path)
560+
sub: "/user_id" # Override default (custom path)
561+
```
562+
563+
With this configuration:
564+
565+
- `email` is extracted from `/user/email` (default behavior)
566+
- `name` is extracted from `/profile/displayName` (custom override)
567+
- `sub` is extracted from `/user_id` (custom override)
568+
- `picture` is still extracted from `/user/image` (default, not overridden)
569+
- `role` is still extracted from `/user/role` (default, not overridden)
570+
571+
**Example JWT payload:**
572+
573+
```json
574+
{
575+
"iss": "https://auth0.com/",
576+
"sub": "auth0|123456",
577+
"user_id": "12345",
578+
"user": {
579+
"email": "[email protected]"
580+
},
581+
"profile": {
582+
"displayName": "John Doe"
583+
}
584+
}
585+
```
586+
587+
The resulting metadata available in Flipt would be:
588+
589+
- `io.flipt.auth.jwt.email`: `[email protected]`
590+
- `io.flipt.auth.jwt.name`: `John Doe`
591+
- `io.flipt.auth.jwt.sub`: `12345`
592+
593+
<Note>
594+
Invalid JSON Pointer expressions or paths that don't exist in the JWT payload
595+
are silently ignored.
596+
</Note>

0 commit comments

Comments
 (0)