Browse Source

Use the API extensions to grab users

master
harture 7 years ago
parent
commit
c9126f86c2
  1. 7
      users.go

7
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
}

Loading…
Cancel
Save