Version 1.1 Command-line tools, reference programs and a library

Tools

Five command-line tools, two reference programs and a reference PEP library in Rust. They help you build and test an implementation of the protocol, for agents and for their services.

Why a team that builds agents wants them

An agent acts with a key. A team that builds agents, or services for agents, must know two things. A service refuses a key that goes beyond the rights of its owner. A spent budget stops the agent.

  • fake-pdp gives your service a decision point with a user, the key of her agent and their limits. Its counters run in memory.
  • access-token makes the identity tokens, good and bad, that the service must check.
  • access-conformance runs the cases against your service. Each case cites the paragraph that it tests.
  • access-lint checks the action document, where the service declares its actions and limits.
  • reference-service and reference-edge show a service and an edge that pass the cases.

Seven programs, one library

The repository builds seven programs. Five are tools for you. Two are reference programs: they are the targets that the conformance cases test, and they show how an implementation can look. A reference program is not a tool for an operator. The library procurauth-pep is the eighth crate that you use.

ProgramKindWhat it does
keychecktoolChecks the text of a key against a key format.
access-tokentoolMakes and checks identity tokens, good and bad.
access-linttoolChecks an action document, grants and an options answer.
fake-pdptoolA test PDP for a service and for the runner.
access-conformancetoolRuns the series U, D and E against a target.
reference-servicereference programThe test subject of the series U (a PEP).
reference-edgereference programThe test subject of the series E (an edge).

Common rules

Option or codeMeaning
--help, -hShow the usage and exit with 0.
--version, -VShow the name and the version of the program. The five tools add the line Apache-2.0.
Exit code 0No finding. The check passes.
Exit code 1A finding, a bad key, a failed case. For fake-pdp and the reference programs: the port cannot open.
Exit code 2The command line is not valid, a file is bad, or the tool cannot read its input.
  • The command line is closed. An unknown option, or an option that occurs two times, is a usage error.
  • The results go to the standard output. The diagnostics go to the standard error. No program uses colour.
  • The five tools read no environment variable. A reference program reads one only when its configuration names it with a key that ends in _env.
  • The configuration of a program is closed. An unknown member, a duplicate member or a wrong value stops the program at start. The message names the key, the expected value and the value found. --print-config prints the value that applies for each key and its source, and hides each secret.
  • No program has TLS code. The tools speak plain http and refuse an https URL. Production needs TLS from another layer. The library procurauth-pep has the optional feature tls for the link to the PDP (see the library).

keycheck

Checks the text of a key against a key format. No store, no network.

What it does

Role
Tells if a text has the form of a key. The protocol defines no format for the text of a key (3.8), so the format is an input.
Input
The key text on the standard input, never as an argument. The tool reads at most 4,096 bytes and removes one line end. The argument is a format file, a JSON document with prefix, length, alphabet and checksum. The member checksum.covers is optional: random, the default, or prefix_and_random.
Output
Text: good, the SHA-256 digest of the text in lower-case hexadecimal, and a hint of 4 characters at most. Or bad: with the first cause, in this order: prefix, length, alphabet, checksum. With --format json: one object on one line.

0 good key1 bad key2 usage error or unreadable input

Rules: 3.8.

Limits

  • The tool never prints the text of a key, never writes it to a log and never puts it in an error. A usage error does not show an argument. No message shows the path of the format file.
  • It reads no environment variable and makes no network call.
  • It checks the form of the text only. It does not know your keys, and it does not make keys.
  • An empty input, an input of more than 4,096 bytes and an input that is not UTF-8 give exit code 2.

Schemas: key-format.schema.json, keycheck-output.schema.json.

Command
keycheck [--format text|json] <format-file>
format.json
{  "prefix": "mcp_",  "length": 53,  "alphabet": "A-Za-z0-9",  "checksum": {    "algorithm": "crc32",    "encoding": "base62",    "characters": 6  }}
Example
$ keycheck format.json < key.txtgoodsha256: 0765d2f5a64bd1a2cb6d9ec22708e772e64e6191b60d06d290644c1ea49d75d3hint: Ky9P$ echo $?0
Example
$ keycheck format.json < key.txtbad: length (expected 53 characters, found 47)$ echo $?1
JSON form
{"verdict":"bad","cause":"length","message":"length (expected 53 characters, found 47)","detail":{"expected":53,"found":47}}
Real output of keycheck --help
keycheck --help
Check the text of a key against a key format.The text of the key comes from the standard input, and never from an argument. The program prints the verdict on the standard output. For a good key it prints the SHA-256 digest and a hint of at most 4 characters. The program never prints the text of the key.Usage: keycheck [--format text|json] <format-file>Arguments:  <format-file>          The file of the key format: a JSON document with `prefix`, `length`, `alphabet` and `checksum`Options:      --format <text|json>          The form of the output          Possible values:          - text: Lines of text. This is the default          - json: One JSON object on one line                    [default: text]  -h, --help          Print help (see a summary with '-h')  -V, --version          Print versionExit codes: 0 for a good key, 1 for a bad key, 2 for a usage error or an input that the program cannot read.

