What Is a Policy in Keycloak?

What Is a Policy in Keycloak?

The complete, in-depth guide to the reusable rule that decides who gets to do what, inside Keycloak's fine-grained Authorization Services.

Picture a large office building’s insurance policy — the actual paper document, not the everyday word. It doesn’t describe one single door or one single employee; it describes a general rule: “claims are covered if the incident happened during business hours, on the premises, and the claimant was an active employee at the time.” That one written rule then gets applied, unchanged, across every single claim the building ever files — different doors, different employees, different incidents, but always checked against that same underlying rule. Earlier guides in this series covered Roles as labels a user carries, and Realm-level authorization decisions an application makes on its own using those labels. This guide goes one level deeper, into Keycloak’s own built-in engine for expressing exactly these kinds of reusable rules formally, so that an application doesn’t have to hand-code its own scattered permission checks at all. In Keycloak’s own terminology, that reusable, named rule is called a Policy.

This guide is a comprehensive, ground-up exploration of Policies specifically: what a Policy actually is inside Keycloak’s Authorization Services, how it differs from a Role or a plain permission check, every built-in Policy type Keycloak ships with, how Policies combine with Resources and Scopes to become enforceable Permissions, and the real-world patterns and mistakes that come up when organizations build genuinely fine-grained authorization on top of Keycloak. No prior identity or security background is assumed — every term is explained in full the moment it first appears.

1Core Concepts

Before touching any specific Policy type, we need a precise, unambiguous definition of what a Policy actually is, and where it lives inside Keycloak’s broader feature set.

What Is a Policy?

A Policy is a named, reusable rule, configured inside Keycloak’s Authorization Services feature, that evaluates to either “satisfied” or “not satisfied” for a given user and request. On its own, a Policy doesn’t grant or deny anything — it’s purely a rule waiting to be attached to something it should actually govern, which is the job of a Permission, covered fully in Chapter 10.

i
A Policy Is Not a Role, Even Though It Can Use One

This is the single most important distinction to internalize early. A Role, covered elsewhere in this series, is a label attached to a user. A Policy is a rule — and one of the built-in Policy types happens to check whether a user carries a specific Role, but a Policy can just as easily check something entirely different, like the time of day or a specific Group membership, with no Role involved anywhere in it. A Policy is the broader, more general concept; a Role Policy is just one specific instance of it.

Where Authorization Services Fits Into This Series

Everything covered so far in this series about Roles has assumed an application reads a user’s Roles out of a token and makes its own decision in its own code — “if the token contains the admin Role, allow this action.” Keycloak’s Authorization Services feature offers an alternative: instead of that decision living scattered inside application code, it lives centrally inside Keycloak itself, expressed as Policies, and the application simply asks Keycloak “is this specific action, on this specific thing, allowed for this specific user right now?” and gets back a straightforward answer.

Everyday Analogy

Return to the insurance policy from the opening. The written rule itself — “covered if during business hours, on premises, employee was active” — is the Policy. It says nothing yet about which specific door, which specific claim form, or which specific department it applies to. Attaching that same rule to “the north entrance’s incident reports” is a separate, deliberate step — exactly the role a Permission plays in Keycloak’s model, joining a Policy to something concrete it should actually govern.

Why Centralize Authorization Logic This Way?

Scattering permission checks across dozens of individual applications’ own code creates real problems at scale: inconsistent enforcement between applications, no single place to audit “who can actually do what,” and a genuine engineering cost every time a rule needs to change across many codebases at once. Centralizing the rules as Policies inside Keycloak means one update, made in one place, can immediately apply everywhere that Policy is actually used — a benefit that compounds as an organization’s number of protected resources and applications grows.

2Architecture & Components

