feat: add OIDC claim overrides and group filtering#454
Conversation
zxh326
left a comment
There was a problem hiding this comment.
Two issues block this as a safe fix.
-
In
pkg/auth/oauth_provider.go,UsernameClaimandGroupsClaimare implemented as hard replacements rather than preferred claims. If the configured claim is missing or mistyped, Kite stops checking the standard claim chain entirely. That can leaveuser.Usernameempty even when standard fields are present, andFindWithSubOrUpsertUseronly validatesSub, so the first bad login can create a user with an empty username. After that, later logins can start failing on the unique index. The same problem also turnsAllowedGroupsinto a blanket deny if the configured groups claim is wrong. This should either fall back to the existing default extraction logic or fail explicitly before user upsert. -
In
pkg/auth/login_handler.go, the new redirect branch checkserr.Error() == "user is not in any of the allowed groups". That makes the behavior depend on exact error text and will silently regress to genericuser_info_failedif the error is wrapped or reworded. Please use a sentinel or typed error instead.
The overall direction makes sense, but I don't think this is the best fix in its current form.
…d groups, and introduce `ErrNotInAllowedGroups` for better error handling.
Signed-off-by: Zzde <zhangxh1997@gmail.com>
Signed-off-by: Zzde <zhangxh1997@gmail.com>
ed357f0 to
4fb65fb
Compare
|
Thanks @GyroGearl00se I’ve added some end-to-end tests to ensure that everything works as expected. |
Summary
This PR enhances the OIDC/OAuth authentication provider by introducing three new advanced configuration properties:
Why
Some Identity Providers do not adhere to standard OIDC claim names. Giving administrators the flexibility to map these claims as needed.
Furthermore, without group-based filtering (
Allowed Groups), any authenticated user from the configured IDP can successfully log in. By enforcing an allowed groups intersection during the [GetUserInfo] phase, we can proactively deny access to users before they even reach the dashboard, improving security posture.Related issue
Closes #
Validation
Checklist