access-token

Makes and checks identity tokens, good ones and bad ones, for tests.

What it does

Role
make signs a token, or makes a bad token to test a service. check runs the checks of 9.2, 9.3 and 9.4 on a token, and prints one line for each of 14 checks.
Input
make: a private key in PKCS#8 PEM form (Ed25519 or P-256) and a claims file. check: a token and the configuration of a service. Both accept - for the standard input.
Output
make writes the token on the standard output. check writes the name of the check, ok, fail or skip, and a detail. A failed line ends with the rule. --format json is available on both.

0 no finding: a token is made, or each check passes1 findings2 usage error or unreadable input

Bad tokens

  • An old exp, a late iat, a late nbf, a long life or an absent claim: write it in the claims file. Use --allow-bad-claims to make a token with an absent claim.
  • --number-form CLAIM=FORM writes the number of iat, exp or nbf with a fraction, an exponent or a sign. The forms are fraction, exponent and negative. The value stays the same, and protocol 9.3 refuses each form.
  • --alg accepts Ed25519, ES256, and, to make bad tokens, EdDSA, HS256, RS256 and none. The tool always signs with the real algorithm of the key.
  • --typ, --kid, --crit and --bad-signature make the other defects of 9.2 to 9.4. A token without --kid fails against a configuration of two keys.

Limits

  • By default, make refuses claims that break 9.3. It makes no token and exits with 1.
  • The tool has no key generator. Make test keys with openssl. The keys in crates/access-token/examples/ are public. Never use them for a real edge.
  • The tool reads the system clock only when you do not give --now. It reads no environment variable and makes no network call.
  • The configuration file of the service has a closed schema. It refuses Authorization, Proxy-Authorization and Cookie as the token header (9.4).

Schemas: access-token-config.schema.json, identity-token-claims.schema.json.

Command
access-token make --key FILE [--alg ALG] [--typ TYPE]    [--kid ID] [--crit NAME] [--bad-signature]    [--number-form CLAIM=FORM]... [--allow-bad-claims]    [--format text|json] CLAIMSaccess-token check --config FILE [--format text|json]    [--now UNIX_SECONDS] [--print-config] [TOKEN]
Example
$ access-token make --key test-edge-ed25519.pem \    --alg Ed25519 claims-key.json > token.jwt$ access-token check --config service.json \    --now 1792569700 token.jwtstructure  ok   3 partsheader     ok   no `crit`alg        ok   Ed25519typ        ok   JWTkid        ok   one key in the setsignature  ok   goodclaims     ok   iss, sub, aud, iat, expiss        ok   https://edge.examplesub        ok   presentaud        ok   datastoreiat        ok   1792569600exp        ok   1792569900nbf        ok   absentlife       ok   life 300 s, max 300 s$ echo $?0
Example, a bad signature
$ access-token make --key test-edge-ed25519.pem \    --alg Ed25519 --bad-signature \    claims-key.json > token-bad.jwt$ access-token check --config service.json \    --now 1792569700 token-bad.jwttyp        ok   JWTkid        ok   one key in the setsignature  fail The signature is not good. (rule 9.4)claims     ok   iss, sub, aud, iat, exp...$ echo $?1
The 14 checks of access-token check
CheckRuleThe check passes when
structure9.4three parts in base64url; the header and the payload are JSON objects
header9.4no crit member
alg9.2Ed25519 or ES256
typ9.2JWT
kid9.4the key set has a key for the token
signature9.4good, with the key and the algorithm of the header
claims9.3iss, sub, aud, iat and exp are there; iat and exp are JSON integers with digits only
iss9.4the issuer of the configuration
sub9.3a string that is not empty
aud9.4the id of the service, or an array that holds it
iat9.4not later than the clock plus the skew
exp9.4the clock is not later than exp plus the skew
nbf9.4no nbf, or an nbf that is not later than the clock plus the skew
life9.4exp minus iat is not more than the maximum age
Real output of access-token --help
access-token --help
Make and check the identity tokens of ProcurAuth (protocol section 9)Usage: access-token <COMMAND>Commands:  make   Make a signed identity token, good or bad, and write it to the standard output  check  Check a token against the configuration of a service, and write one line for each checkOptions:  -h, --help     Print help  -V, --version  Print versionExit codes: 0 no finding, 1 at least one finding, 2 usage error or unreadable input.The licence is Apache-2.0.

