@@ -13,6 +13,7 @@ import (
13
13
)
14
14
15
15
const (
16
+ DefaultRequestTimeout = 30 * time .Second
16
17
DefaultExpirationRefreshRatio = 0.7
17
18
DefaultRetryOptionsMaxAttempts = 3
18
19
DefaultRetryOptionsBackoffMultiplier = 2.0
@@ -85,6 +86,9 @@ func defaultTokenManagerOptionsOr(options TokenManagerOptions) TokenManagerOptio
85
86
if options .ExpirationRefreshRatio == 0 {
86
87
options .ExpirationRefreshRatio = DefaultExpirationRefreshRatio
87
88
}
89
+ if options .RequestTimeout == 0 {
90
+ options .RequestTimeout = DefaultRequestTimeout
91
+ }
88
92
return options
89
93
}
90
94
@@ -108,16 +112,31 @@ func (*defaultIdentityProviderResponseParser) ParseResponse(response shared.Iden
108
112
if err != nil {
109
113
return nil , fmt .Errorf ("failed to get auth result: %w" , err )
110
114
}
111
- if authResult .ExpiresOn .IsZero () {
112
- return nil , fmt .Errorf ("auth result expiration time is not set" )
115
+
116
+ claims := struct {
117
+ jwt.RegisteredClaims
118
+ Oid string `json:"oid,omitempty"`
119
+ }{}
120
+
121
+ // Parse the token to extract claims, but note that signature verification
122
+ // should be handled by the identity provider
123
+ _ , _ , err = jwt .NewParser ().ParseUnverified (authResult .AccessToken , & claims )
124
+ if err != nil {
125
+ return nil , fmt .Errorf ("failed to parse JWT token: %w" , err )
113
126
}
114
- if authResult .IDToken .Oid == "" {
127
+
128
+ if claims .Oid == "" {
115
129
return nil , fmt .Errorf ("auth result OID is empty" )
116
130
}
117
- rawToken = authResult .IDToken .RawToken
118
- username = authResult .IDToken .Oid
131
+
132
+ if claims .ExpiresAt .IsZero () {
133
+ return nil , fmt .Errorf ("auth result expiration time is not set" )
134
+ }
135
+
136
+ rawToken = authResult .AccessToken
137
+ username = claims .Oid
119
138
password = rawToken
120
- expiresOn = authResult . ExpiresOn .UTC ()
139
+ expiresOn = claims . ExpiresAt .UTC ()
121
140
122
141
case shared .ResponseTypeRawToken , shared .ResponseTypeAccessToken :
123
142
var tokenStr string
0 commit comments