View as Markdown

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
{
  "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 /v1/identify/assessments. 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" } } }'
{
  "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"'" } } }'
{
  "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"'" } } }'
{
  "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 /v1/identify/decisions 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"
{
  "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