Skip to content

Commit

Permalink
openid: Issue ID Token on implicit code flow as well
Browse files Browse the repository at this point in the history
  • Loading branch information
arekkas committed May 24, 2018
1 parent 28822d7 commit e15b3c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions compose/compose_openid.go
Expand Up @@ -91,6 +91,7 @@ func OpenIDConnectHybridFactory(config *Config, storage interface{}, strategy in
IDTokenHandleHelper: &openid.IDTokenHandleHelper{
IDTokenStrategy: strategy.(openid.OpenIDConnectTokenStrategy),
},
OpenIDConnectRequestStorage: storage.(openid.OpenIDConnectRequestStorage),
OpenIDConnectRequestValidator: openid.NewOpenIDConnectRequestValidator(config.AllowedPromptValues, strategy.(jwt.JWTStrategy)),
}
}
7 changes: 7 additions & 0 deletions handler/openid/flow_hybrid.go
Expand Up @@ -39,6 +39,7 @@ type OpenIDConnectHybridHandler struct {
IDTokenHandleHelper *IDTokenHandleHelper
ScopeStrategy fosite.ScopeStrategy
OpenIDConnectRequestValidator *OpenIDConnectRequestValidator
OpenIDConnectRequestStorage OpenIDConnectRequestStorage

Enigma *jwt.RS256JWTStrategy
}
Expand Down Expand Up @@ -103,6 +104,12 @@ func (c *OpenIDConnectHybridHandler) HandleAuthorizeEndpointRequest(ctx context.
return err
}
claims.CodeHash = base64.RawURLEncoding.EncodeToString([]byte(hash[:c.Enigma.GetSigningMethodLength()/2]))

if ar.GetGrantedScopes().Has("openid") {
if err := c.OpenIDConnectRequestStorage.CreateOpenIDConnectSession(ctx, resp.GetCode(), ar.Sanitize(oidcParameters)); err != nil {
return errors.WithStack(fosite.ErrServerError.WithDebug(err.Error()))
}
}
}

if ar.GetResponseTypes().Has("token") {
Expand Down
1 change: 1 addition & 0 deletions handler/openid/flow_hybrid_test.go
Expand Up @@ -96,6 +96,7 @@ func TestHybrid_HandleAuthorizeEndpointRequest(t *testing.T) {
},
ScopeStrategy: fosite.HierarchicScopeStrategy,
OpenIDConnectRequestValidator: NewOpenIDConnectRequestValidator(nil, j.RS256JWTStrategy),
OpenIDConnectRequestStorage: storage.NewMemoryStore(),
}

for k, c := range []struct {
Expand Down

0 comments on commit e15b3c1

Please sign in to comment.