A Policy doesn’t operate in isolation — it’s one piece of a small, interconnected model Keycloak calls Authorization Services. Let’s map the whole picture before going deeper into Policies themselves.
graph TD
    RS["Resource Server
(a Client with Authorization enabled)"] RS --> Res["Resource
(e.g. 'Invoice #4471')"] RS --> Scope["Scope
(e.g. 'view', 'approve')"] RS --> Pol["Policy
(e.g. 'Only Finance Role')"] Res --> Perm["Permission
(joins Resource + Scope + Policy)"] Scope --> Perm Pol --> Perm App["Application"] -->|"Asks: can this user
'approve' this Resource?"| RS RS -->|"Evaluates matching Permission
and its attached Policies"| Perm Perm -->|"Returns"| Decision["Permit / Deny"]
Fig 2.1 — The full Authorization Services model: Resources and Scopes describe what’s being protected, Policies describe the rule, Permissions tie them together
Container

Resource Server

A Client with Authorization Services enabled — the application acting as the thing actually being protected and queried for decisions.

What

Resource

A specific thing being protected — a document, an API endpoint, a database record — registered so Policies can be applied to it.

How

Scope

A specific action that can be taken on a Resource, like “view,” “edit,” or “approve” — mirroring the “action” concept introduced earlier in this series’ authorization guide.

Rule

Policy

The reusable, named rule this entire guide focuses on — evaluates to satisfied or not satisfied for a given request.

Binding

Permission

The object that actually joins a Resource (and/or Scope) to one or more Policies, making the rule enforceable — covered fully in Chapter 10.

3The Built-In Policy Types

Keycloak ships with a defined menu of Policy types, each checking a different kind of fact, covering the overwhelming majority of real-world authorization needs.
Policy TypeWhat It Checks
Role PolicyWhether the user holds a specified Realm Role or Client Role
User PolicyWhether the requester is one of a specifically named set of individual users
Group PolicyWhether the user belongs to a specified Group
Client PolicyWhether the request is coming from a specified Client, useful for machine-to-machine authorization decisions
Time PolicyWhether the current request falls within a specified date range, time window, or day-of-week schedule
Aggregated PolicyCombines two or more other Policies using logical rules, covered fully in Chapter 8
JS/Rule-Based PolicyRuns custom logic written by a developer, for checks no built-in type can express
i
Every Policy Also Has a Logic Setting

Beyond its specific type, every Policy also carries a simple “Positive” or “Negative” logic setting, which inverts its result. A Role Policy set to Negative logic, for instance, is satisfied precisely when the user does not hold the specified Role — a small but genuinely useful building block, especially when combined with other Policies in Chapter 8.

4Internal Working: How a Policy Is Actually Evaluated

Let’s trace exactly what happens, step by step, when an application asks Keycloak’s Authorization Services whether a specific action should be allowed.
1

Application Sends an Authorization Request

Instead of deciding on its own, the application asks Keycloak’s Resource Server endpoint a specific question: can this particular user perform this particular Scope on this particular Resource?

2

Matching Permission Located

Keycloak finds the Permission (or Permissions) associated with the requested Resource and Scope, as configured by an administrator ahead of time.

3

Attached Policies Evaluated

Every Policy attached to that Permission is evaluated against the current request — checking the user’s Roles, Group membership, the current time, or whatever else each specific attached Policy examines.

4

Results Combined per the Permission’s Own Logic

If more than one Policy is attached to the same Permission, Keycloak combines their individual results according to a configurable rule (commonly “all must be satisfied,” though this is adjustable) to reach one overall verdict for that Permission.

5

Decision Returned

Keycloak returns a straightforward Permit or Deny back to the requesting application, which then simply acts on that answer rather than having computed any of the underlying logic itself.

!
The Application Never Sees the Policy Logic

This is a deliberate and important architectural property: the requesting application only ever sees the final Permit/Deny answer, never the underlying Policies or their internal logic. This keeps the actual authorization rules centralized and consistently enforced inside Keycloak, rather than duplicated or reinterpreted differently by every individual application that happens to call it.

5Policy Deep Dive: Role Policy

The most commonly used Policy type, and the natural bridge between the Role concepts covered earlier in this series and Keycloak’s formal Authorization Services model.

How It Works

A Role Policy is satisfied when the requesting user holds a specified Realm Role or Client Role. It can also be configured to require the Role only when a specific condition applies, and multiple Roles can be listed within a single Role Policy, with a setting controlling whether the user must hold all of them or just one.

Production Example: Document Approval Restricted by Role

A document-management application registers each sensitive document as a Resource, defines an “approve” Scope, and creates a Permission joining that Scope to a Role Policy requiring the “department-head” Realm Role. Rather than the application’s own code checking token claims directly, it simply asks Keycloak’s Authorization Services “can this user approve this document?” and receives a clean answer, with the underlying Role requirement fully centralized and auditable inside Keycloak’s own configuration.

Role Policy vs. an Application Reading Roles From the Token Directly

It’s worth being explicit about what’s actually gained here, since a Role Policy can seem, at first glance, to simply duplicate a check an application could make itself by reading its token’s Role claims directly. The real difference emerges at scale and over time: a Role Policy lives in one place, is reviewable by a security team without reading application source code, and can be combined with other Policy types (Chapter 8) without any application code changes — advantages that become increasingly valuable as the number of protected Resources and the sophistication of the rules involved both grow.

6Policy Deep Dive: User and Group Policy

Two related Policy types for when the relevant distinction isn’t naturally expressed as a Role at all.

User Policy

A User Policy is satisfied only for a specifically named, finite list of individual users. This is a narrower, more explicit tool than a Role Policy, appropriate when an authorization rule genuinely applies to particular named people rather than a broader category of user.

Production Example: Named Approvers for an Exceptional Process

An organization handling an unusual, high-value contract exception might restrict approval specifically to two named senior executives, using a User Policy listing exactly those two accounts, rather than inventing a brand-new Role that would only ever apply to these two people for this one narrow process.

Group Policy

A Group Policy is satisfied when the user belongs to a specified Group, covered elsewhere in this series as the common mechanism for bulk Role assignment. Using a Group Policy directly, rather than a Role Policy checking a Role that Group happens to carry, can sometimes better reflect an organization’s actual intent when the distinction is fundamentally about organizational structure (which team someone is on) rather than a formally defined permission label.

i
Choosing Between Role, User, and Group Policies

As a general rule: reach for a Role Policy when the distinction is a formally meaningful, reusable category across the organization; reach for a Group Policy when the distinction tracks actual organizational structure (a team, a department); and reach for a User Policy only for genuinely narrow, named-individual exceptions that don’t warrant inventing a new Role or Group just for this one purpose.

7Policy Deep Dive: Time Policy

A Policy type that checks a fact about the moment of the request itself, rather than anything about the requesting user.

How It Works

A Time Policy is satisfied only when the current request falls within a configured window — a specific date range (useful for a temporary, time-boxed grant), a repeating time-of-day window, or specific days of the week. Unlike every Policy type covered so far, a Time Policy’s outcome has nothing to do with who is asking; it depends entirely on when they’re asking.

Production Example: Restricting Sensitive Batch Operations to Off-Peak Hours

A financial system running a sensitive bulk data-export operation might combine a Role Policy (restricting the operation to the “data-operations” Role) with a Time Policy (permitting the action only during a designated overnight maintenance window), ensuring the operation never runs during business hours regardless of who happens to be authorized to trigger it in principle.

Time Policies and Temporary Access Grants

A Time Policy configured with a specific start and end date is a clean way to implement genuinely temporary access — a contractor’s project-based permission, an emergency “break-glass” grant issued during an incident — that automatically stops being satisfied once the window closes, without requiring an administrator to remember to manually revoke it later.

8Policy Deep Dive: Aggregated Policy

The mechanism for combining several individual Policies into one larger, more sophisticated rule, without needing custom code.

How It Works

An Aggregated Policy doesn’t check any fact on its own — instead, it references two or more other, already-defined Policies, and combines their individual results using a configurable rule, commonly requiring that all referenced Policies be satisfied (“unanimous”) or that at least one be satisfied (“affirmative”), among other available combination strategies.

Everyday Analogy

An Aggregated Policy is like a loan approval requiring sign-off from both the branch manager and the risk department — neither individual approval alone is sufficient, but the combination, evaluated together as one unified rule, produces the actual approval decision. Each underlying approver’s own criteria (the individual Policies) stays defined and reusable on its own, while the Aggregated Policy expresses how they must combine for this particular purpose.

Production Example: Combining a Role Requirement With a Time Window

Building directly on the Chapter 7 example, an Aggregated Policy combining the “data-operations” Role Policy with the overnight Time Policy, using “unanimous” logic, produces exactly the combined rule described there — both conditions must hold simultaneously — while keeping each individual Policy independently defined, documented, and reusable elsewhere for entirely different purposes.

Why Aggregation Is Preferable to Duplicating Logic

Without Aggregated Policies, achieving the same combined effect would require either building one large, bespoke custom rule from scratch for every new combination needed, or accepting looser, less precise enforcement. Aggregation lets an organization build a small library of focused, well-understood individual Policies, then combine them in different ways for different purposes — much like the composite Role pattern covered elsewhere in this series, applied here to rules rather than permission labels themselves.

9Policy Deep Dive: JS/Rule-Based Policy

The extension point for when none of the built-in Policy types can express a genuinely custom organizational rule.

How It Works

A JS/Rule-Based Policy runs custom logic, written by a developer, that receives details about the current request (the user, the Resource, the Scope, and other available context) and returns a satisfied or not-satisfied result based on whatever bespoke reasoning the organization needs — a proprietary risk score, an external system lookup, or any check too specific to be covered by a built-in type.

Production Example: External Risk-Score Integration

An organization wanting to deny a sensitive financial action whenever a user’s real-time fraud-risk score (computed by a separate internal system) exceeds a defined threshold can implement this entirely as a custom Policy, querying that external system as part of its evaluation logic — a check with no equivalent among Keycloak’s built-in Policy types.

!
Reach for This Last, Not First

Because a custom Policy is genuinely running code rather than simple configuration, it deserves the same engineering rigor — testing, code review, monitoring — as any other security-critical software, and it carries real upgrade-compatibility considerations similar to the custom authenticators covered elsewhere in this series. It’s the right tool when a genuinely custom check is needed, and the wrong tool when the same outcome could be achieved by combining built-in Policy types through Aggregation instead.

10From Policies to Permissions: How They Actually Combine

A Policy alone accomplishes nothing until it’s actually attached to something — this is the job of a Permission, the final piece of the puzzle.

What a Permission Does

A Permission joins one or more Policies to a specific Resource, a specific Scope, or both, making the rule they express actually enforceable. Two main Permission types exist: a Resource-based Permission (governing any and all Scopes on a given Resource) and a Scope-based Permission (governing one specific action, potentially across multiple Resources).

Broad

Resource-Based Permission

Attaches Policies to an entire Resource, governing every action that might be taken on it.

Narrow

Scope-Based Permission

Attaches Policies to one specific action (Scope), letting different actions on the same Resource carry entirely different rules.

Production Example: Different Rules for Viewing vs. Approving

A single invoice Resource might have a Scope-based Permission on its “view” Scope requiring only the broad “employee” Role Policy, while a separate Scope-based Permission on its “approve” Scope requires the much narrower “finance-approver” Role Policy — two entirely different rules governing two different actions on the exact same underlying Resource.

Reading the Full Picture Together

Putting the whole model together: a Resource describes what, a Scope describes which action, a Policy describes the rule, and a Permission is what actually wires the rule to the thing it governs. An application never needs to understand any of these individually — it simply asks its one authorization question and receives one clean answer, with every layer of this structure working together invisibly behind that single request.

11Data Flow & Lifecycle

A Policy moves through its own lifecycle, closely tied to the broader Resources and Permissions it eventually supports.

Design. An administrator or security architect identifies a genuine, reusable rule worth formalizing — often recognizing the same underlying condition would otherwise be duplicated across several different Permissions.

Creation. The Policy is created inside the relevant Resource Server, choosing the appropriate built-in type (or Aggregating several existing ones, or writing custom logic as a last resort).

Attachment. The Policy is attached to one or more Permissions, each joining it to specific Resources or Scopes it should actually govern.

Active Use. Every authorization request touching an attached Permission now evaluates this Policy as part of reaching its overall decision.

Reuse. Because Policies are independent, named objects, the very same Policy can be attached to many different Permissions across many different Resources, without being redefined each time.

Retirement. When a rule is no longer needed, the Policy can be detached from its Permissions and removed, though this deserves the same careful review as removing any other access control, to confirm nothing still depends on it unexpectedly.

graph LR
    A["Reusable Rule Identified"] --> B["Policy Created
(built-in type, aggregated, or custom)"] B --> C["Attached to One or More
Permissions"] C --> D["Evaluated on Every
Matching Authorization Request"] D --> E{"Rule No Longer Needed?"} E -->|"Yes"| F["Detached and Retired"] E -->|"No"| G["Reused Across Additional
Permissions Over Time"]
Fig 11.1 — The lifecycle of a Policy, from initial design through ongoing reuse across many Permissions

12Advantages, Disadvantages & Trade-offs

Formalizing authorization logic as Policies is powerful, but it introduces its own genuine costs worth weighing honestly.

Advantages

  • Centralizes authorization rules in one auditable place, rather than scattered across many applications’ own source code
  • Reusable Policies mean a single rule change can propagate instantly to every Permission that references it
  • Aggregated Policies allow sophisticated combined logic without writing custom code
  • Cleanly separates “what is the rule” (Policy) from “what does it apply to” (Permission), letting each evolve somewhat independently

Disadvantages & Trade-offs

  • Adds genuine architectural complexity compared to a simple in-application Role check, appropriate mainly once authorization needs grow sophisticated enough to justify it
  • Requires the application to make an extra round-trip request to Keycloak’s Authorization Services for every decision, rather than deciding locally from an already-issued token
  • A tangle of many overlapping Policies and Permissions can become as hard to audit as scattered application code, if not managed with the same discipline recommended elsewhere in this series for Roles and flows
  • Custom JS/Rule-Based Policies carry the same software-engineering and upgrade-compatibility burden as any other custom code extension

13Security

Because Policies frequently gate genuinely sensitive actions, getting their configuration wrong carries direct security consequences.
ADR-013: Misjudging How Multiple Policies Combine on One Permission Anti-pattern Warning
Problem

An administrator attaches both a Role Policy and a Time Policy to the same Permission, intending both to be required together, but the Permission’s own combination setting is actually configured as “affirmative” (any one Policy satisfied is enough) rather than “unanimous” (all must be satisfied).

Why It Fails

A user holding the required Role can now perform the action at any time, completely bypassing the intended time restriction, because satisfying just one of the two attached Policies was sufficient under the actual configured combination logic — the opposite of what was intended.

Correct Approach

Always verify a Permission’s combination logic explicitly rather than assuming a default, and test the actual resulting behavior with real accounts under both the intended-pass and intended-fail conditions, exactly as recommended for Conditional Flows elsewhere in this series.

Negative Logic Deserves Careful Review

Because any Policy can be inverted with Negative logic, a reviewer auditing a Permission’s attached Policies should always check each one’s logic setting individually, rather than assuming a Policy’s name alone describes its actual effect — a Role Policy named “finance-approver” set to Negative logic is actually satisfied by everyone except finance approvers, the opposite of what its name might suggest at a glance.

Custom Policy Code Is a Security-Critical Surface

A JS/Rule-Based Policy runs directly inside the authorization decision path for every request it’s attached to, meaning a bug here can either wrongly deny legitimate access or, more seriously, be tricked into approving an action it shouldn’t. This code deserves the same review rigor as the custom authenticators discussed elsewhere in this series.

Fail-Closed Versus Fail-Open Behavior

Any custom Policy that calls out to an external system — the fraud-risk example from Chapter 9 is a good illustration — has to make an explicit decision about what happens when that external call itself fails or times out. A Policy that silently defaults to “satisfied” whenever its external dependency is unreachable is said to fail open, and this is almost never the right default for a security-relevant rule, since an outage in an unrelated system would quietly widen access rather than narrow it. The safer default, failing closed, treats an unreachable dependency as “not satisfied,” at the cost of occasionally denying a legitimate action during an outage — a trade-off worth making deliberately and documenting clearly, rather than leaving to whatever a custom Policy’s error-handling code happens to do by accident.

Least Privilege Applies to Policy Design Itself

The same least-privilege thinking that governs Role design elsewhere in this series applies just as directly to Policies: a Policy should check the narrowest fact that actually captures the intended rule, rather than a broader one that happens to produce the right answer today but would silently over-grant access the moment circumstances change. A Group Policy checking membership in a broad “all-staff” Group, used as a stand-in for a much narrower intended audience, is a common example of this drift, and it’s exactly the kind of gap a periodic Policy and Permission review, discussed in Chapter 14, is meant to catch.

14Monitoring, Logging & Metrics

Because Policies sit directly inside the decision path for every protected action, their real-world behavior deserves dedicated, ongoing observability.
Coverage

Per-Permission Decision Volume

Tracking how many Permit versus Deny decisions a given Permission produces over time reveals whether its attached Policies are behaving as expected for the population actually using it.

Audit

Policy Configuration Changes

Logging every edit to a Policy’s configuration — which Role it checks, its combination logic, its logic setting — supports later review of exactly when and how an authorization rule’s real effect changed.

Reliability

Authorization Request Latency

Because each protected action now involves a round-trip request to Keycloak’s Authorization Services, monitoring this latency specifically helps catch a performance issue before it noticeably slows down protected applications.

Reuse Tracking

Policy Usage Across Permissions

Tracking how many Permissions reference each Policy helps identify both heavily relied-upon rules deserving extra review care, and unused, orphaned Policies that may be safe to retire.

15Design Patterns & Anti-patterns

A handful of consistent habits keep a Policy-based authorization model powerful without becoming an unmanageable tangle.

Good Patterns

  • Build a small library of focused, single-purpose Policies: combine them through Aggregation for specific needs, rather than creating many near-duplicate Policies
  • Prefer built-in types over custom code: reach for a JS/Rule-Based Policy only once Aggregating existing built-in types genuinely can’t express the needed rule
  • Verify combination logic explicitly: never assume how multiple Policies on one Permission combine — check and test it directly
  • Name Policies for what they check, and note their logic setting clearly, so a Negative-logic Policy’s actual effect is obvious without needing to open its configuration

Anti-patterns to Avoid

Common Mistakes

  • Misconfiguring a Permission’s combination logic and assuming multiple attached Policies are all required when they aren’t, as covered in Chapter 13
  • Creating many overlapping, inconsistently named Policies that duplicate the same underlying rule in slightly different forms
  • Reaching for a custom JS/Rule-Based Policy before checking whether Aggregating existing built-in Policies could achieve the same result
  • Leaving orphaned Policies attached to no Permissions cluttering the configuration indefinitely

16Real-World & Industry Examples

Policy-based authorization is the quiet engine behind genuinely fine-grained access control in a wide range of real deployments.

Document Management Platforms

A corporate document platform commonly registers each folder or document as a Resource, defines Scopes like “view,” “edit,” and “share,” and attaches different Role and Group Policies to each Scope, letting a single document carry genuinely different rules for who can merely read it versus who can share it further.

Healthcare Record Systems

A hospital records system frequently combines a Role Policy (“clinician”) with a Time Policy (restricting access to a patient’s record outside an active care relationship’s known window) through Aggregation, formalizing a nuanced rule that would be difficult and error-prone to hand-code consistently across every application touching patient records.

Multi-Tenant SaaS Platforms

A business software platform serving many separate customer organizations often uses Group Policies aligned to each customer’s own internal team structure, letting fine-grained, per-resource permissions be managed consistently across the platform without each customer needing separate custom-built authorization logic.

Financial Services with Break-Glass Access

A bank’s internal operations platform might combine a User Policy naming specific incident responders with a Time Policy limiting the grant to a short emergency window, formalizing a genuinely temporary “break-glass” access pattern entirely through Policy configuration, with the access automatically expiring once the time window closes.

17Frequently Asked Questions

Q1Is a Policy the same thing as a Role?
No — a Role is a label attached to a user. A Policy is a reusable rule, and one built-in Policy type happens to check whether a user holds a specific Role, but a Policy can check many other kinds of facts entirely unrelated to Roles.
Q2Does a Policy do anything on its own?
No — a Policy only becomes enforceable once it’s attached to a Resource or Scope through a Permission. On its own, a Policy is simply a defined, reusable rule waiting to be used.
Q3What’s the difference between a Role Policy, a User Policy, and a Group Policy?
A Role Policy checks a formally defined Role; a Group Policy checks membership in a specific Group, typically reflecting organizational structure; a User Policy names specific individual users directly, appropriate only for narrow, genuinely named exceptions.
Q4How do I combine more than one condition into a single rule?
Use an Aggregated Policy, which references two or more already-defined Policies and combines their results using a configurable rule like “all must be satisfied” or “at least one must be satisfied.”
Q5When should I write a custom JS/Rule-Based Policy instead of using built-in types?
Only when a genuinely custom check has no equivalent among the built-in Policy types, even when combined through Aggregation — for instance, a check against an external, proprietary system. It carries real engineering overhead, so it should be a last resort, not a first reach.
Q6What’s the difference between a Resource-based and a Scope-based Permission?
A Resource-based Permission attaches Policies to an entire Resource, governing every action on it uniformly. A Scope-based Permission attaches Policies to one specific action, letting different actions on the same Resource carry entirely different rules.
Q7Can the same Policy be reused across many different Permissions?
Yes — this reusability is one of the central benefits of the Policy model. A single well-defined Policy can be attached to as many Permissions, across as many Resources, as actually need that same underlying rule.
Q8What does a Policy’s “Negative” logic setting actually mean?
It inverts the Policy’s normal result. A Role Policy set to Negative logic is satisfied precisely when the user does not hold the specified Role, rather than when they do — worth checking explicitly during any audit, since it isn’t visible from the Policy’s name alone.
Q9Does the application making the request ever see the Policies themselves?
No. The requesting application only ever receives the final Permit or Deny decision from Keycloak’s Authorization Services — the underlying Policies, their combination logic, and any custom code they run stay entirely inside Keycloak’s own configuration, invisible to the calling application.
Q10What should happen when a custom Policy’s external dependency is unreachable?
As a general rule, it should fail closed — treating the unreachable dependency as “not satisfied” rather than silently granting access. Failing open, where an outage elsewhere quietly widens access, is rarely the right default for a security-relevant rule and should only be chosen deliberately, if at all.

18Summary and Key Takeaways

“A Policy is the written rule on file — a Permission is what pins that same rule to one specific door.”

Key Takeaways

  • A Policy is a named, reusable rule inside Keycloak’s Authorization Services that evaluates to satisfied or not satisfied — it does nothing on its own until attached to something.
  • Built-in Policy types include Role, User, Group, Client, Time, Aggregated, and JS/Rule-Based, covering the vast majority of real-world authorization needs.
  • A Permission is what actually joins one or more Policies to a Resource and/or Scope, making the rule enforceable — Policies describe the rule, Permissions describe what it governs.
  • Aggregated Policies let sophisticated combined logic be built from focused, reusable individual Policies, without writing custom code.
  • Always verify a Permission’s combination logic explicitly and test both the intended-pass and intended-fail paths — a misconfigured combination setting can silently defeat an intended control.
  • A Policy’s Negative logic setting inverts its result and isn’t visible from its name alone, so it deserves explicit review during any audit.
  • Centralizing authorization as Policies pays off once an organization’s authorization needs grow sophisticated enough to justify the added architectural complexity — it isn’t automatically the right tool for every simple permission check.