access-lint

Checks an action document before a service publishes it.

What it does

Role
Applies 86 rules to the action document (44), to a file of grants (27) and to an answer of the options route (15). It reports every problem, not only the first.
Input
An action document, as a file or as an http URL. Optionally --grants FILE, the grants of one subject, and --options FILE, an answer of the options route or an envelope with query and answer.
Output
One line for each finding: the JSON path, the rule and a short text. A warning has the mark warning:. --format json adds the code and the full message of each finding.

0 no error (warnings are allowed)1 at least one error2 usage error or unreadable input

Rules: 3.5, 4.1, 4.2, 5.2, 5.2b, 5.3, 5.3c, 5.7, 5.8, 6.1, 6.10, 7.1, 7.3 and 8.3.

Limits

  • A warning never changes the exit code. A warning shows a SHOULD, a size above the minimum of 5.3c, or a value that has no effect.
  • The warnings ceiling_unit_plural and budget_unit_singular check the unit of a limit (6.1). The unit of a ceiling is a plural noun, for example rows. The unit of a budget is a singular noun, for example request. The test is a heuristic, so the finding is a warning.
  • The tool fetches an http URL only, with one GET. It has no TLS code and refuses an https URL with exit code 2. It reads at most 64 KiB, waits 10 seconds, follows 3 redirects at most (same host and port) and reads no proxy variable.
  • The URL is the full URL of the document. The tool does not add /.well-known/procurauth/actions.
  • A file can have 8 MiB at most. The tool does not read the standard input and reads no environment variable.
  • Without a query, the tool cannot check the type or the parent of the items of an options answer.

Rules: crates/access-lint/RULES.md lists each one. Schemas: access-lint-output.schema.json, grants-file.schema.json, options-file.schema.json.

Command
access-lint [--format text|json] [--grants FILE]    [--options FILE] <document>
Example
$ access-lint actions.jsonactions.json: 2 errors  $.actions[0].limits[2]  rule 5.2  undeclared limit  $.limits[0].min         rule 6.1  budget with "min"$ echo $?1
Example
$ access-lint good-actions.jsongood-actions.json: no finding$ echo $?0
Example, an https URL
access-lint: URL https://example.com/x: the scheme https is not supported, because the tool has no TLS code. Use an http URL, or save the document in a file$ echo $?2
Real output of access-lint --help
access-lint --help
Check an action document of ProcurAuth.The tool prints one line for each finding: the JSON path, the rule and a short text. A document without error gives exit code 0, and a document with an error gives 1. A usage error, or an input that the tool cannot read, gives 2.Usage: access-lint [--format text|json] [--grants FILE] [--options FILE] <document>Arguments:  <document>          The action document: a file, or an http URLOptions:      --format <text|json>          The form of the output: `text` or `json`          Possible values:          - text: One line for each finding          - json: One JSON document. `schemas/access-lint-output.schema.json` describes it                    [default: text]      --grants <FILE>          A file of grants. The tool checks each limit value against the document      --options <FILE>          A file with an answer of the options route, and optionally its query  -h, --help          Print help (see a summary with '-h')  -V, --version          Print version

fake-pdp

A test decision point (PDP). A service and the conformance runner can run without a real backend.

What it does

Role
Answers as the protocol says for decisions, limits, budgets and reasons (sections 3 to 8, 11 and 12), from the fixed data of one file. It also gives the approvals of section 17. It keeps its counters in memory.
Input
A data file with services (each with its action document), subjects (persons and keys with grants), counters, failures, approvals, clock and metadata. The test mode confirm_all makes each action except access and mcp.session need an approval. The example crates/fake-pdp/examples/datastore.json is the data of section 13 of the protocol.
Output
The AuthZEN 1.0 endpoints and the metadata on one address. One block of log for each question on the standard output. The values of the configuration go to the standard error.

0 stopped on request1 the port cannot open2 usage error or bad file

