Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose: Pass ID Token configuration to strategy #297

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func ComposeAllEnabled(config *Config, storage interface{}, secret []byte, key *
storage,
&CommonStrategy{
CoreStrategy: NewOAuth2HMACStrategy(config, secret),
OpenIDConnectTokenStrategy: NewOpenIDConnectStrategy(key),
OpenIDConnectTokenStrategy: NewOpenIDConnectStrategy(config, key),
JWTStrategy: &jwt.RS256JWTStrategy{
PrivateKey: key,
},
Expand Down
4 changes: 3 additions & 1 deletion compose/compose_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ func NewOAuth2JWTStrategy(key *rsa.PrivateKey, strategy *oauth2.HMACSHAStrategy)
}
}

func NewOpenIDConnectStrategy(key *rsa.PrivateKey) *openid.DefaultStrategy {
func NewOpenIDConnectStrategy(config *Config, key *rsa.PrivateKey) *openid.DefaultStrategy {
return &openid.DefaultStrategy{
JWTStrategy: &jwt.RS256JWTStrategy{
PrivateKey: key,
},
Expiry: config.GetIDTokenLifespan(),
Issuer: config.IDTokenIssuer,
}
}
5 changes: 4 additions & 1 deletion compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ type Config struct {
// AuthorizeCodeLifespan sets how long an authorize code is going to be valid. Defaults to fifteen minutes.
AuthorizeCodeLifespan time.Duration

// IDTokenLifespan sets how long an id token is going to be valid. Defaults to one hour.
// IDTokenLifespan sets the default id token lifetime. Defaults to one hour.
IDTokenLifespan time.Duration

// IDTokenIssuer sets the default issuer of the ID Token.
IDTokenIssuer string

// HashCost sets the cost of the password hashing cost. Defaults to 12.
HashCost int

Expand Down
2 changes: 1 addition & 1 deletion handler/openid/flow_explicit_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
h := &OpenIDConnectExplicitHandler{}
areq := fosite.NewAccessRequest(nil)
areq.Client = &fosite.DefaultClient{
//ResponseTypes: fosite.Arguments{"id_token"},
//ResponseTypes: fosite.Arguments{"id_token"},
}
assert.EqualError(t, h.HandleTokenEndpointRequest(nil, areq), fosite.ErrUnknownRequest.Error())
}
Expand Down