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

fix verify the JWS E256 signature using the server’s public key #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion providers/apple/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,27 @@ func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string,
if err != nil {
return nil, err
}
pubKeyIface, _ := set.Keys[0].Materialize()

var (
pubKeyIface interface{}
kid string
ok bool
)

if kid, ok = t.Header["kid"].(string); !ok {
vErr.Inner = fmt.Errorf("header kid not found")
vErr.Errors |= jwt.ValidationErrorUnverifiable
return nil, vErr
}

for _, key := range set.Keys {
if key.KeyID() == kid {
if pubKeyIface, err = key.Materialize(); err != nil {
return nil, err
}
}
}

pubKey, ok := pubKeyIface.(*rsa.PublicKey)
if !ok {
return nil, fmt.Errorf(`expected RSA public key from %s`, idTokenVerificationKeyEndpoint)
Expand Down