Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user group filter endpoint #16087

Merged
merged 5 commits into from
Apr 30, 2024
Merged

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Apr 18, 2024

Prerequisites

  • I have added steps to test this contribution in the description below

Description

This PR adds a filter endpoint for user groups.

Note that the filter only ever returns groups that the current user is a member of, unless the current user is an admin.

Testing this PR

Use Swagger to test the new endpoint:

  1. It should be possible to filter out groups by name using the filter parameter.
  2. If the executing user is an admin, the endpoint returns all user groups that match the filter parameter (all groups if the parameter is empty)
  3. If the executing user is not an admin, the endpoint returns only user groups that the current user is assigned to.

@warrenbuckley
Copy link
Contributor

Nice hopefully saves me doing some juggling to get the current users groups that I am doing currently @kjac 😄

As I do the following in the UI/Javascript to get the current groups

  • Use UMB_CURRENT_USER_CONTEXT and get the Current User Id/Key
  • New up UmbUserDetailRepository and call requestByUnique with the current user Id/key
  • Which returns a collection of GUIDs that are the groups the user is in
  • New up UmbUserGroupItemRepository and call RequestItems with the array from the previous step
  • Returns an array of the groups which include name property

Suggestions

Could this be part of the response of getting the current user at /umbraco/management/api/v1/user as there is an isAdmin and UserGroupIds array of GUIDs

Any plans to add group aliases?
This only returns the names and no longer the group aliases such as admin as opposed to now getting Administrators which can be problematic for some packages that have config that allowed users to control which usergroups had access and was using the same aliases based on the previous convention of specifying permissions in package.manifest or the C# approach of registering dashboards etc...

https://docs.umbraco.com/umbraco-cms/extending/dashboards#specifying-permissions

@kjac kjac marked this pull request as draft April 26, 2024 07:53
@kjac
Copy link
Contributor Author

kjac commented Apr 26, 2024

Hi @warrenbuckley - thanks for chiming in here 👍

We're amending the user group endpoints to handle aliases (it was omitted in the initial implementation by mistake) - see #16154

Once that PR is in, this PR will likewise feature user group aliases in the output 😄

@kjac kjac marked this pull request as ready for review April 30, 2024 09:51
Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good tests good

@Zeegaan Zeegaan merged commit de23033 into v14/dev Apr 30, 2024
15 of 16 checks passed
@Zeegaan Zeegaan deleted the v14/feature/user-group-filter-endpoint branch April 30, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants