Verify OAuth2 ID tokens before trusting claims

The compliance portal OAuth callback accepted ID tokens after only
parsing claims, without checking the signature, issuer, audience, or
expiry. Add RS256 verification helpers to the JOSE package, enforce
those checks in ParseIDTokenIdentity, and thread JWKS, issuer, and
client ID through the token response and callback handler.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-15 14:38:37 +02:00
parent 4e73bd6a97
commit 48dba254ca
6 changed files with 711 additions and 4 deletions

View File

@@ -128,7 +128,13 @@ func (h *OAuthCallbackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
return
}
identityID, err := oauth2.ParseIDTokenIdentity(tokenResult.IDToken, state.Nonce)
identityID, err := oauth2.ParseIDTokenIdentity(
tokenResult.IDToken,
h.iam.OAuth2ServerService.JWKS(),
state.Nonce,
h.iam.OAuth2ServerService.Issuer(),
tokenResult.ClientID.String(),
)
if err != nil {
h.logger.WarnCtx(ctx, "cannot validate id token", log.Error(err))
httpserver.RenderError(w, http.StatusBadRequest, errInvalidOAuthRequest)