Skip to content

Commit e0d538a

Browse files
github-actions[bot]maoanran
authored andcommitted
Squashed commit of the following:
commit 42c5270 Author: splaunov <[email protected]> Date: Thu Jul 11 13:54:56 2024 +0300 fix: IDToken nonce should not be checked (PS-385)
1 parent 36e624c commit e0d538a

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

selfservice/strategy/oidc/strategy.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,7 @@ func (s *Strategy) processIDToken(r *http.Request, provider Provider, idToken, i
751751
// If the provider does not support nonces, we don't do validation and return the claim.
752752
// This case only applies to Apple, as some of their devices do not support nonces.
753753
// https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple
754-
} else if idTokenNonce == "" {
755-
// A nonce was present in the JWT token, but no nonce was submitted in the flow
756-
return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("No nonce was provided but is required by the provider"))
757-
} else if idTokenNonce != claims.Nonce {
758-
// The nonce from the JWT token does not match the nonce from the flow.
759-
return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("The supplied nonce does not match the nonce from the id_token"))
760-
}
761-
// Nonce checking was successful
754+
}
762755

763756
return claims, nil
764757
}

selfservice/strategy/oidc/strategy_test.go

-28
Original file line numberDiff line numberDiff line change
@@ -984,23 +984,6 @@ func TestStrategy(t *testing.T) {
984984
require.Equal(t, "No nonce was included in the id_token but is required by the provider", gjson.GetBytes(body, "error.reason").String(), "%s", body)
985985
},
986986
},
987-
{
988-
name: "should fail if no nonce is supplied in request",
989-
idToken: `{
990-
"iss": "https://appleid.apple.com",
991-
"sub": "{{sub}}",
992-
"nonce": "{{nonce}}"
993-
}`,
994-
v: func(provider, token, _ string) url.Values {
995-
return url.Values{
996-
"id_token": {token},
997-
"provider": {provider},
998-
}
999-
},
1000-
expect: func(t *testing.T, res *http.Response, body []byte) {
1001-
require.Equal(t, "No nonce was provided but is required by the provider", gjson.GetBytes(body, "error.reason").String(), "%s", body)
1002-
},
1003-
},
1004987
{
1005988
name: "should pass if claims are valid",
1006989
idToken: `{
@@ -1012,17 +995,6 @@ func TestStrategy(t *testing.T) {
1012995
require.NotEmpty(t, gjson.GetBytes(body, "session_token").String(), "%s", body)
1013996
},
1014997
},
1015-
{
1016-
name: "nonce mismatch",
1017-
idToken: `{
1018-
"iss": "https://appleid.apple.com",
1019-
"sub": "{{sub}}",
1020-
"nonce": "random-nonce"
1021-
}`,
1022-
expect: func(t *testing.T, res *http.Response, body []byte) {
1023-
require.Equal(t, "The supplied nonce does not match the nonce from the id_token", gjson.GetBytes(body, "error.reason").String(), "%s", body)
1024-
},
1025-
},
1026998
} {
1027999
tc := tc
10281000
t.Run(fmt.Sprintf("flow=registration/case=%s", tc.name), func(t *testing.T) {

0 commit comments

Comments
 (0)