Skip to content

Commit

Permalink
Add support for users-management-permissions get/put (Nerzal#463)
Browse files Browse the repository at this point in the history
* Add support for permission_resource_format/permission_resource_matching_uri

* lint error

* Add support for users-management-permissions
  • Loading branch information
tomqwpl authored Feb 1, 2024
1 parent 56fa25b commit fec0d9e
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ func (g *GoCloak) GetRequestingPartyPermissions(ctx context.Context, token, real
if err := checkForError(resp, err, errMessage); err != nil {
return nil, err
}

return &res, nil
}

Expand Down Expand Up @@ -4304,3 +4303,38 @@ func (g *GoCloak) RevokeToken(ctx context.Context, realm, clientID, clientSecret

return checkForError(resp, err, errMessage)
}

// UpdateUsersManagementPermissions updates the management permissions for users
func (g *GoCloak) UpdateUsersManagementPermissions(ctx context.Context, accessToken, realm string, managementPermissions ManagementPermissionRepresentation) (*ManagementPermissionRepresentation, error) {
const errMessage = "could not update users management permissions"

var result ManagementPermissionRepresentation

resp, err := g.GetRequestWithBearerAuth(ctx, accessToken).
SetResult(&result).
SetBody(managementPermissions).
Put(g.getAdminRealmURL(realm, "users-management-permissions"))

if err := checkForError(resp, err, errMessage); err != nil {
return nil, err
}

return &result, nil
}

// GetUsersManagementPermissions returns the management permissions for users
func (g *GoCloak) GetUsersManagementPermissions(ctx context.Context, accessToken, realm string) (*ManagementPermissionRepresentation, error) {
const errMessage = "could not get users management permissions"

var result ManagementPermissionRepresentation

resp, err := g.GetRequestWithBearerAuth(ctx, accessToken).
SetResult(&result).
Get(g.getAdminRealmURL(realm, "users-management-permissions"))

if err := checkForError(resp, err, errMessage); err != nil {
return nil, err
}

return &result, nil
}

0 comments on commit fec0d9e

Please sign in to comment.