Add optional PrivateClaims to jwt.Config

This commit is contained in:
Frank He 2019-03-07 22:22:33 -08:00 committed by GitHub
parent e64efc72b4
commit 9dd27cc44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -66,6 +66,9 @@ type Config struct {
// request. If empty, the value of TokenURL is used as the // request. If empty, the value of TokenURL is used as the
// intended audience. // intended audience.
Audience string Audience string
// PrivateClaims optionally specifies private claims in the JWT.
PrivateClaims map[string]interface{}
} }
// TokenSource returns a JWT TokenSource using the configuration // TokenSource returns a JWT TokenSource using the configuration
@ -100,6 +103,7 @@ func (js jwtSource) Token() (*oauth2.Token, error) {
Iss: js.conf.Email, Iss: js.conf.Email,
Scope: strings.Join(js.conf.Scopes, " "), Scope: strings.Join(js.conf.Scopes, " "),
Aud: js.conf.TokenURL, Aud: js.conf.TokenURL,
PrivateClaims: js.conf.PrivateClaims,
} }
if subject := js.conf.Subject; subject != "" { if subject := js.conf.Subject; subject != "" {
claimSet.Sub = subject claimSet.Sub = subject