Skip to content
Open
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
11 changes: 7 additions & 4 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,13 @@ func (m *MockOIDC) setTokens(tr *tokenResponse, s *Session, grantType string) er
if err != nil {
return err
}
if len(s.Scopes) > 0 && s.Scopes[0] == openidScope {
tr.IDToken, err = s.IDToken(m.Config(), m.Keypair, m.Now())
if err != nil {
return err
for _, scope := range s.Scopes {
if scope == openidScope {
tr.IDToken, err = s.IDToken(m.Config(), m.Keypair, m.Now())
if err != nil {
return err
}
break
}
}
if grantType != "refresh_token" {
Expand Down
5 changes: 4 additions & 1 deletion handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ func TestMockOIDC_Token_CodeGrant(t *testing.T) {
m, err := mockoidc.NewServer(nil)
assert.NoError(t, err)

// Note: we're setting openid to the end of the scope list to test
// that ordering is not considered when checking for "openid" in the
// list
session, _ := m.SessionStore.NewSession(
"openid email profile", "nonce", mockoidc.DefaultUser(), "", "")
"email profile openid", "nonce", mockoidc.DefaultUser(), "", "")

assert.HTTPError(t, m.Token, http.MethodPost, mockoidc.TokenEndpoint, nil)

Expand Down