TwoGenIdentity Labs

Keycloak Cedar Policy Engine

Fine-grained authorization for humans and AI agents, running inside Keycloak IAM.

This Lab explores how Cedar and Keycloak can provide consistent authorization across users, applications, and AI agents.

Experimental All Labs

Use Case

Human + AI agent access control

Goals

Enable fine-grained authorization inside Keycloak

Benefits

Consistent, policy-based access control

Standards

Cedar, AuthZEN

Why we're exploring this

Keycloak Authorization Services provides policy-based authorization, but its policy evaluation capabilities can be extended with different policy engines. This experiment explores integrating Cedar, AWS's open-source policy language, directly into Keycloak as the policy engine for authorization decisions. Policies are managed through the Keycloak Admin Console, while authorization decisions are exposed through Keycloak's AuthZEN endpoint. The result is a Keycloak-based authorization architecture that brings Cedar's policy language and evaluation model to both human and AI agent authorization.

How a decision flows

Every request, human or agent, goes through the same path. The gateway enforces; Keycloak and Cedar decide.

Human / AI Agent

request

AuthZEN PEP

Your API / AI Gateway

AuthZEN request

Keycloak (AuthZEN PDP)

Cedar Policy Engine

permit / deny, evaluated in-process

One policy language, humans and agents

Cedar policies are declarative and readable. The same engine evaluates a human's role-based access and an AI agent's delegated scope, with no separate code path.

permit: User view document

Role-based read access to Document resources.

permit(
  principal,
  action == Action::"read",
  resource
)
when {
  principal.roles
    .contains("document-viewer")
  && resource.type == "Document"
};
permit: AI Agent view docs

Cryptographic identity + delegated scope + trusted orchestrator in audience.

permit(
  principal,
  action == Action::"read",
  resource
)
when {
  principal.clientId ==
    "spiffe://org/agents/planner"
  && principal.scope
       .contains("docs:read")
  && "spiffe://org/agents/orchestrator"
       in principal.aud
  && resource.type == "Document"
};

What it does today

  • Cedar policies are evaluated in process by Keycloak's Authorization Services.
  • Keycloak remains the policy decision point (PDP), with decisions exposed through its AuthZEN endpoint.
  • The Cedar schema is automatically generated from Keycloak's resource server scopes and types.

Experimental

This is early-stage work. The policy schema, packaging, and admin experience may all change before this graduates into a supported product.

Talk to us about it