Extracts agent identity registration behind AgentRegistrar protocol.
Three implementations:
KeycloakRegistrar — Keycloak Admin REST API (existing, refactored)
EntraRegistrar — Microsoft Entra Agent ID platform (NEW)
StubRegistrar — dev mode without real IdP
Driver selection via AGENT_REGISTRAR env var:
auto — prefers Entra if configured, Keycloak fallback, stub default
keycloak — explicit Keycloak
entra — explicit Entra Agent ID
Entra integration:
Registers agent as Entra app + service principal via Graph API
Tags with delegation metadata (agent_type, delegator, governed:true)
Client secret TTL matches delegation expiry
Deletes application on revocation (cascades to SP)
Uses msal for token acquisition
Future: native Agent ID Blueprint API when GA
Files:
registrar.py — AgentRegistrar protocol + AgentCredentials dataclass
registrar_keycloak.py — refactored from keycloak.py
registrar_entra.py — NEW Entra Graph API driver
registrar_stub.py — dev mode stub
registrar_factory.py — driver selection factory
delegation.py — updated to use registrar abstraction
settings.py — added Entra config + agent_registrar field
All 7 smoke tests pass with stub registrar.
Implements GCAP-SPEC-LLM-PRINCIPAL-BROKER-0001 §4.1-§4.3.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FastAPI companion service to the GSAP broker for AI agent
identity delegation in governed shell sessions.
Implements GCAP-SPEC-LLM-PRINCIPAL-BROKER-0001:
POST /delegate — request delegation (human → AI agent)
POST /delegate/{id}/revoke — revoke delegation
GET /delegate/{id} — delegation status
GET /agents — list active delegations
GET /health — health check
Delegation lifecycle:
REQUESTED → ACTIVE → EXPIRED | REVOKED
Cascading revocation on delegator AC revocation
Background cleanup of expired delegations (30s interval)
Keycloak integration:
Registers ephemeral agent clients per delegation
Deletes clients on revocation/expiry
Dev mode: stubs when no client_secret configured
GSAP broker integration:
Requests delegated ACs via on_behalf_of pattern
Scope narrowing: agent ceiling ≤ delegator ceiling
Dev mode: stubs when no bearer_token configured
Chronicle integration:
DELEGATION_CREATED (0x3001)
DELEGATION_REVOKED (0x3003)
DELEGATION_EXPIRED (0x3004)
All 7 smoke tests pass (health, create, list, query, revoke, verify, empty).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>