Skip to content
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

feat: ability to map custom claims #338

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Ory OAuth2 requires more setup to get CSRF cookies on the `/consent` endpoint.
name without the `__Host-` prefix.
- `TRUSTED_CLIENT_IDS` (optional): A list of trusted client ids. They can be set
to skip the consent screen.
- `ID_TOKEN_TRAITS` (optional): A comma separated list of identity traits to be
mapped to id_token.

Getting TLS working:

Expand Down
10 changes: 10 additions & 0 deletions src/routes/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ const extractSession = (
session.id_token.name = identity.traits.name
}

const traitsToMap = process.env.ID_TOKEN_TRAITS
if (traitsToMap) {
const traits = traitsToMap.split(",")
for (const trait of traits) {
if (identity.traits[trait]) {
session.id_token[trait] = identity.traits[trait]
}
}
}

if (identity.updated_at) {
session.id_token.updated_at = Date.parse(identity.updated_at)
}
Expand Down
Loading