fix(op): add scope to access token scope (#664)
This commit is contained in:
parent
8afb8b8d5f
commit
897c720070
7 changed files with 14 additions and 9 deletions
|
@ -230,12 +230,13 @@ func (c *ActorClaims) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
|
||||
type AccessTokenResponse struct {
|
||||
AccessToken string `json:"access_token,omitempty" schema:"access_token,omitempty"`
|
||||
TokenType string `json:"token_type,omitempty" schema:"token_type,omitempty"`
|
||||
RefreshToken string `json:"refresh_token,omitempty" schema:"refresh_token,omitempty"`
|
||||
ExpiresIn uint64 `json:"expires_in,omitempty" schema:"expires_in,omitempty"`
|
||||
IDToken string `json:"id_token,omitempty" schema:"id_token,omitempty"`
|
||||
State string `json:"state,omitempty" schema:"state,omitempty"`
|
||||
AccessToken string `json:"access_token,omitempty" schema:"access_token,omitempty"`
|
||||
TokenType string `json:"token_type,omitempty" schema:"token_type,omitempty"`
|
||||
RefreshToken string `json:"refresh_token,omitempty" schema:"refresh_token,omitempty"`
|
||||
ExpiresIn uint64 `json:"expires_in,omitempty" schema:"expires_in,omitempty"`
|
||||
IDToken string `json:"id_token,omitempty" schema:"id_token,omitempty"`
|
||||
State string `json:"state,omitempty" schema:"state,omitempty"`
|
||||
Scope SpaceDelimitedArray `json:"scope,omitempty" schema:"scope,omitempty"`
|
||||
}
|
||||
|
||||
type JWTProfileAssertionClaims struct {
|
||||
|
|
|
@ -344,6 +344,7 @@ func CreateDeviceTokenResponse(ctx context.Context, tokenRequest TokenRequest, c
|
|||
RefreshToken: refreshToken,
|
||||
TokenType: oidc.BearerToken,
|
||||
ExpiresIn: uint64(validity.Seconds()),
|
||||
Scope: tokenRequest.GetScopes(),
|
||||
}
|
||||
|
||||
// TODO(v4): remove type assertion
|
||||
|
|
|
@ -232,7 +232,7 @@ func TestRoutes(t *testing.T) {
|
|||
"scope": oidc.SpaceDelimitedArray{oidc.ScopeOpenID, oidc.ScopeOfflineAccess}.String(),
|
||||
},
|
||||
wantCode: http.StatusOK,
|
||||
contains: []string{`{"access_token":"`, `","token_type":"Bearer","expires_in":299}`},
|
||||
contains: []string{`{"access_token":"`, `","token_type":"Bearer","expires_in":299,"scope":"openid offline_access"}`},
|
||||
},
|
||||
{
|
||||
// This call will fail. A successful test is already
|
||||
|
|
|
@ -145,7 +145,7 @@ func TestServerRoutes(t *testing.T) {
|
|||
"assertion": jwtProfileToken,
|
||||
},
|
||||
wantCode: http.StatusOK,
|
||||
contains: []string{`{"access_token":`, `"token_type":"Bearer","expires_in":299}`},
|
||||
contains: []string{`{"access_token":`, `"token_type":"Bearer","expires_in":299,"scope":"openid"}`},
|
||||
},
|
||||
{
|
||||
name: "Token exchange",
|
||||
|
@ -174,7 +174,7 @@ func TestServerRoutes(t *testing.T) {
|
|||
"scope": oidc.SpaceDelimitedArray{oidc.ScopeOpenID, oidc.ScopeOfflineAccess}.String(),
|
||||
},
|
||||
wantCode: http.StatusOK,
|
||||
contains: []string{`{"access_token":"`, `","token_type":"Bearer","expires_in":299}`},
|
||||
contains: []string{`{"access_token":"`, `","token_type":"Bearer","expires_in":299,"scope":"openid offline_access"}`},
|
||||
},
|
||||
{
|
||||
// This call will fail. A successful test is already
|
||||
|
|
|
@ -65,6 +65,7 @@ func CreateTokenResponse(ctx context.Context, request IDTokenRequest, client Cli
|
|||
TokenType: oidc.BearerToken,
|
||||
ExpiresIn: exp,
|
||||
State: state,
|
||||
Scope: request.GetScopes(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -120,5 +120,6 @@ func CreateClientCredentialsTokenResponse(ctx context.Context, tokenRequest Toke
|
|||
AccessToken: accessToken,
|
||||
TokenType: oidc.BearerToken,
|
||||
ExpiresIn: uint64(validity.Seconds()),
|
||||
Scope: tokenRequest.GetScopes(),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ func CreateJWTTokenResponse(ctx context.Context, tokenRequest TokenRequest, crea
|
|||
AccessToken: accessToken,
|
||||
TokenType: oidc.BearerToken,
|
||||
ExpiresIn: uint64(validity.Seconds()),
|
||||
Scope: tokenRequest.GetScopes(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue