Get list of roles for all clients in keycloak - keycloak

I'm working on an application that authentication and authorization are handling with Keyclock.
So we have a scenario that we should list all of the roles from our client, realm-management and realm roles, for assiging to a specific user.
We need realm-management roles for assign view-user, query-user to a spesific user,to able query or view user list from the Keycloak.
I know we can get a client roles by following API:
GET KEYCLOACK_BASE_URL + "/admin/realms/" + REALM + "/clients/{clientId}/roles"
But if we want to get all roles we should call above API for three times.
First: GET KEYCLOACK_BASE_URL + "/admin/realms/" + REALM + "/clients/ABC_id/roles"
Second: GET KEYCLOACK_BASE_URL + "/admin/realms/" + REALM + "/clients/realm-management_id/roles"
Third: GET KEYCLOACK_BASE_URL + "/admin/realms/" + REALM + "/roles"
Is there a better solution for get all the roles from multiple clients only with an API.
Or What is the best practice in the same situation.
Any help?

Related

Security on GET with query params

I have a dilemma. What do you return for a GET REST request where a user doesn't have the right to use a certain query param.
For example : GET /transactions?user=admin
If an user, that is not the admin tries the following example, what should be the proper response 403 or an empty list?
He has the right to search for any other user, but not the user admin.

How to make transactions on multiple data tables in Firebase?

I've an application, which uses Firebase. I have a new post adding. And when I make it, I do a number of operations in database, like:
Add new post info to Posts node
Add Id of the new post to Users node
Upload media to storage
etc.
So, for example, user can close application on step 2. How can I reset data on start of adding new post?
If I've understood correctly, Firebase transactions work on only one data table.
Main question is: how to make transactions on multiple data tables and storage in Firebase?
I believe you're looking for something like this: https://firebase.google.com/docs/database/web/read-and-write#update_specific_fields. It allows you to run multiple updates all at once to wherever you need. Here is a snapshot of the code:
var updates = {};
updates['/posts/' + newPostKey] = ...;
updates['/user-posts/' + uid + '/' + newPostKey] = ...;
return firebase.database().ref().update(updates);

Filter/query list of users that not being blocked

I have a list off users in the app, I show that users list in an tableview, now I want to query that list of users to show only the users that have not being blocked by me as an user... So my database structure I'm thinking of is something like this;
users
usersid-987545
name: String
description: String
blocked
userid-767438: true
usersid-767438
name: String
description: String
But this is a problem when I want to query list of users or later to search for a user with name and exclude a blocked user by that user... Whats a more scalable structure? Can you query a list of users and filter out the blocked users by that user?
try to nest your data
DATABASE / Users / USERIDS / personal data
DATABASE / BLOCKS / USERID / blocked users
DATABASE / FRIENDS / USERID / listed friends
then
get the list of peeople blocked under the uid you are looking for (yours for example)
then
get all the friends
get all the blocked users
compare and exclude
Another solution would be to remove the blocked user from the friends list or to make a separate DATABASE / AUTHORIZED / USERID/ list of authorized people
Structuring data is really important and makes firebase so powerfull.

Alfresco filter people by creator name

I want to modify the webscript alfresco-remote-api-5.0.d.jar\alfresco\templates\webscripts\org\alfresco\repository\person\people.get.js. I need to display for the connected user only user he has created.
I have modify the filter to include username in query.
filter = filter + " AND cm:creator:admin";
people.getPeoplePaging(filter, paging, sortBy, sortAsc);
This must display only users created by admin.
But it's not working(no user is returned).
How can i select only users created by a certain user ?
By looking at below definition of content model I sure , what you want to achieve is not possible ,as person(user) does not have creator property.Below link shows the content model for users.
https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/COMMUNITYTAGS/V4.2c/root/projects/repository/config/alfresco/model/contentModel.xml
https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/COMMUNITYTAGS/V4.2c/root/projects/repository/config/alfresco/model/systemModel.xml

How to get group info of a user

I get a user's JID,i want to get the group info that the user has joined by user JID.
Can someone help me ?Please.
Depending on which storage type you are using in there (CoreData/Memory) - the 'groups' field on the user (XMPPUserCoreDataStorageObject) is a 1:m relation to the groups (XMPPGroupCoreDataStorageObject) of that user, and each group also has a 1:m relation to users (group.users).
So you should be able to get the user object via the jid of that user ([xmppRosterStorage userForJID:jid ...]), and from there, get the groups (user.groups).