From 3e054e56459671c75d96849db26e6e0e5e61f373 Mon Sep 17 00:00:00 2001 From: Bastien Beuchat Date: Thu, 14 Jul 2022 16:58:33 +0200 Subject: [PATCH] [CLOUDTRUST-4382] Add endpoint for TrustIDAuhtToken(#101) --- api/users.go | 7 +++++++ definitions.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/api/users.go b/api/users.go index a50fc52..374c0d4 100644 --- a/api/users.go +++ b/api/users.go @@ -29,6 +29,7 @@ const ( shadowUser = userIDPath + "/federated-identity/:provider" expiredToUAcceptancePath = adminRootPath + "/expired-tou-acceptance" getSupportInfoPath = adminRootPath + "/support-infos" + generateTrustIDAuthToken = "/auth/realms/:realmReq/trustid-auth-token/realms/:realm/users/:userId/generate" ) // GetUsers returns a list of users, filtered according to the query parameters. @@ -174,3 +175,9 @@ func (c *Client) GetSupportInfo(accessToken string, email string) ([]keycloak.Em err := c.get(accessToken, &emailInfos, url.Path(getSupportInfoPath), url.Param("realmReq", "master"), query.Add("email", email)) return emailInfos, err } + +func (c *Client) GenerateTrustIDAuthToken(accessToken string, reqRealmName string, realmName string, userID string) (string, error) { + var token keycloak.TrustIDAuthTokenRepresentation + err := c.get(accessToken, &token, url.Path(generateTrustIDAuthToken), url.Param("realmReq", reqRealmName), url.Param("realm", realmName), url.Param("userId", userID)) + return *token.Token, err +} diff --git a/definitions.go b/definitions.go index b6c3833..d18c6bf 100644 --- a/definitions.go +++ b/definitions.go @@ -809,3 +809,7 @@ type EmailInfoRepresentation struct { RealmName *string `json:"realm,omitempty"` CreationDate *int64 `json:"creationDate,omitempty"` } + +type TrustIDAuthTokenRepresentation struct { + Token *string `json:"token"` +}