Repository navigation
feat(sso): log OIDC groups diagnostics without exposing tokens or PII - #139
Merged
Merged
Conversation
Group-mapping failures (notably with Okta) were opaque: a missing groups claim was coerced to [] and the denial log said only "no matching role mapping". Each OIDC login now logs the claim names present in the ID token and userinfo, the granted scopes, where the groups claim was found and its shape, and how the role was resolved (matched mappings, default role used, group counts). Claim values, tokens and the userinfo payload are never logged. Raw group names sit behind a separate auth:oidc:groups debug namespace, capped in number and length, with control characters stripped from IdP-supplied values. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Group-mapping failures with OIDC providers (notably Okta) were hard to diagnose: a missing groups claim was coerced to
[], and the denial log said only "no matching role mapping". This adds targeted diagnostics that show the shape of what the IdP sent, without logging sensitive values.oidc-strategy.js: one line per login with the claim names in the ID token and userinfo, granted scopes, the configuredgroupsClaim, where it was found (id_token/userinfo/none), its type and the group count. A missing claim is now distinguishable from an empty or scalar one.role-mapper.js: newexplainRole()returns the role plus matched mappings, whether the default role was used, and group counts.resolveRole()delegates to it with unchanged behaviour.provider-user-service.js: logs the role decision (role,matchedMappings,defaultRoleUsed, counts). Also benefits SAML and LDAP since they share this service.Security considerations
auth:oidc:groupsdebug namespace (opt-in), capped at 50 entries / 100 chars each.Usage
Set
DEBUG=auth:oidc,auth:provisioning(addauth:oidc:groupstemporarily to see exact group names). Nothing is logged withoutDEBUG, as before.Test plan
test/oidc-logging.tests.js(15 tests): claim shapes, sanitising,explainRole, and the verify callback, including assertions that tokens, PII and raw group names do not appear in output by defaultrole-mapper.resolveRoletests pass (11)🤖 Generated with Claude Code