How to list public groups of a user in Gitlab? - api

I want all the public groups of a particular user in gitlab. Is there any API or any other way to achieve it.
https://gitlab.com/api/v4/groups
If I use this API without providing any authentication token, it gives me all the public groups in GITLAB. But my requirement is to get all public groups of a particular user(using user_id).

There is no direct way to list a user's groups.
The closest way to do this would be to list all groups and then use the memberships API to see if the user is in a particular group.

Related

How to verify weather the logged in user is a member of google group to which I am an admin

I have a scenario in my web application where I want to verify the logged in user is a member of the specific google groups. If he is a member of the group I can give some access permissions. How to verify this programatically. I am using google authentication to login to my application and I have a google group with a list of members.
There is a method from the members API which retrieves the members of a specific group, you can use that method to obtain the members of the group and look if the logged user matches any of those members.
I hope you find this useful!

Azure AD does not return groups on claims

I have an application registered on Azure AD. The application has been configured to include groups claim on Token Configuration section on Azure Portal. When I access to the application, follow the process to authenticate against AzureAD, and access to an Controller endpoint, I see that the Claims for the user property does not have the groups. Instead, I'm getting a property, hasgroups, defined with true.
I'm assigned to 89 groups, I don't know if there's any limitation about the number of groups and for that reason Azure change the claims (instead one for each group, it's emitting one with the boolean value I have told you).
This situation happens with an organization tenant. I have test the same with my own tenant on Azure and I'm getting the groups. But in my own tenant I'm assigned only to 2 groups. This is the reason I've highlighted the number of groups i belongs to in my organization.
There is a limitation to how many groups can be returned due to size limitations of tokens.
You must always be ready to query for user groups from MS Graph API, e.g. with:
Get group members: https://learn.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http
Get user groups: https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http
Check group access for user: https://learn.microsoft.com/en-us/graph/api/user-checkmembergroups?view=graph-rest-1.0&tabs=http
If you get the hasgroups claim, you need to query for groups.

List of organizations given an user id or username

I am trying to obtain a list of organizations that belongs an userId or username from the sonarcloud api. The uri I want to expose looks like https:///users/{userId,username}/organizations. Do you have any experience that complains this use case? I have explored almost all the documentation and I didn't find any solution.

Keycloak: user getting its info (id, groups, etc...)

I need a suggestion on how to perform this. I'm using the Keycloak API to perform requests like retrieve users, groups, or other CRUD operations. All these ops can be done with the admin account; what if I would a user, using its own access token, to access only to its own information? Is there a specific endpoint I haven't seen in the documentation or is there a workaround?
Thanks in advance!
By postman:
{{yourKeycloakServer}}/auth/realms/{{yourRealm}}/protocol/openid-connect/userinfo
with accesstoken and POST method.
I don't know about any specific endpoint to see only user's own metadata, but it is possible to create a new user in Master realm and restrict it's access to Admin API.
For example, we can grant to that user only certain roles like View/Manage Users of only one specific Realm. This way we don't need to use server's primary admin account.

Okta Api User Directory

Using the okta API, we're trying to display a simple staff directory. Basically we want to list all active users in a particular group on a web page.
Seems like it should be super simple.
If I use the user endpoint, I can get all users and filter by status to be active, but I can't seem to filter by group.
If I use the group end point, I can get all users in a group, but I can't seem to filter by status.
How should I be going about this?
Edit: Added my api calls
method 1
$filters = 'status eq "ACTIVE"';
$c = curl_init("https://wvuf.okta.com/api/v1/users?filter=".urlencode($filters));
method 2
$c = curl_init("https://wvuf.okta.com/api/v1/groups/xxxxGROUPIDxxxx/users");
Unfortunately, this is not possible in the current version of the Okta API. As you've surmised, you can either GET all users with an ACTIVE status and then iterate through them to get the groups for each user or GET all users for a specific group and manually filter by status.
The latter method may be preferable because it will amount to fewer calls (assuming there are more users than groups).
The List Group members (/api/v1/groups/${groupId}/users) endpoint does not support the filter query param
https://developer.okta.com/docs/reference/api/groups/#group-member-operations
One suggestion is to do some client side filtering (eg using jq etc)
The ListGroupUsers method in the Groups API for Okta enumerates all users that are a member of a specified group.
Have a look at this tool I created for a project I am on, okta-admin, wraps up the Golang SDK for Okta in an easy to use CLI (which effectively invokes REST API requests...)
okta-admin groups listusers $groupId
I have added the ability to pass filter arguments supported by the API or endpoint as well as a jsonquery argument where you can perform searches or projections client side.