Search code examples
javaspring-bootwso2wso2-identity-server

How to Register, login, and get user permissions using WSO2 IS with Spring Boot or java


I read all the WSO2 IS documentation to understand how to login, register, and get user permissions through the Restful APIs. Finally, I did the login and registration, but I don't know how to get user permissions, and this is my point!


Solution

  • If you are building an oauth/oidc based application, instead of using separate REST APIs, you can use the permission handler https://github.com/nilasini/CustomPermissionClaimHandler to include user's permissions into the ID token.

    If you want to get a user's permission through a REST API, there is no one single API to get that. The option is,

    1. Get the user's assigned roles by one of the following API based on your usecase
    • https://<host>:<port>/scim2/Users/<user-id>?attributes=roles (This can be invoked by a privileged user to get another user's assigned roles)
    • https://<host>:<port>/scim2/Me?attributes=roles (Loggegin user can get his own roles)
    1. Then per each assigned role, invoke the following API to get the assigned permissions to the role
    • https://<host>:<port>/scim2/Roles/<role-id>?attributes=permissions

    Here is a reference for the mentioned scim REST APIs: https://is.docs.wso2.com/en/latest/apis/scim2-rest-apis/