mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: prevent authentication of non-unique oidc subjects (#16498)
Any IdP returning an empty field here breaks the assumption of a unique subject id. This is defined in the OIDC spec.
This commit is contained in:
@ -1112,6 +1112,20 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if idToken.Subject == "" {
|
||||
logger.Error(ctx, "oauth2: missing 'sub' claim field in OIDC token",
|
||||
slog.F("source", "id_token"),
|
||||
slog.F("claim_fields", claimFields(idtokenClaims)),
|
||||
slog.F("blank", blankFields(idtokenClaims)),
|
||||
)
|
||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||
Message: "OIDC token missing 'sub' claim field or 'sub' claim field is empty.",
|
||||
Detail: "'sub' claim field is required to be unique for all users by a given issue, " +
|
||||
"an empty field is invalid and this authentication attempt is rejected.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
logger.Debug(ctx, "got oidc claims",
|
||||
slog.F("source", "id_token"),
|
||||
slog.F("claim_fields", claimFields(idtokenClaims)),
|
||||
|
Reference in New Issue
Block a user