feat(op): allow setting the actor to Token Requests (#569)
For impersonation token exchange we need to persist the actor throughout token requests, including refresh token. This PR adds the optional TokenActorRequest interface which allows to pass such actor.
This commit is contained in:
parent
9afc07c0cb
commit
4d63d68c9e
1 changed files with 11 additions and 0 deletions
|
@ -121,6 +121,10 @@ func CreateBearerToken(tokenID, subject string, crypto Crypto) (string, error) {
|
|||
return crypto.Encrypt(tokenID + ":" + subject)
|
||||
}
|
||||
|
||||
type TokenActorRequest interface {
|
||||
GetActor() *oidc.ActorClaims
|
||||
}
|
||||
|
||||
func CreateJWT(ctx context.Context, issuer string, tokenRequest TokenRequest, exp time.Time, id string, client AccessTokenClient, storage Storage) (string, error) {
|
||||
ctx, span := tracer.Start(ctx, "CreateJWT")
|
||||
defer span.End()
|
||||
|
@ -150,6 +154,9 @@ func CreateJWT(ctx context.Context, issuer string, tokenRequest TokenRequest, ex
|
|||
}
|
||||
claims.Claims = privateClaims
|
||||
}
|
||||
if actorReq, ok := tokenRequest.(TokenActorRequest); ok {
|
||||
claims.Actor = actorReq.GetActor()
|
||||
}
|
||||
signingKey, err := storage.SigningKey(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -181,6 +188,10 @@ func CreateIDToken(ctx context.Context, issuer string, request IDTokenRequest, v
|
|||
nonce = authRequest.GetNonce()
|
||||
}
|
||||
claims := oidc.NewIDTokenClaims(issuer, request.GetSubject(), request.GetAudience(), exp, request.GetAuthTime(), nonce, acr, request.GetAMR(), request.GetClientID(), client.ClockSkew())
|
||||
if actorReq, ok := request.(TokenActorRequest); ok {
|
||||
claims.Actor = actorReq.GetActor()
|
||||
}
|
||||
|
||||
scopes := client.RestrictAdditionalIdTokenScopes()(request.GetScopes())
|
||||
signingKey, err := storage.SigningKey(ctx)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue