|
|
@ -4,6 +4,7 @@ import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
|
|
|
|
|
|
"gopkg.in/h2non/gentleman.v2/plugins/body" |
|
|
"gopkg.in/h2non/gentleman.v2/plugins/body" |
|
|
|
|
|
"gopkg.in/h2non/gentleman.v2/plugins/headers" |
|
|
"gopkg.in/h2non/gentleman.v2/plugins/url" |
|
|
"gopkg.in/h2non/gentleman.v2/plugins/url" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
@ -22,6 +23,7 @@ const ( |
|
|
getCredentialsForUserPath = usersAdminExtensionApiPath + "/:id/credentials" |
|
|
getCredentialsForUserPath = usersAdminExtensionApiPath + "/:id/credentials" |
|
|
deleteCredentialsForUserPath = getCredentialsForUserPath + "/:credid" |
|
|
deleteCredentialsForUserPath = getCredentialsForUserPath + "/:credid" |
|
|
accountPasswordPath = "/auth/realms/master/api/account/realms/:realm/credentials/password" |
|
|
accountPasswordPath = "/auth/realms/master/api/account/realms/:realm/credentials/password" |
|
|
|
|
|
accountPath = "/auth/realms/master/api/account/realms/:realm/" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// GetUsers returns a list of users, filtered according to the query parameters.
|
|
|
// GetUsers returns a list of users, filtered according to the query parameters.
|
|
|
@ -145,3 +147,16 @@ func (c *Client) UpdatePassword(accessToken, realm, currentPassword, newPassword |
|
|
var m = map[string]string{"currentPassword": currentPassword, "newPassword": newPassword, "confirmation": confirmPassword} |
|
|
var m = map[string]string{"currentPassword": currentPassword, "newPassword": newPassword, "confirmation": confirmPassword} |
|
|
return c.post(accessToken, nil, url.Path(accountPasswordPath), url.Param("realm", realm), body.JSON(m)) |
|
|
return c.post(accessToken, nil, url.Path(accountPasswordPath), url.Param("realm", realm), body.JSON(m)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetAccount provides the user's information
|
|
|
|
|
|
func (c *Client) GetAccount(accessToken string, realm string) (UserRepresentation, error) { |
|
|
|
|
|
var resp = UserRepresentation{} |
|
|
|
|
|
var err = c.get(accessToken, &resp, url.Path(accountPath), url.Param("realm", realm), headers.Set("Accept", "application/json")) |
|
|
|
|
|
return resp, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// UpdateAccount updates the user's information
|
|
|
|
|
|
func (c *Client) UpdateAccount(accessToken string, realm string, user UserRepresentation) error { |
|
|
|
|
|
_, err := c.post(accessToken, nil, url.Path(accountPath), url.Param("realm", realm), body.JSON(user)) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|