Estimated read: 3-4 minutes
We first presented this work at Java Day Istanbul 2026, where we used a live demo to explore a practical question for AI agent systems: once an agent has a valid token, who decides what it can actually access? The talk was titled "Beyond the Gateway: Fine-Grained Authorization for AI Agents," delivered to an audience built around Java and platform engineers.
The talk was organized around one question:
Once an AI agent has obtained a valid token, how do we decide what data it may reach, under what conditions, and on whose behalf?
For many classic application flows, an API gateway plus authentication and route/scope checks can be enough for coarse access control. For autonomous agents that talk to LLMs, MCP servers, tools, and other agents in sequence, that surface leaves the harder question unanswered. The harder question is no longer "can this request pass" but "what may it reach, under what conditions, and on whose behalf." Answering it requires evaluating tenant, actor identity, trust level, request channel, resource ownership, and risk score together. None of these inputs fits naturally inside a route rule or a scope check.
We argued that the answer belongs in a declarative policy artifact, evaluated by a centralized decision engine, and verified at design time with policy semantics designed to carry into runtime enforcement.
The live demo had a single policy at its center: an agent-invoice-read rule expressing under what conditions an invoice-agent may read an invoice. The condition combined seven inputs in a single expression: agent type, agent trust level, actor presence, request channel, tenant match against the resource, actor role, and current risk score.
We then ran two surfaces in sequence:
Design time. With kmctl authz, we validated the policy schema, simulated five scenarios (one GRANT and four DENY paths covering low trust, tenant mismatch, missing actor context, and high risk), and used explain to open the decision chain condition by condition for a denied case. (GRANT is the runtime result corresponding to a policy-level allow decision.)
Runtime. We placed an AI agent on the client side of the same flow, with an MCP server exposing two tools: get_agent_token (obtains a token from Keymate IdP, our Keycloak-based authority) and check_invoice_permission (calls the Access Gateway's check-permission endpoint). The agent translated natural-language intent into those two calls, and the decision was made outside the agent every time.
We also ran two social-engineering rounds. Within the demo's tool surface and credential boundary, the agent had no path to widen its own authority: enforcement remained in the policy layer, and the agent could only report the verdict.
The point of the demo was not the agent. It was that the authorization decision was deterministic, explainable, and designed around the same policy semantics across design time and runtime.
The design-time side of the work is now available as the Keymate Authz Toolkit under Apache-2.0. The repository ships:
kmctl authz binary built with Picocli. A self-contained fat JAR for developer machines and CI pipelines, exposing validate, simulate, and explain.This is the part of the work that developers can pick up today, point at their own access patterns, and use to express, test, and explain authorization policies before deploying them.
The identity, security, and governance ecosystems have moved fast on AI agents over the past year. Emerging drafts, published standards, and governance toolkits each address part of the picture: Transaction Tokens for Agents (IETF draft), Cross-App Access (XAA, in draft), RFC 9728 on Protected Resource Metadata (published), the AAuth draft, the OWASP LLM and Agentic Top 10 lists, and Microsoft's Agent Governance Toolkit. Together they cover how tokens are obtained, how identity propagates, how governance is set up, and how risks are mapped.
These are important steps. But they do not, on their own, answer "what data can this agent reach, under what conditions, on whose behalf," and recent public reports of broadly scoped tokens in agent hands have made the cost of that gap concrete.
That is the space the Java Day talk addressed and the space the open-source toolkit lives in. The combination we believe addresses it: declarative policy artifact + centralized evaluation + design-time test + policy semantics designed to carry into runtime.
This post is the entry door. The first two deeper pieces in the series are:
kmctl authz), the runtime flow through Access Gateway, and how the same policy semantics are designed to carry from a developer's machine to production.Beyond these two, we plan smaller deep-dives on Access Rules patterns, kmctl authz workflows, MCP integration, runtime enforcement, explainability, and a watchlist of the standards and drafts moving in this space.
If the toolkit interests you, the fastest way in is to clone the repo, run kmctl authz validate against the demo policy, and then write your own scenarios for an access pattern you actually care about. The design-time loop is intentionally short. Once it feels right, the same policy model is designed to carry into the runtime side without rewriting the rule.
We are continuing to ship, and we would rather hear "this is where it breaks for us" now than after the next release.
Try the open-source Keymate Authz Toolkit, walk through the demo policy, and tell us where it lands well or falls short.
Stay updated with our latest insights and product updates