Add Roles programmatically

Hi Team,

I’m implementing a new app with Jmix, and need to integrate it with an existing user management system, which requests to check and assign certain roles in the new app when sync users from the user management system.

Could you please guide how to implement this programmatically? AFAIK, there is a table sec_role_assignment, should I insert this table directly or there is some Bean/Service that can help?

Thanks!

Hi,
There is no special API at the moment. So you need to fill and save RoleAssignmentEntity instances manually.

Here is implementation example: https://github.com/Haulmont/jmix-quickstart/blob/security-advanced-complete/src/main/java/com/company/jmixpm/app/RegistrationService.java
(it’s a scenario of user registration and activation).

1 Like

Great! Thank you for the example code.