How can i restrict client access to only one group

2019-04-01 21:50发布

问题:

I have a client in keycloak for my awx(ansible tower) webpage. I need only the users from one specific keycloak group to be able to log in through this client.

How can I forbid all other users(except from one particular group) from using this keycloak client?

回答1:

On Keycloak admin console, go to Clients menu, select your client. On the client configuration page, set Authorization Enabled: On, click Save. A new Authorization tab should appear, go to it, then to the Policies tab underneath, click Create Policy and select Group-based policy. There, you can restrict access to specific groups, assuming you have defined your groups via the Groups menu already.



回答2:

Solved: 1.Create a new role in keycloak. 2. Assign this role to the group. 3. Create new authentication script in keycloak. Configure which role is allowed upon login (e.g. user.hasRole(realm.getRole("yourRoleName")) ). 4. In client setting, under "Authentication Flow overrides" choose the created authentication(from step 3).