Feat v0.6.6 final hardening (#41)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m47s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 29s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #41.
This commit is contained in:
2026-03-31 17:40:40 +00:00
committed by xcaliber
parent 81c28a50bf
commit 7915d84c8b
19 changed files with 625 additions and 131 deletions

View File

@@ -246,6 +246,7 @@ type oidcClaims struct {
Email string `json:"email"`
PreferredUsername string `json:"preferred_username"`
Name string `json:"name"`
Nonce string `json:"nonce"`
Groups []string `json:"groups"`
RealmAccess realmAccess `json:"realm_access"`
ResourceAccess interface{} `json:"resource_access"`
@@ -304,6 +305,23 @@ func (p *OIDCProvider) validateToken(tokenString string) (*oidcClaims, error) {
return claims, nil
}
// ValidateIDTokenNonce validates that the ID token's nonce claim matches the
// stored nonce from the authorization request. This prevents token replay and
// substitution attacks in the authorization code flow.
func (p *OIDCProvider) ValidateIDTokenNonce(tokenString, expectedNonce string) error {
if expectedNonce == "" {
return nil // no nonce to validate (e.g. direct token flow)
}
claims, err := p.validateToken(tokenString)
if err != nil {
return fmt.Errorf("token validation failed: %w", err)
}
if claims.Nonce != expectedNonce {
return fmt.Errorf("nonce mismatch: expected %q, got %q", expectedNonce, claims.Nonce)
}
return nil
}
// isIdPAdmin checks whether the OIDC claims include the configured admin role.
func (p *OIDCProvider) isIdPAdmin(claims *oidcClaims) bool {
for _, role := range claims.RealmAccess.Roles {