Assigning roles through REST-API

Hi,
I am using REST-API add-on to synchronize data with our other systems and now I need to assign basic role for our users. But there is nothing in JMIX to assign more roles on faster way. So I wanted to assign them through API, but I didnt find any way to edit entity for role assigments.
Is there any way, how can I prepare this function for roles?
Thank you
Paul

Hi,

In order to assign roles programmatically you must create and persist an instance of io.jmix.securitydata.entity.RoleAssignmentEntity, e.g.

RoleAssignmentEntity roleAssignmentEntity = metadata.create(RoleAssignmentEntity.class);
roleAssignmentEntity.setRoleCode(roleCode);
roleAssignmentEntity.setUsername(username);
roleAssignmentEntity.setRoleType(RoleAssignmentRoleType.RESOURCE);

If I misunderstood your question, then please explain in more details.

2 Likes

Hi,

thanks for you informations. This solution is amazing for me in some of our programs but in synchronization program I need to use API.
I have found that we can Update/Create/Delete assign roles through entitiy “sec_RoleAssignmentEntity”.

Thank you for your time and have a nice day :sunny: