From c9126f86c29f702fe4ca695dfd7af2bf2a90a49d Mon Sep 17 00:00:00 2001 From: harture Date: Tue, 23 Apr 2019 16:19:47 +0200 Subject: [PATCH] Use the API extensions to grab users --- users.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/users.go b/users.go index fa0bdae..33d81a1 100644 --- a/users.go +++ b/users.go @@ -9,13 +9,14 @@ import ( const ( userPath = "/auth/admin/realms/:realm/users" + usersAdminExtensionApiPath = "/auth/realms/:realmReq/api/admin/realms/:realm/users" userCountPath = userPath + "/count" userIDPath = userPath + "/:id" userGroupsPath = userIDPath + "/groups" resetPasswordPath = userIDPath + "/reset-password" sendVerifyEmailPath = userIDPath + "/send-verify-email" executeActionsEmailPath = userIDPath + "/execute-actions-email" - getCredentialsForUserPath = "/auth/realms/:realmReq/api/admin/realms/:realm/users/:id/credentials" + getCredentialsForUserPath = usersAdminExtensionApiPath +"/:id/credentials" deleteCredentialsForUserPath = getCredentialsForUserPath + "/:credid" ) @@ -23,13 +24,13 @@ const ( // Parameters: email, first (paging offset, int), firstName, lastName, username, // max (maximum result size, default = 100), // search (string contained in username, firstname, lastname or email) -func (c *Client) GetUsers(accessToken string, realmName string, paramKV ...string) ([]UserRepresentation, error) { +func (c *Client) GetUsers(accessToken string, reqRealmName, targetRealmName string, paramKV ...string) ([]UserRepresentation, error) { if len(paramKV)%2 != 0 { return nil, fmt.Errorf("the number of key/val parameters should be even") } var resp = []UserRepresentation{} - var plugins = append(createQueryPlugins(paramKV...), url.Path(userPath), url.Param("realm", realmName)) + var plugins = append(createQueryPlugins(paramKV...), url.Path(usersAdminExtensionApiPath), url.Param("realmReq", reqRealmName), url.Param("realm", targetRealmName)) var err = c.get(accessToken, &resp, plugins...) return resp, err }