Endpoints

  • POST /access/v1/evaluation and POST /access/v1/evaluations.
  • GET /.well-known/authzen-configuration. The metadata always has the five members procurauth_usage_max_seconds, procurauth_idle_max_seconds, procurauth_evaluations_max_bytes, procurauth_evaluations_max_items and procurauth_directory_max_age_seconds (defaults 5, 30, 1,048,576, 100 and 1). The data-file key metadata.directory_max_age_seconds sets the last one (3.9, 10.7b). The metadata also has the twelve members procurauth_approval_* of 17.4a.
  • POST /approval/v1/requests, GET /approval/v1/requests/{id} and POST /approval/v1/requests/{id}/keepalive: the approval API of 17.4. A request with no credential, or with an unknown credential, gets HTTP 401 with unauthorized.
  • The admin endpoints, with --admin only.

Failures to make

A rule of the data file or of --failures makes the PDP fail. Use it to test a PEP against 6.9, 6.12, 10.3 and 10.6. The kinds are error_503, delay, no_answer, close, invalid_json and no_units. The kinds submit_explanation_required, submit_cannot_supersede, submit_invalid_evaluation and submit_unknown_code apply to the next submissions of the approval API. They test the map of binding 5.7a in a PEP.

Limits

  • It is a test PDP, not a production PDP. It runs one instance, keeps the counters in memory and has no store.
  • It speaks plain HTTP. It has no TLS code.
  • The admin endpoints have no protection except the credential. Enable them on a trusted network only.
  • The tool has no --format option. A body above procurauth_evaluations_max_bytes gets HTTP 413, and more items than procurauth_evaluations_max_items get HTTP 400.
  • It keeps only the SHA-256 digest of a credential and never writes a credential to a log.

Schema: fake-pdp-data.schema.json. The crate is also a library (fake_pdp::Server), and access-conformance uses it.

Command
fake-pdp [--listen ADDRESS:PORT] [--clock-start SECONDS]    [--admin] [--credential-file FILE] [--failures FILE]    [--workers N] [--print-config] <data-file>
Example
$ fake-pdp --listen 127.0.0.1:8181 \    crates/fake-pdp/examples/datastore.jsonfake-pdp 1.1.0 on http://127.0.0.1:8181metadata /.well-known/authzen-configurationq1  alice  data.read  host:prod/database:test2/table:orders    true  limits {"max_duration":30,"max_rows":100}  units 1    counters  alice/second 1  alice/minute 1
question.json
{  "subject": { "type": "user", "id": "alice" },  "action": { "name": "data.read" },  "resource": {    "type": "table",    "id": "orders",    "properties": {      "ancestors": [        { "type": "service", "id": "datastore" },        { "type": "host", "id": "prod" },        { "type": "database", "id": "test2" }      ]    }  },  "context": { "usage": { "units": 1 } }}
Example
$ curl -s -H 'Content-Type: application/json' \    http://127.0.0.1:8181/access/v1/evaluation \    -d @question.json{"context":{"limits":{"max_duration":30,"max_rows":100},"usage":{"units":1}},"decision":true}
Flags and defaults
FlagDefaultMeaning
--listen ADDRESS:PORT127.0.0.1:8181The listener. Port 0 chooses a free port.
--clock-start SECONDSthe system clockFix the clock. It then moves only through the admin endpoint.
--adminoffEnable the admin endpoints under /__fake/.
--credential-file FILEno credentialThe PDP then requires Authorization: Bearer from the PEP.
--failures FILEnoneMore failures, with the kinds close, invalid_json, no_units and submit_*.
--workers N8Worker threads, 1 to 256. One open connection uses one thread.
--print-configoffCheck all the files, print the value of each key with its source, and exit with 0.
Admin endpoints
RequestEffect
GET, POST /__fake/clockRead the clock, or move it with {"advance": N} or {"set": T}.
PUT /__fake/loadReplace the directory, the counters, the failures, the clock and the credentials with a data file.
POST /__fake/resetPut the counters back to their first values.
GET /__fake/countersThe counters of the current windows.
GET, DELETE /__fake/logThe last 10,000 questions with their answers, or remove them.
GET, POST /__fake/failuresRead the failure rules, or replace all of them.
GET /__fake/approvalsAll the approval requests, with all their members.
POST /__fake/approvals/{id}/answerThe answer of the owner: {"decision": "approve"} or {"decision": "decline"}.
POST /__fake/approvals/{id}/replyThe owner asks the agent a question.
POST /__fake/approvals/{id}/cancelCancel a request that waits, or an approval that nobody consumed.
POST /__fake/approval-refsRegister an approval_ref of an agent.
The metadata
Metadata
{  "access_evaluation_endpoint": "http://127.0.0.1:8181/access/v1/evaluation",  "access_evaluations_endpoint": "http://127.0.0.1:8181/access/v1/evaluations",  "policy_decision_point": "http://127.0.0.1:8181",  "procurauth_approval_consume_seconds": 300,  "procurauth_approval_deny_seconds": 300,  "procurauth_approval_evaluation_ttl_seconds": 300,  "procurauth_approval_grace_seconds": 120,  "procurauth_approval_lease_max_seconds": 604800,  "procurauth_approval_lease_min_seconds": 30,  "procurauth_approval_max_command_bytes": 65536,  "procurauth_approval_max_life_seconds": 7776000,  "procurauth_approval_max_revivals": 3,  "procurauth_approval_ref_ttl_seconds": 900,  "procurauth_approval_revive_seconds": 604800,  "procurauth_approval_wait_max_seconds": 25,  "procurauth_directory_max_age_seconds": 1,  "procurauth_evaluations_max_bytes": 1048576,  "procurauth_evaluations_max_items": 100,  "procurauth_idle_max_seconds": 30,  "procurauth_usage_max_seconds": 5}
Real output of fake-pdp --help
fake-pdp --help
A test decision point (PDP) for ProcurAuth.The program answers like a real PDP, from the fixed data of one file. It serves the AuthZEN 1.0 endpoints and the metadata on one address. It keeps its counters in memory. It reads no environment variable.Exit code 0: stopped on request. Exit code 1: the port cannot open. Exit code 2: usage error or bad file.Usage: fake-pdp [OPTIONS] <DATA_FILE>Arguments:  <DATA_FILE>          The data file: services, subjects, grants, counters and failuresOptions:      --listen <ADDRESS:PORT>          The address of the listener. The default is 127.0.0.1:8181. Port 0 chooses a free port      --clock-start <UNIX_SECONDS>          Fix the clock at this time. The clock then moves only through the admin endpoint      --admin          Enable the admin endpoints under /__fake/. Use it on a trusted network only      --credential-file <FILE>          Read the credential of the PEP from this file. The PDP then requires a Bearer credential      --failures <FILE>          Read more failures from this file. It can use the kinds close, invalid_json, no_units and submit_*      --workers <N>          The number of worker threads, from 1 to 256. The default is 8      --print-config          Check all the files, print the values that apply, and exit with 0. The port stays closed  -h, --help          Print help (see a summary with '-h')  -V, --version          Print version

