Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c8ee5c

Browse files
authored
fix(coderd): support string type for oidc response's expires_in json property (#20152)
Some versions of Azure AD return expires_in property as string. Usejson.Number to accept either integer or string and then convert toint64.Helpful links:https://learn.microsoft.com/en-us/answers/questions/2337020/azure-ad-token-endpoint-returns-expires-in-as-strihttps://feedback.azure.com/d365community/idea/7772fd95-26e6-ec11-a81b-0022484ee92d
1 parent91d4f8b commit1c8ee5c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎coderd/oauthpki/oidcpki.go‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ func (src *jwtTokenSource) Token() (*oauth2.Token, error) {
222222
RefreshTokenstring`json:"refresh_token,omitempty"`
223223

224224
// Extra fields returned by the refresh that are needed
225-
IDTokenstring`json:"id_token"`
226-
ExpiresInint64`json:"expires_in"`// relative seconds from now
225+
IDTokenstring`json:"id_token"`
226+
ExpiresIn json.Number`json:"expires_in"`// relative seconds from now, use Number since Azure AD might return string
227+
227228
// error fields
228229
// https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
229230
ErrorCodestring`json:"error"`
@@ -256,8 +257,13 @@ func (src *jwtTokenSource) Token() (*oauth2.Token, error) {
256257
RefreshToken:tokenRes.RefreshToken,
257258
}
258259

259-
ifsecs:=tokenRes.ExpiresIn;secs>0 {
260-
newToken.Expiry=time.Now().Add(time.Duration(secs)*time.Second)
260+
expiresIn,convertErr:=tokenRes.ExpiresIn.Int64()
261+
ifconvertErr!=nil {
262+
returnnil,xerrors.Errorf("oauth2: cannot convert expires_in to int64: %w",convertErr)
263+
}
264+
265+
ifexpiresIn>0 {
266+
newToken.Expiry=time.Now().Add(time.Duration(expiresIn)*time.Second)
261267
}
262268

263269
// ID token is a JWT token. We can decode it to get the expiry.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp