Skip to content

a Keycloak browser authenticator that enforces an impersonation policy restricting impersonators from accessing service providers (clients) unless holding an associated client role

License

Notifications You must be signed in to change notification settings

LucaFilipozzi/keycloak-impersonation-policy-enforcer

license latest tag latest release

build analyze dependabot

lines of code maintainability technical debt

keycloak-impersonation-policy-enforcer

This project provides a Keycloak browser authenticator that enforces an impersonation policy restricting impersonators from accessing service providers (clients) unless holding an associated client role.

usage

deployment

Copy keycloak-impersionation-policy-enforcer-«version».ear to ${KEYCLOAK_HOME}/deployments.

configuration

client configuration

  1. Create an authentication flow as follows (or equivalent):

    auth type requirement
    Impersonation Policy Enforcer ◯ REQUIRED ● ALTERNATE ◯ DISABLED
    Identity Provider Redirector ◯ REQUIRED ● ALTERNATE ◯ DISABLED
    Forms ◯ REQUIRED ● ALTERNATE ◯ DISABLED ◯ CONDITIONAL
    Username Password Form ● REQUIRED
  2. Apply it to a client.

  3. Create a client role that is composed with the realm-management-impersonation role.

policy enforcement

The Impersonation Policy Enforcer authenticator replaces the Cookie authenticator provided by Keycloak. It checks whether the user is being impersonated and, if so, whether the impersonator has any client role that is composed with the realm-management.impersonation role. If both conditions are met, the impersonator is granted access to the client.

Without the client role, the impersonator is denied access to the client.

If the user is not being impersonated, then grant or deny access just as the Cookie authenticator would.

development

project structure

This project follows the module/bundle approach to packaging keycloak extensions:

  • module builds the jar that contains the keycloak extensions

  • bundle builds the ear that contains the jar from module and any jars that are not designated as provided dependencies

coding conventions

This project uses:

  • checkstyle to achieve compliance with the Google Java Style Guide. Please add the checkstyle plugin to your IDE.

  • SonarLint to improve code quality and code security. Please add the SonarLint plugin to your IDE.


Copyright 2021 Luca Filipozzi. Some rights reserved. See LICENSE.

About

a Keycloak browser authenticator that enforces an impersonation policy restricting impersonators from accessing service providers (clients) unless holding an associated client role

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages