@ -149,9 +149,8 @@ func newAccessTokenResponse(grant *auth.OAuth2Grant, serverKey, clientKey oauth2
accessToken := & oauth2 . Token {
accessToken := & oauth2 . Token {
GrantID : grant . ID ,
GrantID : grant . ID ,
Type : oauth2 . TypeAccessToken ,
Type : oauth2 . TypeAccessToken ,
// FIXME: Migrate to RegisteredClaims
RegisteredClaims : jwt . RegisteredClaims {
StandardClaims : jwt . StandardClaims { //nolint
ExpiresAt : jwt . NewNumericDate ( expirationDate . AsTime ( ) ) ,
ExpiresAt : expirationDate . AsTime ( ) . Unix ( ) ,
} ,
} ,
}
}
signedAccessToken , err := accessToken . SignToken ( serverKey )
signedAccessToken , err := accessToken . SignToken ( serverKey )
@ -163,14 +162,13 @@ func newAccessTokenResponse(grant *auth.OAuth2Grant, serverKey, clientKey oauth2
}
}
// generate refresh token to request an access token after it expired later
// generate refresh token to request an access token after it expired later
refreshExpirationDate := timeutil . TimeStampNow ( ) . Add ( setting . OAuth2 . RefreshTokenExpirationTime * 60 * 60 ) . AsTime ( ) . Unix ( )
refreshExpirationDate := timeutil . TimeStampNow ( ) . Add ( setting . OAuth2 . RefreshTokenExpirationTime * 60 * 60 ) . AsTime ( )
refreshToken := & oauth2 . Token {
refreshToken := & oauth2 . Token {
GrantID : grant . ID ,
GrantID : grant . ID ,
Counter : grant . Counter ,
Counter : grant . Counter ,
Type : oauth2 . TypeRefreshToken ,
Type : oauth2 . TypeRefreshToken ,
// FIXME: Migrate to RegisteredClaims
RegisteredClaims : jwt . RegisteredClaims { // nolint
StandardClaims : jwt . StandardClaims { // nolint
ExpiresAt : jwt . NewNumericDate ( refreshExpirationDate ) ,
ExpiresAt : refreshExpirationDate ,
} ,
} ,
}
}
signedRefreshToken , err := refreshToken . SignToken ( serverKey )
signedRefreshToken , err := refreshToken . SignToken ( serverKey )
@ -207,11 +205,10 @@ func newAccessTokenResponse(grant *auth.OAuth2Grant, serverKey, clientKey oauth2
}
}
idToken := & oauth2 . OIDCToken {
idToken := & oauth2 . OIDCToken {
// FIXME: migrate to RegisteredClaims
RegisteredClaims : jwt . RegisteredClaims {
StandardClaims : jwt . StandardClaims { //nolint
ExpiresAt : jwt . NewNumericDate ( expirationDate . AsTime ( ) ) ,
ExpiresAt : expirationDate . AsTime ( ) . Unix ( ) ,
Issuer : setting . AppURL ,
Issuer : setting . AppURL ,
Audience : app . ClientID ,
Audience : [ ] string { app . ClientID } ,
Subject : fmt . Sprint ( grant . UserID ) ,
Subject : fmt . Sprint ( grant . UserID ) ,
} ,
} ,
Nonce : grant . Nonce ,
Nonce : grant . Nonce ,
@ -329,8 +326,7 @@ func IntrospectOAuth(ctx *context.Context) {
var response struct {
var response struct {
Active bool ` json:"active" `
Active bool ` json:"active" `
Scope string ` json:"scope,omitempty" `
Scope string ` json:"scope,omitempty" `
// FIXME: Migrate to RegisteredClaims
jwt . RegisteredClaims
jwt . StandardClaims //nolint
}
}
form := web . GetForm ( ctx ) . ( * forms . IntrospectTokenForm )
form := web . GetForm ( ctx ) . ( * forms . IntrospectTokenForm )
@ -344,7 +340,7 @@ func IntrospectOAuth(ctx *context.Context) {
response . Active = true
response . Active = true
response . Scope = grant . Scope
response . Scope = grant . Scope
response . Issuer = setting . AppURL
response . Issuer = setting . AppURL
response . Audience = app . ClientID
response . Audience = [ ] string { app . ClientID }
response . Subject = fmt . Sprint ( grant . UserID )
response . Subject = fmt . Sprint ( grant . UserID )
}
}
}
}