access-conformance

Runs the conformance cases against a PEP, a PDP or an edge.

What it does

Role
Runs the series U against a PEP, the series D against a PDP and the series E against an edge. See the page Conformance.
Input
--role pep|pdp|edge, --profile FILE (mandatory) and --url URL. The profile tells the runner how to reach and wire the target: the operations, the keys, the credentials and the listen addresses. Optionally --cases, --series, --cases-dir and --print-config.
Output
One line for each case: the id, pass, fail, warn or skip, the paragraphs and a text. A summary line ends the run. --format json writes one document (schema conformance-report).

0 each case that ran passed1 a case failed2 usage error, bad profile or data, or a target that is not reachable

Limits

  • It speaks plain HTTP. The URL has the scheme http and no path. The tool refuses an https URL.
  • For a PEP it acts as the edge and as the PDP, and for an edge as the client, the service and the PDP. It binds the listen addresses of the profile. A port in use stops the program.
  • It makes the identity tokens with the system clock. The clock of the target must agree with it, within the skew of the profile.
  • It reads no environment variable. The profile and the options are the only sources.
  • A skipped case is not a failure. A failed case of a SHOULD rule is a warning and does not change the exit code.
  • A PEP never skips the cases of section 17. A PDP or an edge that gives no approval skips them, with the condition no_approval_support.

Schemas: conformance-profile.schema.json, conformance-report.schema.json, conformance-case.schema.json.

