Skip to content

Commit

Permalink
Add support for "direct naked impersonation"
Browse files Browse the repository at this point in the history
  • Loading branch information
tomqwpl committed Feb 17, 2024
1 parent fec0d9e commit 04b3c73
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 @@ -580,6 +580,19 @@ func (g *GoCloak) LoginClientTokenExchange(ctx context.Context, clientID, token,
return g.GetToken(ctx, realm, tokenOptions)
}

// Performs "Direct Naked Impersonation"

Check warning on line 583 in client.go

View workflow job for this annotation

GitHub Actions / tests

exported: comment on exported method GoCloak.DirectNakedImpersonationTokenExchange should be of the form "DirectNakedImpersonationTokenExchange ..." (revive)
// 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 04b3c73

Please sign in to comment.