Repository navigation
Conversation
A user who signed in through the OIDC authorization-code flow got an access token with no `groups` claim: issueOIDCTokens and the refresh grant passed nil groups to buildOIDCAccessClaims. Both userinfo endpoints read groups from the token, so the groups appeared nowhere (OIDC /userinfo omitted them, /api/auth/userinfo answered null), while a direct login's token carried them. A direct login's groups are the directory's groups for the person, as bare CNs (entryToResult), never filtered per app; syncUserFromLDAP stores exactly that set on the user in the same login. The OIDC paths now pass that stored set: - issueOIDCTokens (authorization-code exchange and, sharing it, the password grant) passes user.Groups; - the refresh_token grant passes the resolved user's current user.Groups, so a refreshed token carries the current set and a user removed from every group gets none. It is the set resolveTokenRoles already reads for per-app group assignments. A user with no groups still gets no claim. Roles, permissions, audience, issuer, lifetimes and the id_token are unchanged. Tests drive authorize -> code -> token with PKCE and the refresh grant, and check the access token, OIDC /userinfo and /api/auth/userinfo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For a user in no group, OIDC /userinfo omitted `groups` and /api/auth/userinfo answered null. A client could not tell "no groups" from "groups unavailable" (an older SimpleAuth, or a failure). Both endpoints now answer `groups` as a JSON list through one helper, userinfoGroups: the token's groups, or [] when it carries none. The access token's claim stays omitempty and the id_token is unchanged. The no-groups tests now expect [] from both endpoints for a direct login, the code exchange and its refreshes, and for a user the directory removed from every group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both userinfo endpoints echoed the presented token's `groups` claim. Several token paths set no claim (a local-password direct login, /api/auth/refresh, the session-cookie sign-in, impersonation), so for a user with groups they answered [] since the previous commit, a false "no groups". Both endpoints now answer the resolved user's stored groups, the set synced at their last LDAP or Kerberos sign-in, always as a list, [] when there are none, whatever the token's claim holds. A token minted before the directory moved the user reads the current set. The token claims and the id_token are unchanged. Co-Authored-By: Claude Opus 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
A user who signs in through the OIDC authorization-code flow gets an access token with no
groupsclaim.issueOIDCTokensand the refresh grant passnilgroups tobuildOIDCAccessClaims. Both userinfo endpoints read groups from the token, so the groups appear nowhere: OIDC/userinfoomits them and/api/auth/userinfoanswersnull. A direct login's token, meanwhile, carries them.This change makes the OIDC paths pass the user's stored groups,
user.Groups. That is the setsyncUserFromLDAPstores at each directory sign-in, and the setresolveTokenRolesalready reads for per-app group assignments:issueOIDCTokens: the authorization-code exchange and, sharing it, the password grant;refresh_tokengrant: the resolved user's currentuser.Groups, so a refreshed token carries the current set, and a user removed from every group gets none.A user with no groups still gets no claim. Roles, permissions, audience, issuer, lifetimes and the id_token are unchanged.
Behaviour note (owner decision)
Groups are the last-known set, as stored at the user's last directory sign-in. So OIDC tokens also carry them in four cases where a direct login carries none:
This was chosen deliberately: it is the set SimpleAuth already persists and resyncs at every directory login.
Tests
internal/handler/oidc_groups_test.godrives authorize → code → token, with PKCE, and the refresh grant. It checks the access token, OIDC/userinfoand/api/auth/userinfo, and covers a user with no groups.-race,go vet,gofmtand the build pass.feat/oidc-given-family-name, and the merged tree passes.Verified against a consumer
A local image built from this branch (
simpleauth:2.3.0-groupsfix-local) ran in CORTEX's dev stack. CORTEX's live test signed in a directory user (an, AD groupsCORTEX-AnalystsandTeam-B) through the browser code flow. OIDC userinfo with the session's access token then returned exactly["CORTEX-Analysts","Team-B"]. Before this change, it returned none.Userinfo answers the stored groups (follow-up commits)
Review on the consumer side found that a person in no group got no
groupsmember at all. So a consumer couldn't tell "no groups" from "groups unavailable", whether that came from an older SimpleAuth or a failure.Two follow-up commits close this:
d2bf301: both userinfo endpoints always answergroupsas a JSON list,[]when the user has none.223a2ce: both userinfo endpoints answer from the user's stored groups (user.Groups, synced at the last directory sign-in), whatever the presented token's claim holds. This avoids a false "no groups" for tokens whose minting path never set the claim:/api/auth/refresh, a session-cookie sign-in, impersonation, and a local-password or LDAP-down direct login. It is consistent with the last-known-groups behaviour above.Token claims and the id_token are unchanged. Userinfo
rolesstill come from the token, so for a token minted before a group change they can laggroupsuntil the next refresh.TestUserinfoAnswersStoredGroupsfailed first, then passed. It covers a local-password login,/api/auth/refresh, impersonation and a pre-change token. All 13 mutants are caught, and the suite,-race,vet,gofmtand the build pass.Not included
There is no version bump, tag or release; that is left to the maintainer.
CHANGELOG.mdgains an Unreleased entry, anddocs/API.mdis corrected.🤖 Generated with Claude Code