Command
access-conformance --role pep|pdp|edge --profile FILE    [--url URL] [--cases ID,ID,...] [--series U|D|E]    [--format text|json] [--cases-dir DIR] [--print-config]
Example
$ access-conformance --role pdp --profile pdp-fake.json \    --series D --cases D01,D02,D05D01  pass  4.3,7.3  A grant covers the node and each node below it, also a node that the service adds later.D02  pass  4.3,11.2  A grant on a database does not cover its host.D05  pass  7.3,8.1,8.4  A ceiling takes the lowest value among the grants of the asked action, and a key never goes above its owner.3 cases: 3 passed, 0 failed, 0 skipped$ echo $?0
Example, an https URL
error: Option `--url`: expected an http URL, found "https://x": the scheme https is not supported, because the tool has no TLS code; expected an http URL.$ echo $?2
Real output of access-conformance --help
access-conformance --help
Run the conformance cases of ProcurAuth against a PEP, a PDP or an edge.The runner sends the requests of the cases to the target. For a PEP, it acts as the edge and as the PDP. For an edge, it acts as the client, as the service behind the edge and as the PDP. The profile gives what the runner needs: the operations, the keys and the listen addresses.Usage: access-conformance [OPTIONS] --role <ROLE> --profile <FILE>Options:      --role <ROLE>          The implementation under test          Possible values:          - pep:  A service: the series U          - pdp:  A decision point: the series D          - edge: An edge: the series E      --profile <FILE>          The profile of the target, as one JSON file      --url <URL>          The URL of the target, for example http://127.0.0.1:8000. A PDP can run with no URL when the profile starts fake-pdp      --cases <ID,ID,...>          Run only these cases. Give ids with commas, for example U01,U05      --series <SERIES>          Run only this series. It must fit the role          Possible values:          - U: The cases for a PEP          - D: The cases for a PDP          - E: The cases for an edge      --format <FORMAT>          The form of the result          Possible values:          - text: One line for each case          - json: One JSON document                    [default: text]      --cases-dir <DIR>          Read the cases from this directory, in the layout of the directory conformance/. Without it, the program uses its own copy      --print-config          Check the profile and the files, write the values that apply, and stop  -h, --help          Print help (see a summary with '-h')  -V, --version          Print versionExit codes: 0 each case that ran passed, 1 at least one case failed, 2 usage error, bad profile or unreachable target.A skipped case is not a failure. A failed case of a SHOULD rule is a warning and does not change the exit code.The licence is Apache-2.0.

reference-service

A small service that uses the library. It is the test subject of the series U.

What it does

Role
The datastore example of section 13 of the protocol. It has routes for hosts, databases and tables, an action document, an options route and an MCP endpoint. It is a PEP built with procurauth-pep. It is not a tool for an operator.
Input
One JSON configuration file with a closed schema. A key takes its value from the file, or from an environment variable or a file that the configuration names (_env, _file). It needs a PDP, for example fake-pdp.
Output
One line on the standard error for each request: the method, the path and the status. Never a header, a query or a body. The client never gets the cause of a refusal.

0 stopped on request, or --print-config finished1 the port cannot open2 bad command line or configuration

Routes and tools

  • The health-probe route GET /health gives the text ok. It needs no token and asks no question (10.1c).
  • The route GET /static/about.txt runs no action of the action document. The service asks the action access on the service for it (10.1c).
  • The MCP tools include append_rows (action data.append) and get_action_status (binding 5.7b). Each tool follows the approval flow of section 17.
  • A route cannot wait for an approval. A reason of 17.1 gives HTTP 403 with the code approval_cannot_wait (17.7a).

Limits

  • It has no TLS client. The key pdp.url takes an http URL only, and it needs pdp.allow_plain_http. A deployment builds its own service with the library. It gives the library TlsTransport (feature tls) or another transport with TLS.
  • It keeps its data in memory. A write changes it for the life of the process.
  • Its cache_ttl_seconds is 0, so each request reaches the PDP, as the cases expect.

The file crates/reference-service/PROFILE.md maps each operation of the cases to a request of the service.

Command
reference-service [--print-config] <config-file>
Example
$ PROCURAUTH_PDP_CREDENTIAL=... \    reference-service --print-config \    crates/reference-service/examples/config.jsonlisten = 127.0.0.1:8080  (file)workers = 8  (default)max_body_bytes = 1048576  (default)read_timeout_seconds = 10  (default)idle_timeout_seconds = 30  (default)service_id = datastore  (file)token_header = X-Identity-Token  (file)issuer = https://edge.example  (file)max_token_age_seconds = 300  (file)clock_skew_seconds = 30  (file)jwks = 1 key (Ed25519 kid=edge-ed25519)  (file)cache_ttl_seconds = 0  (file)cache_max_entries = 10000  (default)display_max_questions = 50  (default)mcp_path = /mcp  (file)mcp_session_budget = false  (default)pdp.url = http://127.0.0.1:8181  (file)pdp.credential = <hidden>  (file:crates/fake-pdp/examples/pep-credential.txt)pdp.allow_plain_http = true  (file)pdp.request_timeout_ms = 5000  (file)pdp.usage_wait_margin_ms = 1000  (default)pdp.idle_close_after_ms = 5000  (default)pdp.max_connections = 4  (default)pdp.plain_retries = 1  (default)$ echo $?0
Actions and limits of the service
ActionTypesLimits
data.readservice, host, database, tablerequests, max_rows, max_duration
data.writeservice, host, database, tablerequests, max_duration
data.inspectservice, host, database, tablenone
data.appendservice, host, database, tablerequests
mcp.sessionservicenone (the key mcp_session_budget adds the budget requests)
Real output of reference-service --help
reference-service --help
A reference service for ProcurAuth. It uses the library procurauth-pep. It is the test subject of the series U of the conformance cases. The configuration file is the only source of the values. The program reads an environment variable only when the file names it with a key that ends in _env.Usage: reference-service [OPTIONS] <CONFIG>Arguments:  <CONFIG>          The configuration file, a JSON object. See the README of the crate for the keysOptions:      --print-config          Check the configuration, print the value that applies for each key and its source, and exit  -h, --help          Print help (see a summary with '-h')  -V, --version          Print version

