Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Allow the nonce to be empty #27

Merged
merged 2 commits into from
Jan 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/provider/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ func (c *oidcExchangeConfig) verifyUpdateToken(ctx context.Context, t *Token) er
return fmt.Errorf("provider: oidc: verification error: %+v", err)
}

if subtle.ConstantTimeEq(int32(len(idToken.Nonce)), int32(len(c.nonce))) == 0 ||
subtle.ConstantTimeCompare([]byte(idToken.Nonce), []byte(c.nonce)) == 0 {
// If nonce is configured, make sure it matches the nonce in
// the ID token. It is not configured when refresh_token is
// sent in from an external source.
if len(c.nonce) > 0 &&
(subtle.ConstantTimeEq(int32(len(idToken.Nonce)), int32(len(c.nonce))) == 0 ||
subtle.ConstantTimeCompare([]byte(idToken.Nonce), []byte(c.nonce)) == 0) {
return ErrOIDCNonceMismatch
}

Expand Down