Golang port of OAuth2Client.prototype.verifyIdToken from google-auth-library-nodejs
Verify idtoken without making http request to tokeninfo API.
import (
"github.com/futurenda/google-auth-id-token-verifier"
)
v := googleAuthIDTokenVerifier.Verifier{}
aud := "xxxxxx-yyyyyyy.apps.googleusercontent.com"
err := v.VerifyIDToken(TOKEN, []string{
aud,
})
if err == nil {
claimSet, err := googleAuthIDTokenVerifier.Decode(TOKEN)
// claimSet.Iss,claimSet.Email ... (See claimset.go)
}
- Fetch public key from www.googleapis.com/oauth2/v3/certs
- Respect cache-control in response from www.googleapis.com/oauth2/v3/certs
- JWT Parser
- Check Signature
- Check IssueTime, ExpirationTime with ClockSkew
- Check Issuer
- Check Audience
- golang.org/x/oauth2/jws