reference-edge

A small reference edge, an HTTP reverse proxy. It is the test subject of the series E.

What it does

Role
The edge of 8.3 and section 9 of the protocol and of section 6 of the MCP binding. It reads the text of a key from Authorization: Bearer. It asks the PDP for the action access on the service. It makes an identity token and sends the request to the service. It never sends the text of the key on. It is not a tool for an operator.
Input
One JSON configuration file with a closed schema, with the same _env and _file forms as the service. It needs four inputs: the key format, a keys file, a signing key (Ed25519 or P-256) and a PDP. The keys file has the SHA-256 digest, the subject and the owner of each key.
Output
One line on the standard error for each request. Never a header, a query, a body, the text of a key or a token.

0 stopped on request, or --print-config finished1 the port cannot open2 bad command line or configuration

Limits

  • It has no TLS code. It speaks plain HTTP to the client, the service and the PDP. Put a proxy that ends TLS in front of it.
  • It has no rate limit. A client can try many key texts. The format check and the digest lookup make each try cheap.
  • It opens a new connection to the service for each request. One open connection of a client uses one thread.
  • It reads the keys file at start. Restart it to load a new file. The protocol defines no key format and no keys file (3.8).
  • It does not support the header Upgrade. It answers HTTP/1.1 only.

The key token_cache_max_entries sets the table of kept tokens (9.9). With 0, the edge keeps no token. It asks the PDP for each request, also when it keeps tokens.

Command
reference-edge [--print-config] <config-file>
Example
$ PROCURAUTH_PDP_CREDENTIAL=... \    reference-edge --print-config \    crates/reference-edge/examples/config.jsonlisten = 127.0.0.1:8090  (file)workers = 16  (default)max_body_bytes = 1048576  (default)read_timeout_seconds = 10  (default)idle_timeout_seconds = 30  (default)service_id = datastore  (file)token_header = X-Identity-Token  (default)issuer = https://edge.example  (file)token_life_seconds = 60  (file)max_token_age_seconds = 300  (file)token_cache_max_entries = 1000  (file)key_format = prefix "pk_live_", 51 characters  (file:crates/reference-edge/examples/key-format.test-only.json)keys = 2 entries  (file:crates/reference-edge/examples/keys.test-only.json)upstream.url = http://127.0.0.1:8080  (file)upstream.connect_timeout_ms = 2000  (default)upstream.response_timeout_seconds = 30  (default)signing.key = <hidden> (Ed25519)  (file:crates/access-token/examples/test-edge-ed25519.pem)signing.kid = edge-ed25519  (file)pdp.url = http://127.0.0.1:8181  (file)pdp.credential = <hidden>  (env:PROCURAUTH_PDP_CREDENTIAL)pdp.allow_plain_http = true  (file)pdp.request_timeout_ms = 5000  (default)pdp.idle_close_after_ms = 5000  (default)pdp.max_connections = 4  (default)pdp.plain_retries = 1  (default)pdp.metadata_max_age_seconds = 3600  (default)pdp.max_response_bytes = 1048576  (default)$ echo $?0
The refusals of the edge
CaseAnswer
No Authorization: Bearer, or an empty textHTTP 401, WWW-Authenticate: Bearer, empty body
A bad form, a key that the edge does not know, or a subject with no accessHTTP 401 with error="invalid_token", empty body, the same for each cause
No valid answer of the PDPHTTP 503, empty body
No answer of the serviceHTTP 502 or 504, empty body
Real output of reference-edge --help
reference-edge --help
A reference edge for ProcurAuth: a reverse proxy that checks a key, asks the PDP for access, and gives the service an identity token. It is the test subject of the series E of the conformance cases. The configuration file is the only source of the values. The program reads an environment variable only when the file names it with a key that ends in _env.Usage: reference-edge [OPTIONS] <CONFIG>Arguments:  <CONFIG>          The configuration file, a JSON object. See the README of the crate for the keysOptions:      --print-config          Check the configuration, print the value that applies for each key and its source, and exit  -h, --help          Print help (see a summary with '-h')  -V, --version          Print version

