Application authentication
Register software as an Application and choose how it proves its identity to Keycard.
An Application is the identity Keycard gives to a piece of software: an MCP server, an agent, a web app, a CLI, or a background job. Keycard issues tokens to Applications, and every token it issues names the Application in its keycard_app_id claim. Before software can request tokens from your Zone, register it as an Application and give the Application a credential.
Create an Application
Section titled “Create an Application”An Application has a name, shown to users on consent screens, and an identifier, unique in the Zone, such as support-agent or a URL. An Application that signs users in also needs redirect URLs: the URLs Keycard may send authorization codes to.
In Keycard Console, go to Applications → Add Application, set Name, Identifier, and any Redirect URLs, then click Create application.
resource "keycard_application" "app" { zone_id = "<zone-id>" name = "Support Agent" identifier = "support-agent"
oauth2 = { redirect_uris = ["http://localhost:8765/callback"] }}The resource’s id is the Application ID that credentials reference.
Send POST /zones/<zone-id>/applications to the management API. The Keycard CLI handles authentication:
keycard agent api /zones/<zone-id>/applications --org <org-id> -X POST -d '{ "name": "Support Agent", "identifier": "support-agent", "protocols": { "oauth2": { "redirect_uris": ["http://localhost:8765/callback"] } }}'The response’s id is the Application ID that credentials reference.
Application credentials
Section titled “Application credentials”A credential is how an Application proves its identity at the Zone’s token endpoint, /oauth/2/token. An Application can hold several, for example a client secret for local development and a Workload Identity credential for production. Each request authenticates with one.
| Credential | type |
The Application sends | Use for |
|---|---|---|---|
| Workload Identity Recommended | token |
A token its platform issues, plus the credential’s Client ID | Workloads on a cloud, CI, or Kubernetes platform |
| Public key | public-key |
A JWT signed with its private key | Software that holds a key pair and serves its public keys |
| URL | url |
A JWT signed with its private key, or only its client ID if it’s a public Application | Software identified by a URL it controls |
| Client ID & Secret Shared secret | password |
A client ID and a shared secret | Local development, and hosts with no other option |
| Public | public |
Only a client ID | Browser and native apps that sign users in |
Add a credential in Keycard Console, with the Keycard Terraform provider, or with the management API.
Client ID & Secret
Section titled “Client ID & Secret”The Application sends its client ID and secret to the token endpoint, as KEYCARD_CLIENT_ID and KEYCARD_CLIENT_SECRET in the SDKs. Keycard returns the secret only once, so store it right away.
On the Application’s Application Credentials tab, click Add credential and choose Client ID & Secret. Copy the client ID and secret.
resource "keycard_application_client_secret" "app" { zone_id = "<zone-id>" application_id = "<application-id>"}The resource exports client_id and client_secret, both sensitive.
Send POST /zones/<zone-id>/application-credentials with the Keycard CLI:
keycard agent api /zones/<zone-id>/application-credentials --org <org-id> -X POST -d '{ "type": "password", "application_id": "<application-id>"}'The response holds the client ID as identifier and the secret as password.
Workload Identity
Section titled “Workload Identity”The Application’s platform issues it a short-lived token. The Application sends that token as client_assertion, and the credential ID as client_id. Keycard verifies the token against a Provider registered for the platform’s issuer, then checks its audience, subject, and claims. No secret is stored.
On the Application’s Application Credentials tab, click Add credential and choose Workload Identity:
| Field | Value |
|---|---|
| Provider | The Provider for the platform’s issuer |
| Subject | The sub the platform puts in the workload’s token |
| Allowed audience | Optional. The token’s aud must be exactly this one value. Defaults to the Zone issuer URL. |
| Authentication condition | Optional. A CEL expression over the token’s claims that must evaluate to true. |
Set Subject, Authentication condition, or both.
Copy the credential’s Client ID from the Application Credentials tab. The workload sends it as client_id.
resource "keycard_application_workload_identity" "app" { zone_id = "<zone-id>" application_id = "<application-id>" provider_id = "<provider-id>" subject = "<subject>" allowed_audience = "<audience>" # Optional. Defaults to the Zone issuer URL. authentication_condition = "<cel-expression>" # Optional.}The workload sends the resource’s client_id as client_id.
Send POST /zones/<zone-id>/application-credentials with the Keycard CLI:
keycard agent api /zones/<zone-id>/application-credentials --org <org-id> -X POST -d '{ "type": "token", "version": 2, "application_id": "<application-id>", "provider_id": "<provider-id>", "subject": "<subject>"}'The response’s identifier is the credential ID. The workload sends it as client_id.
Public key
Section titled “Public key”The Application signs a JWT with its private key and sends it as client_assertion, the private_key_jwt method from RFC 7523. Keycard verifies the signature against the public keys at the credential’s JWKS URL. To rotate keys, publish the new key there before signing with it.
On the Application’s Application Credentials tab, click Add credential and choose Public Key:
| Field | Value |
|---|---|
| Client ID | The client ID the Application sends |
| JWKS URL | The URL that serves the Application’s public keys |
resource "keycard_application_public_key_credential" "app" { zone_id = "<zone-id>" application_id = "<application-id>" jwks_uri = "<jwks-url>" identifier = "<client-id>" # Optional. Generated if omitted.}The Application sends the resource’s identifier as client_id.
Send POST /zones/<zone-id>/application-credentials with the Keycard CLI:
keycard agent api /zones/<zone-id>/application-credentials --org <org-id> -X POST -d '{ "type": "public-key", "application_id": "<application-id>", "jwks_uri": "<jwks-url>"}'The response’s identifier is the client ID.
The Application’s client ID is a URL that serves an OAuth Client ID Metadata Document. Keycard fetches the document from the URL to learn how the Application authenticates and which grants it uses, listed in grant_types. The URL must be reachable from the public internet.
- A confidential Application signs a JWT with its private key. Its document sets
token_endpoint_auth_methodtoprivate_key_jwt, names the signing algorithm, and points to its public keys withjwks_uri. - A public Application, such as a CLI or a native app, has no key. It signs Users in with the authorization code or device code flow.
Give an agent its own access builds a confidential Application this way.
On the Application’s Application Credentials tab, click Add credential, choose URL, and enter the client metadata document’s URL.
resource "keycard_application_url_credential" "app" { zone_id = "<zone-id>" application_id = "<application-id>" url = "<client-metadata-url>"}Send POST /zones/<zone-id>/application-credentials with the Keycard CLI:
keycard agent api /zones/<zone-id>/application-credentials --org <org-id> -X POST -d '{ "type": "url", "application_id": "<application-id>", "identifier": "<client-metadata-url>"}'Public
Section titled “Public”A browser or native app can’t keep a secret, so it sends only its client ID. PKCE is required, and protects the authorization code exchange. A public credential works only for flows where a User delegates access. It can’t get tokens for the Application acting as itself.
On the Application’s Application Credentials tab, click Add credential, choose Public, and enter the Identifier the app sends as its client ID.
resource "keycard_application_public_credential" "app" { zone_id = "<zone-id>" application_id = "<application-id>" identifier = "<client-id>"}Send POST /zones/<zone-id>/application-credentials with the Keycard CLI:
keycard agent api /zones/<zone-id>/application-credentials --org <org-id> -X POST -d '{ "type": "public", "application_id": "<application-id>"}'The response’s identifier is the client ID. Set identifier in the request to choose it yourself.