Identify · Quickstart
Check a signed request
In this quickstart you check a request the way your server would, then sign the same request as an agent and check it again. Provenance names the signed agent, and refuses the signature once the request changes. You use curl and OpenSSL 3, or Node, or Python, with a published sandbox key, so you don't need an account.
1. Set your key and register an agent
The sandbox account key can register agents and check requests. Every key is listed on Sandbox and keys. Register the agent that will sign, then publish the public half of its Ed25519 key; the private key stays with you.
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
openssl genpkey -algorithm ed25519 -out agent-key.pem
export AGENT_X=$(openssl pkey -in agent-key.pem -pubout -outform DER | tail -c 32 | openssl base64 -A | tr '+/' '-_' | tr -d '=')
curl -s $PROVENANCE_API/v1/mandate/agents \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Pantry Pal", "description": "Shops for groceries for a person", "category": "shopping_agent" }' > agent.json
export AGENT_ID=$(jq -r .id agent.json)
curl -s $PROVENANCE_API/v1/identify/agents/$AGENT_ID/signing_keys \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "jwk": { "kty": "OKP", "crv": "Ed25519", "x": "'"$AGENT_X"'" } }' | tee signing-key.json
import { Provenance, generateEd25519Jwk } from "@provenanceauth/sdk";
const api = process.env.PROVENANCE_API!;
const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: api });
const agent = await prov.mandate.agents.create({ name: "Pantry Pal", description: "Shops for groceries for a person", category: "shopping_agent" });
const { publicJwk, privateJwk } = await generateEd25519Jwk(); // keep privateJwk in your secret store
const key = await prov.identify.addSigningKey(agent.id, { jwk: publicJwk });
import os, httpx
from provenanceauth import Provenance
from provenanceauth.web_bot_auth import generate_ed25519_jwk
api = os.environ["PROVENANCE_API"]
prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=api)
agent = httpx.post(f"{api}/v1/mandate/agents", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"},
json={"name": "Pantry Pal", "description": "Shops for groceries for a person", "category": "shopping_agent"}).json()
public_jwk, private_jwk = generate_ed25519_jwk() # keep private_jwk in your secret store
key = prov.identify.add_signing_key(agent["id"], jwk=public_jwk)
{
"object": "agent_signing_key",
"status": "active"
}
The response's kid is the key's thumbprint, the keyid every signature names. directory_url is the public key directory a site fetches it from, with no key.
export KEY_ID=$(jq -r .kid signing-key.json)
2. Check a request with no signature
Send the request as your server received it to POST /. curl declares itself in its user agent, so the verdict is declared_bot.
curl -s $PROVENANCE_API/v1/identify/assessments \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "request": { "method": "GET", "url": "https://quillstack.example/products/linen-a5", "headers": { "user-agent": "curl/8.7.1" } } }'
const unsigned = await prov.identify.assess({
request: { method: "GET", url: "https://quillstack.example/products/linen-a5", headers: { "user-agent": "curl/8.7.1" } },
});
unsigned = prov.identify.assess(request={
"method": "GET", "url": "https://quillstack.example/products/linen-a5", "headers": {"user-agent": "curl/8.7.1"},
})
{
"object": "traffic_assessment",
"class": "declared_bot",
"agent": null
}
3. Sign the request and check it again
Sign the same request as Web Bot Auth defines it (RFC 9421 HTTP message signatures): the method, the host, the path and the Signature-Agent header that points at your agent's key directory. The bash tab builds the signature base and signs it with OpenSSL, so the signature is fresh when you run it.
export SIGNATURE_AGENT="sig1=\"$PROVENANCE_API/v1/public/agents/$AGENT_ID/directory\";type=jwks_uri"
export CREATED=$(date +%s)
export SIGNATURE_PARAMS="(\"@method\" \"@authority\" \"@path\" \"signature-agent\";key=\"sig1\");created=$CREATED;expires=$((CREATED + 300));keyid=\"$KEY_ID\";alg=\"ed25519\";tag=\"web-bot-auth\""
printf '"@method": GET\n"@authority": quillstack.example\n"@path": /products/linen-a5\n"signature-agent";key="sig1": "%s";type=jwks_uri\n"@signature-params": %s' \
"$PROVENANCE_API/v1/public/agents/$AGENT_ID/directory" "$SIGNATURE_PARAMS" > signature-base.txt
export SIGNATURE="sig1=:$(openssl pkeyutl -sign -rawin -inkey agent-key.pem -in signature-base.txt | openssl base64 -A):"
curl -s $PROVENANCE_API/v1/identify/assessments \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "request": { "method": "GET", "url": "https://quillstack.example/products/linen-a5", "headers": {
"user-agent": "PantryPal/1.0",
"signature-agent": "'"${SIGNATURE_AGENT//\"/\\\"}"'",
"signature-input": "sig1='"${SIGNATURE_PARAMS//\"/\\\"}"'",
"signature": "'"$SIGNATURE"'" } } }'
import { signRequest } from "@provenanceauth/sdk";
const url = "https://quillstack.example/products/linen-a5";
const headers = await signRequest(
{ method: "GET", url },
{ key: privateJwk, signatureAgent: { url: `${api}/v1/public/agents/${agent.id}/directory`, type: "jwks_uri" }, expiresIn: 300 },
);
const signed = await prov.identify.assess({ request: { method: "GET", url, headers: { "user-agent": "PantryPal/1.0", ...headers } } });
console.log(signed.class, signed.agent?.name); // signed_agent Pantry Pal
from provenanceauth.web_bot_auth import sign_request
url = "https://quillstack.example/products/linen-a5"
headers = sign_request("GET", url, private_jwk=private_jwk,
signature_agent_url=f"{api}/v1/public/agents/{agent['id']}/directory",
signature_agent_type="jwks_uri", expires_in=300)
signed = prov.identify.assess(request={"method": "GET", "url": url, "headers": {"user-agent": "PantryPal/1.0", **headers}})
print(signed["class"], signed["agent"]["name"]) # signed_agent Pantry Pal
{
"object": "traffic_assessment",
"class": "signed_agent",
"agent": {
"name": "Pantry Pal",
"category": "shopping_agent",
"verified": true
}
}
The verdict names the agent from its registration, so your traffic policy can treat Pantry Pal differently from an unknown bot.
4. Change the request after signing
Send the same headers with a different path. The signature covers @path, so it fails to verify and the request is a suspected_bot.
curl -s $PROVENANCE_API/v1/identify/assessments \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "request": { "method": "GET", "url": "https://quillstack.example/checkout", "headers": {
"user-agent": "PantryPal/1.0",
"signature-agent": "'"${SIGNATURE_AGENT//\"/\\\"}"'",
"signature-input": "sig1='"${SIGNATURE_PARAMS//\"/\\\"}"'",
"signature": "'"$SIGNATURE"'" } } }'
const changed = await prov.identify.assess({
request: { method: "GET", url: "https://quillstack.example/checkout", headers: { "user-agent": "PantryPal/1.0", ...headers } },
});
changed = prov.identify.assess(request={
"method": "GET", "url": "https://quillstack.example/checkout", "headers": {"user-agent": "PantryPal/1.0", **headers},
})
{
"object": "traffic_assessment",
"class": "suspected_bot",
"signals": [{ "code": "signature_invalid" }]
}
5. Read the decision back
Every check is kept as a traffic decision for 30 days. GET / lists them, newest first, with the class, the decision your policy took and the path.
curl -s "$PROVENANCE_API/v1/identify/decisions?limit=1" \
-H "Authorization: Bearer $PROVENANCE_KEY"
const { data } = await prov.identify.listDecisions({ limit: 1 });
decisions = prov.identify.list_decisions(limit=1)
{
"object": "list",
"data": [
{ "object": "traffic_decision", "class": "suspected_bot", "decision": "allow", "path": "/checkout" }
],
"has_more": true
}
The decision is allow because the sandbox account has no traffic policy yet. Write a traffic policy to block or rate-limit suspected bots, or to require a person.
Try it
The Identify explorer runs the check in your browser against the sandbox. To see the RFC 9421 signature base for any request, print signature-base.txt from step 3.
Next steps
- Verify signed agents: put the middleware in front of your site.
- Sign your agent's requests: the agent side, key rotation and suspension.
- Write a traffic policy: block, rate-limit or require a person.
- Example apps: small working apps that use this product end to end.