Skip to content

Commit 7e1718f

Browse files
committed
*: format all files using newer Go versions
1 parent 752fcad commit 7e1718f

3 files changed

Lines changed: 39 additions & 42 deletions

File tree

jose.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !golint
12
// +build !golint
23

34
// Don't lint this file. We don't want to have to add a comment to each constant.

oidc.go

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ var (
4646
// This method sets the same context key used by the golang.org/x/oauth2 package,
4747
// so the returned context works for that package too.
4848
//
49-
// myClient := &http.Client{}
50-
// ctx := oidc.ClientContext(parentContext, myClient)
51-
//
52-
// // This will use the custom client
53-
// provider, err := oidc.NewProvider(ctx, "https://accounts.example.com")
49+
// myClient := &http.Client{}
50+
// ctx := oidc.ClientContext(parentContext, myClient)
5451
//
52+
// // This will use the custom client
53+
// provider, err := oidc.NewProvider(ctx, "https://accounts.example.com")
5554
func ClientContext(ctx context.Context, client *http.Client) context.Context {
5655
return context.WithValue(ctx, oauth2.HTTPClient, client)
5756
}
@@ -160,14 +159,14 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
160159

161160
// Claims unmarshals raw fields returned by the server during discovery.
162161
//
163-
// var claims struct {
164-
// ScopesSupported []string `json:"scopes_supported"`
165-
// ClaimsSupported []string `json:"claims_supported"`
166-
// }
162+
// var claims struct {
163+
// ScopesSupported []string `json:"scopes_supported"`
164+
// ClaimsSupported []string `json:"claims_supported"`
165+
// }
167166
//
168-
// if err := provider.Claims(&claims); err != nil {
169-
// // handle unmarshaling error
170-
// }
167+
// if err := provider.Claims(&claims); err != nil {
168+
// // handle unmarshaling error
169+
// }
171170
//
172171
// For a list of fields defined by the OpenID Connect spec see:
173172
// https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
@@ -318,18 +317,17 @@ type IDToken struct {
318317

319318
// Claims unmarshals the raw JSON payload of the ID Token into a provided struct.
320319
//
321-
// idToken, err := idTokenVerifier.Verify(rawIDToken)
322-
// if err != nil {
323-
// // handle error
324-
// }
325-
// var claims struct {
326-
// Email string `json:"email"`
327-
// EmailVerified bool `json:"email_verified"`
328-
// }
329-
// if err := idToken.Claims(&claims); err != nil {
330-
// // handle error
331-
// }
332-
//
320+
// idToken, err := idTokenVerifier.Verify(rawIDToken)
321+
// if err != nil {
322+
// // handle error
323+
// }
324+
// var claims struct {
325+
// Email string `json:"email"`
326+
// EmailVerified bool `json:"email_verified"`
327+
// }
328+
// if err := idToken.Claims(&claims); err != nil {
329+
// // handle error
330+
// }
333331
func (i *IDToken) Claims(v interface{}) error {
334332
if i.claims == nil {
335333
return errors.New("oidc: claims not set")

verify.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,18 @@ type IDTokenVerifier struct {
5050
// This constructor can be used to create a verifier directly using the issuer URL and
5151
// JSON Web Key Set URL without using discovery:
5252
//
53-
// keySet := oidc.NewRemoteKeySet(ctx, "https://www.googleapis.com/oauth2/v3/certs")
54-
// verifier := oidc.NewVerifier("https://accounts.google.com", keySet, config)
53+
// keySet := oidc.NewRemoteKeySet(ctx, "https://www.googleapis.com/oauth2/v3/certs")
54+
// verifier := oidc.NewVerifier("https://accounts.google.com", keySet, config)
5555
//
5656
// Since KeySet is an interface, this constructor can also be used to supply custom
5757
// public key sources. For example, if a user wanted to supply public keys out-of-band
5858
// and hold them statically in-memory:
5959
//
60-
// // Custom KeySet implementation.
61-
// keySet := newStatisKeySet(publicKeys...)
62-
//
63-
// // Verifier uses the custom KeySet implementation.
64-
// verifier := oidc.NewVerifier("https://auth.example.com", keySet, config)
60+
// // Custom KeySet implementation.
61+
// keySet := newStatisKeySet(publicKeys...)
6562
//
63+
// // Verifier uses the custom KeySet implementation.
64+
// verifier := oidc.NewVerifier("https://auth.example.com", keySet, config)
6665
func NewVerifier(issuerURL string, keySet KeySet, config *Config) *IDTokenVerifier {
6766
return &IDTokenVerifier{keySet: keySet, config: config, issuer: issuerURL}
6867
}
@@ -190,19 +189,18 @@ func parseClaim(raw []byte, name string, v interface{}) error {
190189
//
191190
// See: https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
192191
//
193-
// oauth2Token, err := oauth2Config.Exchange(ctx, r.URL.Query().Get("code"))
194-
// if err != nil {
195-
// // handle error
196-
// }
197-
//
198-
// // Extract the ID Token from oauth2 token.
199-
// rawIDToken, ok := oauth2Token.Extra("id_token").(string)
200-
// if !ok {
201-
// // handle error
202-
// }
192+
// oauth2Token, err := oauth2Config.Exchange(ctx, r.URL.Query().Get("code"))
193+
// if err != nil {
194+
// // handle error
195+
// }
203196
//
204-
// token, err := verifier.Verify(ctx, rawIDToken)
197+
// // Extract the ID Token from oauth2 token.
198+
// rawIDToken, ok := oauth2Token.Extra("id_token").(string)
199+
// if !ok {
200+
// // handle error
201+
// }
205202
//
203+
// token, err := verifier.Verify(ctx, rawIDToken)
206204
func (v *IDTokenVerifier) Verify(ctx context.Context, rawIDToken string) (*IDToken, error) {
207205
jws, err := jose.ParseSigned(rawIDToken)
208206
if err != nil {

0 commit comments

Comments
 (0)