Skip to content

Commit 390d0f5

Browse files
committed
id_token not generated for client_credentials refresh grant
1 parent 4004af5 commit 390d0f5

7 files changed

Lines changed: 18 additions & 4 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/go-memdb v1.2.1
1212
github.com/pkg/errors v0.9.1
1313
github.com/stretchr/testify v1.6.1
14-
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
14+
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect
1515
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
1616
gopkg.in/square/go-jose.v2 v2.5.1
1717
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA
4040
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
4141
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
4242
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
43+
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 h1:phUcVbl53swtrUN8kQEXFhUxPlIlWyBfKmidCu7P95o=
44+
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
4345
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
4446
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
4547
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -51,6 +53,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FY
5153
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5254
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5355
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
56+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
57+
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
5458
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
5559
golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
5660
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=

impl/processors/01_grant_type_validator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ func (d *DefaultGrantTypeValidator) HandleTokenEP(_ context.Context, requestCont
2525
if grantType == sdk.GrantResourceOwnerPassword && client.IsPublic() {
2626
return sdkerror.ErrUnsupportedGrantType.WithDescription("'password' grant not allowed for public client")
2727
}
28+
requestContext.GetProfile().SetGrantType(grantType)
2829
return nil
2930
}

impl/processors/01_response_type_validator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ func (d *DefaultResponseTypeValidator) HandleAuthEP(_ context.Context, requestCo
2525
if !approvedGrantTypes.Has(sdk.GrantAuthorizationCode) {
2626
return sdkerror.ErrUnsupportedResponseType.WithDescription("'authorization_code' grant not approved")
2727
}
28+
requestContext.GetProfile().SetGrantType(sdk.GrantAuthorizationCode)
2829
} else if responseType == sdk.ResponseTypeToken || responseType == sdk.ResponseTypeIdToken {
2930
if !approvedGrantTypes.Has(sdk.GrantImplicit) {
3031
return sdkerror.ErrUnsupportedResponseType.WithDebug("'implicit' grant not approved for client")
3132
}
33+
requestContext.GetProfile().SetGrantType(sdk.GrantImplicit)
3234
if responseType == sdk.ResponseTypeIdToken {
3335
nonce := requestContext.GetNonce()
3436
if nonce == "" {

impl/processors/03_redirect_uri_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
type DefaultRedirectURIValidator struct {
1010
}
1111

12-
func (d *DefaultRedirectURIValidator) HandleRPILogoutEP(ctx context.Context, requestContext sdk.IRPILogoutRequestContext) sdk.IError {
12+
func (d *DefaultRedirectURIValidator) HandleRPILogoutEP(_ context.Context, requestContext sdk.IRPILogoutRequestContext) sdk.IError {
1313
logoutRedirectUri := requestContext.GetPostLogoutRedirectUri()
1414
if logoutRedirectUri != "" {
1515
client := requestContext.GetClient()

impl/processors/07_issue_id_token.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ func (d *DefaultIDTokenIssuer) HandleAuthEP(ctx context.Context, requestContext
3535
}
3636

3737
func (d *DefaultIDTokenIssuer) HandleTokenEP(ctx context.Context, requestContext sdk.ITokenRequestContext) sdk.IError {
38-
if requestContext.GetProfile().GetScope().Has(sdk.ScopeOpenid) {
38+
profile := requestContext.GetProfile()
39+
if profile.GetScope().Has(sdk.ScopeOpenid) && profile.GetGrantType() != sdk.GrantClientCredentials {
3940
expiry := requestContext.GetRequestedAt().UTC().Add(d.Lifespan).Round(time.Second)
40-
profile := requestContext.GetProfile()
4141
client := requestContext.GetClient()
4242
tokens := requestContext.GetIssuedTokens()
4343
var tClaims map[string]interface{}

user.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,10 @@ func (r RequestProfile) GetCodeChallengeMethod() string {
102102
func (r RequestProfile) SetCodeChallengeMethod(challengeMethod string) {
103103
r["code_challenge_method"] = challengeMethod
104104
}
105+
func (r RequestProfile) GetGrantType() string {
106+
return r["grant_type"]
107+
}
108+
109+
func (r RequestProfile) SetGrantType(challengeMethod string) {
110+
r["grant_type"] = challengeMethod
111+
}

0 commit comments

Comments
 (0)