Reference PEP library (Rust): procurauth-pep

The seven steps of a PEP as a small API. It does not depend on a web framework.

What it does

The application gives the headers of a request. The library gives back the identity, the ceilings to apply, or the refusal with its HTTP status. The crate reference-service uses it.

It also gives the options route (5.6 to 5.8), the builder of the action document and a Clock that a test can move by hand. The feature mcp, on by default, gives the helpers of the MCP binding. The feature tls, off by default, gives the link over TLS.

The seven steps of paragraph 10.0
StepWhat the PEP doesWhere
1Check the identity token, and send sub as the subject.Pep::authenticate
2Refuse a request with no valid token.Refusal::to_http
3Give each use one action and one resource with its chain.Operation, ActionDocumentBuilder
4Ask the PDP. Keep answers for cache_ttl at most.Pep::decide, Pep::check, Pep::display
5Send context.usage for a use of an action that lists a budget.Pep::decide
6Apply each ceiling of context.limits.Ceilings
7Map each refusal with 10.3.Refusal::to_http
How a refusal maps to HTTP
Answer of the PDPRefusalHTTP
false, no reason or another reasonForbidden403
false with budget_exceededRateLimited429 with Retry-After
No answer, an HTTP error, or an answer that is not validUnavailable503
false with a reason of 17.1, for a route that cannot waitForbidden403 with {"error":"approval_cannot_wait"}
true with no units for a use, or with a ceiling that the action does not listForbidden403
No valid identity tokenUnauthenticated401

The link to the PDP needs TLS in production. The feature tls gives TlsTransport, an HTTP/1.1 client over TLS 1.2 or 1.3, with rustls and aws-lc-rs. HttpTransport is the same client with no TLS. The configuration refuses an http URL unless pdp.allow_plain_http is true, and it refuses an https URL with this flag. transport::for_pdp gives the transport for the scheme of pdp.url. You can also implement the trait PdpTransport.

More functions

  • Pep::decide_approval follows the steps of 17.7 for a call that can wait. The module approval gives the calls, the verdicts and the refusals of binding 5.7a. Pep::approval_stats counts what the PEP received from the approval API. The MCP helpers give the result of binding 5.7 and the tool get_action_status.
  • Pep::decide_route_without_action serves a route that runs no action, for example a static file. It asks the action access on the service (10.1c). A health-probe route asks nothing.
  • token_cache_max_entries above 0 keeps the results of the token checks (9.7). A kept result serves until exp plus the clock skew. The default 0 keeps no result.
  • The PEP reads procurauth_directory_max_age_seconds from the metadata, for its logs only (3.9).
  • Operation::also_all and Identity::from_checked_token help a plain HTTP service. The README of the crate shows this use.

Limits

  • No TLS client without the feature tls.
  • No server. The application owns its transport and its routes.
  • No Search API of AuthZEN.

Use it

Cargo.toml
[dependencies.procurauth-pep]git = "https://github.com/ProcurAuth/procurauth"tag = "v1.1"# features = ["tls"] for the link over TLS

The crate is in the workspace of the repository and is not on crates.io. It needs Rust 1.89 or later.

Sketch of one call
use procurauth_pep::operation::{Operation, node};let who = pep.authenticate(request_headers)?;let table = node("datastore",    &[("host", "prod"), ("database", "test2"), ("table", "orders")])?;match pep.decide(&who, &Operation::new("data.read", table)).into_result() {    Ok(allowed) => {        // The ceiling lowers the rows that the client asked for (7.5).        let rows = allowed.ceilings().cap("max_rows", requested_rows).value;    }    Err(refusal) => { /* send refusal.to_http() */ }}

The README of the crate describes the API. Test a service that uses it with access-conformance.

How to get them

Binaries

A release has archives for Linux, macOS and Windows, with SHA-256 sums. Each archive holds the seven programs. Download one, check its sum and put the programs on your path.

Binaries of version 1.1

Source

The Rust workspace is in the repository. With Rust 1.89 or later, build the seven programs with cargo build --release --workspace. Without Rust on your machine, use the Docker script scripts/cargo.sh.

How to build