Skip to content

Commit

Permalink
Add support for "direct naked impersonation" (#465)
Browse files Browse the repository at this point in the history
* Add support for "direct naked impersonation"

* Lint error on comment
  • Loading branch information
tomqwpl authored Nov 5, 2024
1 parent 179ac6a commit 75aae0c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,19 @@ func (g *GoCloak) LoginClientTokenExchange(ctx context.Context, clientID, token,
return g.GetToken(ctx, realm, tokenOptions)
}

// DirectNakedImpersonationTokenExchange performs "Direct Naked Impersonation"
// See: https://www.keycloak.org/docs/latest/securing_apps/index.html#direct-naked-impersonation
func (g *GoCloak) DirectNakedImpersonationTokenExchange(ctx context.Context, clientID, clientSecret, realm, userID string) (*JWT, error) {
tokenOptions := TokenOptions{
ClientID: &clientID,
ClientSecret: &clientSecret,
GrantType: StringP("urn:ietf:params:oauth:grant-type:token-exchange"),
RequestedTokenType: StringP("urn:ietf:params:oauth:token-type:refresh_token"),
RequestedSubject: StringP(userID),
}
return g.GetToken(ctx, realm, tokenOptions)
}

// LoginClientSignedJWT performs a login with client credentials and signed jwt claims
func (g *GoCloak) LoginClientSignedJWT(
ctx context.Context,
Expand Down

0 comments on commit 75aae0c

Please sign in to comment.