Skip to content

Agents · work in progress

AgentPass for services

Let an AI agent act for one of your users, with the user’s explicit approval, without sharing their password or session. Identvia is an AgentPass v0.1 federated Authority; your site is the Service.

Copy prompt for your AI agent

Using a coding agent? This prompt points it at these docs and lists the rules it must follow. Review what it writes like any other code.

You are helping me add "Sign in with Identvia" to my app (PHP). Identvia is an OpenID Connect provider.

Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration

Stack: plain PHP 8.1+ (no framework). Use the official SDK identvia/identvia-php (composer require identvia/identvia-php, or the zip with vendor/ from https://id.identvia.com/developers/docs/php for hosts without Composer). Create identvia.php (config), login.php (redirectToSignIn), callback.php (handleCallback, then session_regenerate_id(true) and store sub) and logout.php. Read secrets from environment variables or a config file outside the web root.

Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.

Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md

Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.

AgentPass v0.1 is a draft specification and may change. Identvia implements the version pinned at clerk/agentpass@937efe3. Don’t put irreversible or high-value actions behind it yet.

How it works

  1. The agent’s harness asks Identvia for a pass: which site, which user, what task, which kind (bearer_token or browser_session), and the harness’s public key.
  2. Identvia finds your site through DNS, asks your site which permissions exist, and puts the request in the user’s inbox. The user picks the permissions and approves with a passkey or authenticator app. Agents can never approve their own requests.
  3. The harness gets a pass that works once, for your site only, within 2 minutes, and only together with a proof signed by the harness key.
  4. Your site redeems the pass: it checks it with Identvia, verifies the proof, and issues its own API token or a one-time sign-in link.
  5. While the agent works, your site re-checks the delegation at least every 60 seconds. When the user revokes it in Identvia, the agent is stopped.

PHP: identvia/agentpass-php

View on GitHub · All SDKs

An MIT-licensed library for any PHP 8.1+ site (no framework, works on shared hosting). It serves the AgentPass endpoints, does DNS discovery and authority resolution, validates passes with the Authority, verifies the holder proof, mints bearer tokens or browser sessions, and runs the continuous checks (fail-closed).

PHP
$service = new AgentPass\Service\Service(new AgentPass\Service\ServiceConfig(
    origin: 'https://todo.example.com',
    signingKeyPem: file_get_contents(__DIR__ . '/agentpass-key.pem'),   // bin/agentpass-keygen
    trustedAuthorities: [AgentPass\Service\ServiceConfig::authority('https://id.identvia.com')],
    scopes: [['name' => 'todos:read', 'description' => 'See your todos'], ['name' => 'todos:write', 'description' => 'Add todos']],
    store: AgentPass\Service\Store\PdoStore::sqlite(__DIR__ . '/data/agentpass.sqlite'),
));
if ($service->handleGlobals()) { exit; }            // the /agentpass-service/* endpoints

// In your API:
$d = $service->authenticateBearer($_SERVER['HTTP_AUTHORIZATION'] ?? '');
if (!$d->can('todos:write')) { /* 403 */ }

The download includes a complete demo todo service (examples/todo) that accepts both bearer tokens and browser sessions.

DNS record

Publish one TXT record so Authorities can find your configuration:

DNS
_agentpass-service.todo.example.com.  TXT  "https://todo.example.com/agentpass-service/config.json"

Enterprise domains can publish _agentpass.<domain> with their own Authority URL, or none to disable delegation. Identvia and the SDK honor that precedence.

Identvia’s Authority endpoints

  • Configuration: https://id.identvia.com/agentpass/ap
  • Issuance: POST /agentpass/requests → 202 with a status link; poll no faster than poll_after_ms.
  • Validate and authorization-check: called by Services with a short-lived ES256 assertion signed by the key in the Service’s JWKS.

Your responsibilities

  • Treat the agent as acting for the user, but label it: show “via agent” in your UI and logs.
  • Offer narrow permissions. Never offer *; Identvia won’t either.
  • Keep checkCacheSeconds at 60 or less, and fail closed when the Authority can’t be reached.
  • Treat the task description as untrusted text from the agent.