@@ -10,10 +10,10 @@ import (
10
10
"sync"
11
11
"time"
12
12
13
- phttp "github.com/coreos /go-oidc/http"
14
- "github.com/coreos /go-oidc/jose"
15
- "github.com/coreos /go-oidc/key"
16
- "github.com/coreos /go-oidc/oauth2"
13
+ phttp "github.com/gambol99 /go-oidc/http"
14
+ "github.com/gambol99 /go-oidc/jose"
15
+ "github.com/gambol99 /go-oidc/key"
16
+ "github.com/gambol99 /go-oidc/oauth2"
17
17
)
18
18
19
19
const (
@@ -408,7 +408,7 @@ func emailsToStrings(addrs []mail.Address) []string {
408
408
//
409
409
// NOTE(ericchiang): For development purposes Valid does not mandate 'https' for
410
410
// URLs fields where the OIDC spec requires it. This may change in future releases
411
- // of this package. See: https://github.com/coreos /go-oidc/issues/34
411
+ // of this package. See: https://github.com/gambol99 /go-oidc/issues/34
412
412
func (m * ClientMetadata ) Valid () error {
413
413
if len (m .RedirectURIs ) == 0 {
414
414
return errors .New ("zero redirect URLs" )
@@ -556,12 +556,13 @@ func (c *ClientRegistrationResponse) UnmarshalJSON(data []byte) error {
556
556
}
557
557
558
558
type ClientConfig struct {
559
- HTTPClient phttp.Client
560
- Credentials ClientCredentials
561
- Scope []string
562
- RedirectURL string
563
- ProviderConfig ProviderConfig
564
- KeySet key.PublicKeySet
559
+ Credentials ClientCredentials
560
+ HTTPClient phttp.Client
561
+ KeySet key.PublicKeySet
562
+ ProviderConfig ProviderConfig
563
+ RedirectURL string
564
+ Scope []string
565
+ SkipClientIDCheck bool
565
566
}
566
567
567
568
func NewClient (cfg ClientConfig ) (* Client , error ) {
@@ -579,6 +580,7 @@ func NewClient(cfg ClientConfig) (*Client, error) {
579
580
redirectURL : ru .String (),
580
581
providerConfig : newProviderConfigRepo (cfg .ProviderConfig ),
581
582
keySet : cfg .KeySet ,
583
+ skipClientID : cfg .SkipClientIDCheck ,
582
584
}
583
585
584
586
if c .httpClient == nil {
@@ -593,19 +595,21 @@ func NewClient(cfg ClientConfig) (*Client, error) {
593
595
return & c , nil
594
596
}
595
597
598
+ // Client is the oidc client
596
599
type Client struct {
597
- httpClient phttp.Client
598
- providerConfig * providerConfigRepo
599
- credentials ClientCredentials
600
- redirectURL string
601
- scope []string
602
- keySet key.PublicKeySet
603
- providerSyncer * ProviderConfigSyncer
604
-
600
+ credentials ClientCredentials
601
+ httpClient phttp.Client
602
+ keySet key.PublicKeySet
605
603
keySetSyncMutex sync.RWMutex
606
604
lastKeySetSync time.Time
605
+ providerConfig * providerConfigRepo
606
+ providerSyncer * ProviderConfigSyncer
607
+ redirectURL string
608
+ scope []string
609
+ skipClientID bool
607
610
}
608
611
612
+ // Healthy checks the provider is healthy
609
613
func (c * Client ) Healthy () error {
610
614
now := time .Now ().UTC ()
611
615
@@ -622,6 +626,7 @@ func (c *Client) Healthy() error {
622
626
return nil
623
627
}
624
628
629
+ // OAuthClient returns a oauth2 client
625
630
func (c * Client ) OAuthClient () (* oauth2.Client , error ) {
626
631
cfg := c .providerConfig .Get ()
627
632
authMethod , err := chooseAuthMethod (cfg )
@@ -771,18 +776,21 @@ func (c *Client) RefreshToken(refreshToken string) (jose.JWT, error) {
771
776
return jwt , c .VerifyJWT (jwt )
772
777
}
773
778
779
+ // VerifyJWT verifies the JWT tokens
774
780
func (c * Client ) VerifyJWT (jwt jose.JWT ) error {
775
781
var keysFunc func () []key.PublicKey
776
- if kID , ok := jwt .KeyID (); ok {
777
- keysFunc = c .keysFuncWithID (kID )
782
+ if kid , ok := jwt .KeyID (); ok {
783
+ keysFunc = c .keysFuncWithID (kid )
778
784
} else {
779
785
keysFunc = c .keysFuncAll ()
780
786
}
781
787
782
788
v := NewJWTVerifier (
783
789
c .providerConfig .Get ().Issuer .String (),
784
790
c .credentials .ID ,
785
- c .maybeSyncKeys , keysFunc )
791
+ c .maybeSyncKeys ,
792
+ keysFunc ,
793
+ c .skipClientID )
786
794
787
795
return v .Verify (jwt )
788
796
}
0 commit comments