Rework-Space Rework-Space
  • Services
    • ICT security
    • ICT services
  • Blog
  • Insights
  • About us
    • Contacts
    • Privacy
    • Gender Equality Plan
  • Careers
  • ua

Keycloak Fine-Grained Admin Permissions (FGAP) V2: Fine-Grained Access & Safe Impersonation

Rework-Space Rework-Space
  • ua
  • Services
    • ICT security
    • ICT services
  • Blog
  • Insights
  • About us
    • Contacts
    • Privacy
    • Gender Equality Plan
  • Careers
Rework-Space Rework-Space
  • ua

Keycloak Fine-Grained Admin Permissions (FGAP) V2: Fine-Grained Access & Safe Impersonation


Published #2026-03-27

Tags: Keycloak Terraform DevOps

The problem

Basic Keycloak permissions can be granted via the roles present in system clients. The realm-management client is used in most cases. However, there is a problem: existing permissions cannot be configured to meet your needs and provide too much access. You can make a user to manage all users in the realm or manage no one.

There are two possible scenarios in this case. Only a limited number of developers have access to the realm, which makes them responsible for managing test users. Or, grant access to every developer, allowing them to see your customers' data. Neither of them can be considered enterprise approaches. We wish there was a way to group users and gain access only to the required group. That is exactly what the Fine-Grained Admin Permissions do.

Fine-Grained Permissions

Mentioned Fine-Grained Admin Permissions (FGAP) are based on the Fine-Grained permissions , which appeared in Keycloak 26.2.0. This feature allows moving the user authentication out of the actual program and delegating it to Keycloak itself. Before configuring the admin permissions, let’s consider key components used in both features.

The Resource server is an application that holds the available resources. The Resource is anything you want to protect. It may be the file in object storage, a record from a database, or a basic API endpoint. Each resource may have a set of optional Scopes that defines which actions are allowed to perform on it. The access can be granted depending on the conditions, forced by Policies.

Policies are not attached to the resources directly, instead the Permissions are a glue that combines them. This approach makes the system flexible, allowing you to combine policy with different resources. They can be applied to the scope of the resource itself, granting full control over it.

Picture 1. Global Admin Access vs. Fine-Grained Permissions: Solving the overexposure problem.
Picture 1. Global Admin Access vs. Fine-Grained Permissions: Solving the overexposure problem.

Terraform Configuration

The Fine-Grained permissions feature is fully supported in the official community-driven Terraform Provider v5.7.0 . It allows you to version your configuration and apply it to a new deployment immediately. This combination provides you with functionality similar to the OPA policy agent, making Keycloak more than just an identity manager.

Admin Permissions

Now, when we are familiar with Fine-Grained permissions, let’s take a look at the Fine-Grained Admin Permissions. Obviously, the resource server in this scenario is the Keycloak itself, and it has a set of predefined resources with their scopes: Users, Groups, Clients, and Roles. We can create policies and permissions to manage access on our behalf.

Real example

Let’s consider the real example of an Impersonation feature. Keycloak impersonation grants access to the account without the user’s credentials. It is helpful for testing and reproducing bugs. With basic permissions, it is not possible to limit the pool of users available for impersonation. This can be harmful in production applications.

The best option is to use the FGAP to grant granular access. It requires only two steps. Create a policy to determine: “Who can impersonate?” And create a permission, which allows impersonation to only a limited set of users, the test-users group in our example.

Picture 2. Enabling Fine-Grained Admin Permissions V2 in Keycloak Realm settings.
Picture 2. Enabling Fine-Grained Admin Permissions V2 in Keycloak Realm settings.

Group Policy is used in the example below to allow access only to the users who are members of the dev-group.

Picture 3. Creating a Group Policy to grant access specifically to the 'dev-group' members.
Picture 3. Creating a Group Policy to grant access specifically to the 'dev-group' members.

With the policy created, it’s time to create group permission with the scope impersonate-members.

Picture 4. Setting up the 'impersonate-members' permission.
Picture 4. Setting up the 'impersonate-members' permission.

Now the developers can impersonate only a limited pool of test accounts.

Challenges

Fine-Grained Admin Permissions is a fresh feature that greatly expands the list of Keycloak use cases. Because it is new, the feature has several pitfalls that present new challenges. In this section, we will examine two of them.

Limited Terraform Support

Even though the FGAP feature is based on Fine-Grained Permissions, it implements its own separate API. The separation results badly in the Terraform coverage. Currently, it is only possible to enable the feature with the provider. Permissions and Policies may be created only with UI or API calls. There is an issue related to the problem. However, there is no final date for when the feature will be fully supported.

Bugs

Like any new feature, it may contain bugs that weren’t investigated during the testing stage. For example, Keycloak 26.2.0 has a bug that ignores Fine-Grained Group Permissions during new user creation. It allows adding a new user to a group with limited access.

Let’s consider a bug mentioned in the discussion from the Keycloak repository (FGAP configuration can be found here). The test realm has a group hierarchy displayed in Picture 5. Where users from GroupA have the lowest privileges and aren’t able to add members to the child groups, and perform any changes in user accounts from privileged groups.

Picture 5. Test realm group hierarchy.
Picture 5. Test realm group hierarchy.

After logging in with the GroupA member’s account, who has the least privileges, it is possible to add a new user to GroupC (Picture 6). The action can only be performed during creation requests.

Picture 6. Adding a group during the user creation.
Picture 6. Adding a group during the user creation.

Fortunately, it is not possible to set the password for a new user immediately. After creating the user, a temporary password must be set, or a ‘Reset password’ message must be sent. However, due to the FGAP configuration, the mentioned actions are not allowed for the GroupA member. All requests finish with the 403 error (Picture 7).

Picture 7. Attempting to set the password for a new user.
Picture 7. Attempting to set the password for a new user.

Conclusion

Keycloak Fine-Grained Admin Permissions feature solves a long-standing problem: how to delegate administrative access without overexposing sensitive data. Instead of an all-or-nothing approach with realm roles, permissions can now be scoped to specific resources and actions. This allows safe responsibility delegation while protecting production customer data. With Terraform support, FGAP will soon turn Keycloak into a powerful access-control platform, allowing competition with OPA.

    Contact us
    10 Berezhans'ka St, office 82
    46027, Ternopil, Ukraine
    +38 067 324 6141
    Copyright © Rework-Space, 2026 All rights reserved  |  Privacy
    We would like to use third party code to improve the functionality of this website.