securityvue.jskeycloakopenid-connect

Keycloak: Role based client log-in access restriction for users


I am trying to achieve fairly simple usecase of role based client application (VueJS multi-page applications) control using the keycloak.

Client role mapping

As shown in image, I have three different roles and three different clients in single realm.
The arrow in the image represents which role can access which client.

So my main objectives are,

To achieve this usecase I tried following ways,

But, unfortunately none of this works. Meaning my user with Viewer role can log-in to my admin application. Which is just strange.


Solution

  • The solution proposed by @Stuck is a great start, but it has a significant flaw: When the user has already authenticated, e.g. via the standard flow of another client that did not require the role, the password form flow will never be triggered. Consequently, the user will be logged in via the cookie flow without ever checking for the role.

    In other words: If there are other clients (such as the account console) that do not require the role, anyone can bypass the role check.

    To fix this there needs to be an additional flow layer that includes all authentication executions, that is followed by the authorization step (no matter what authentication flow was used). The final result will look like this:

    enter image description here