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-pdpgives your service a decision point with a user, the key of her agent and their limits. Its counters run in memory.access-tokenmakes the identity tokens, good and bad, that the service must check.access-conformanceruns the cases against your service. Each case cites the paragraph that it tests.access-lintchecks the action document, where the service declares its actions and limits.reference-serviceandreference-edgeshow 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.
| Program | Kind | What it does |
|---|---|---|
keycheck | tool | Checks the text of a key against a key format. |
access-token | tool | Makes and checks identity tokens, good and bad. |
access-lint | tool | Checks an action document, grants and an options answer. |
fake-pdp | tool | A test PDP for a service and for the runner. |
access-conformance | tool | Runs the series U, D and E against a target. |
reference-service | reference program | The test subject of the series U (a PEP). |
reference-edge | reference program | The test subject of the series E (an edge). |
Common rules
| Option or code | Meaning |
|---|---|
--help, -h | Show the usage and exit with 0. |
--version, -V | Show the name and the version of the program. The five tools add the line Apache-2.0. |
| Exit code 0 | No finding. The check passes. |
| Exit code 1 | A finding, a bad key, a failed case. For fake-pdp and the reference programs: the port cannot open. |
| Exit code 2 | The 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-configprints the value that applies for each key and its source, and hides each secret. - No program has TLS code. The tools speak plain
httpand refuse anhttpsURL. Production needs TLS from another layer. The libraryprocurauth-pephas the optional featuretlsfor 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,alphabetandchecksum. The memberchecksum.coversis optional:random, the default, orprefix_and_random. - Output
- Text:
good, the SHA-256 digest of the text in lower-case hexadecimal, and a hint of 4 characters at most. Orbad: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.
keycheck [--format text|json] <format-file>{ "prefix": "mcp_", "length": 53, "alphabet": "A-Za-z0-9", "checksum": { "algorithm": "crc32", "encoding": "base62", "characters": 6 }}$ keycheck format.json < key.txtgoodsha256: 0765d2f5a64bd1a2cb6d9ec22708e772e64e6191b60d06d290644c1ea49d75d3hint: Ky9P$ echo $? 0$ keycheck format.json < key.txtbad: length (expected 53 characters, found 47)$ echo $? 1{"verdict":"bad","cause":"length","message":"length (expected 53 characters, found 47)","detail":{"expected":53,"found":47}}Real output of 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
makesigns a token, or makes a bad token to test a service.checkruns 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
makewrites the token on the standard output.checkwrites the name of the check,ok,failorskip, and a detail. A failed line ends with the rule.--format jsonis 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 lateiat, a latenbf, a long life or an absent claim: write it in the claims file. Use--allow-bad-claimsto make a token with an absent claim. --number-form CLAIM=FORMwrites the number ofiat,expornbfwith a fraction, an exponent or a sign. The forms arefraction,exponentandnegative. The value stays the same, and protocol 9.3 refuses each form.--algacceptsEd25519,ES256, and, to make bad tokens,EdDSA,HS256,RS256andnone. The tool always signs with the real algorithm of the key.--typ,--kid,--critand--bad-signaturemake the other defects of 9.2 to 9.4. A token without--kidfails against a configuration of two keys.
Limits
- By default,
makerefuses 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 incrates/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-AuthorizationandCookieas the token header (9.4).
Schemas: access-token-config.schema.json, identity-token-claims.schema.json.
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]$ 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$ 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 $? 1The 14 checks of access-token check
| Check | Rule | The check passes when |
|---|---|---|
structure | 9.4 | three parts in base64url; the header and the payload are JSON objects |
header | 9.4 | no crit member |
alg | 9.2 | Ed25519 or ES256 |
typ | 9.2 | JWT |
kid | 9.4 | the key set has a key for the token |
signature | 9.4 | good, with the key and the algorithm of the header |
claims | 9.3 | iss, sub, aud, iat and exp are there; iat and exp are JSON integers with digits only |
iss | 9.4 | the issuer of the configuration |
sub | 9.3 | a string that is not empty |
aud | 9.4 | the id of the service, or an array that holds it |
iat | 9.4 | not later than the clock plus the skew |
exp | 9.4 | the clock is not later than exp plus the skew |
nbf | 9.4 | no nbf, or an nbf that is not later than the clock plus the skew |
life | 9.4 | exp minus iat is not more than the maximum age |
Real output of 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
httpURL. Optionally--grants FILE, the grants of one subject, and--options FILE, an answer of the options route or an envelope withqueryandanswer. - Output
- One line for each finding: the JSON path, the rule and a short text. A warning has the mark
warning:.--format jsonadds 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_pluralandbudget_unit_singularcheck theunitof a limit (6.1). The unit of a ceiling is a plural noun, for examplerows. The unit of a budget is a singular noun, for examplerequest. The test is a heuristic, so the finding is a warning. - The tool fetches an
httpURL only, with one GET. It has no TLS code and refuses anhttpsURL 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.
access-lint [--format text|json] [--grants FILE] [--options FILE] <document>$ 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$ access-lint good-actions.jsongood-actions.json: no finding$ echo $? 0access-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 $? 2Real output of 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 versionfake-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,clockandmetadata. The test modeconfirm_allmakes each action exceptaccessandmcp.sessionneed an approval. The examplecrates/fake-pdp/examples/datastore.jsonis 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/evaluationandPOST /access/v1/evaluations.GET /.well-known/authzen-configuration. The metadata always has the five membersprocurauth_usage_max_seconds,procurauth_idle_max_seconds,procurauth_evaluations_max_bytes,procurauth_evaluations_max_itemsandprocurauth_directory_max_age_seconds(defaults 5, 30, 1,048,576, 100 and 1). The data-file keymetadata.directory_max_age_secondssets the last one (3.9, 10.7b). The metadata also has the twelve membersprocurauth_approval_*of 17.4a.POST /approval/v1/requests,GET /approval/v1/requests/{id}andPOST /approval/v1/requests/{id}/keepalive: the approval API of 17.4. A request with no credential, or with an unknown credential, gets HTTP 401 withunauthorized.- The admin endpoints, with
--adminonly.
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
--formatoption. A body aboveprocurauth_evaluations_max_bytesgets HTTP 413, and more items thanprocurauth_evaluations_max_itemsget 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.
fake-pdp [--listen ADDRESS:PORT] [--clock-start SECONDS] [--admin] [--credential-file FILE] [--failures FILE] [--workers N] [--print-config] <data-file>$ 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{ "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 } }}$ 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
| Flag | Default | Meaning |
|---|---|---|
--listen ADDRESS:PORT | 127.0.0.1:8181 | The listener. Port 0 chooses a free port. |
--clock-start SECONDS | the system clock | Fix the clock. It then moves only through the admin endpoint. |
--admin | off | Enable the admin endpoints under /__fake/. |
--credential-file FILE | no credential | The PDP then requires Authorization: Bearer from the PEP. |
--failures FILE | none | More failures, with the kinds close, invalid_json, no_units and submit_*. |
--workers N | 8 | Worker threads, 1 to 256. One open connection uses one thread. |
--print-config | off | Check all the files, print the value of each key with its source, and exit with 0. |
Admin endpoints
| Request | Effect |
|---|---|
GET, POST /__fake/clock | Read the clock, or move it with {"advance": N} or {"set": T}. |
PUT /__fake/load | Replace the directory, the counters, the failures, the clock and the credentials with a data file. |
POST /__fake/reset | Put the counters back to their first values. |
GET /__fake/counters | The counters of the current windows. |
GET, DELETE /__fake/log | The last 10,000 questions with their answers, or remove them. |
GET, POST /__fake/failures | Read the failure rules, or replace all of them. |
GET /__fake/approvals | All the approval requests, with all their members. |
POST /__fake/approvals/{id}/answer | The answer of the owner: {"decision": "approve"} or {"decision": "decline"}. |
POST /__fake/approvals/{id}/reply | The owner asks the agent a question. |
POST /__fake/approvals/{id}/cancel | Cancel a request that waits, or an approval that nobody consumed. |
POST /__fake/approval-refs | Register an approval_ref of an agent. |
The 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
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 versionaccess-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-dirand--print-config.- Output
- One line for each case: the id,
pass,fail,warnorskip, the paragraphs and a text. A summary line ends the run.--format jsonwrites one document (schemaconformance-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
httpand no path. The tool refuses anhttpsURL. - 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.
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]$ 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 $? 0error: 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 $? 2Real output of 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
datastoreexample 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 withprocurauth-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 examplefake-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 /healthgives the textok. It needs no token and asks no question (10.1c). - The route
GET /static/about.txtruns no action of the action document. The service asks the actionaccesson the service for it (10.1c). - The MCP tools include
append_rows(actiondata.append) andget_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.urltakes anhttpURL only, and it needspdp.allow_plain_http. A deployment builds its own service with the library. It gives the libraryTlsTransport(featuretls) or another transport with TLS. - It keeps its data in memory. A write changes it for the life of the process.
- Its
cache_ttl_secondsis 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.
reference-service [--print-config] <config-file>$ 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 $? 0Actions and limits of the service
| Action | Types | Limits |
|---|---|---|
data.read | service, host, database, table | requests, max_rows, max_duration |
data.write | service, host, database, table | requests, max_duration |
data.inspect | service, host, database, table | none |
data.append | service, host, database, table | requests |
mcp.session | service | none (the key mcp_session_budget adds the budget requests) |
Real output of 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 versionreference-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 actionaccesson 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
_envand_fileforms 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.
reference-edge [--print-config] <config-file>$ 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 $? 0The refusals of the edge
| Case | Answer |
|---|---|
No Authorization: Bearer, or an empty text | HTTP 401, WWW-Authenticate: Bearer, empty body |
A bad form, a key that the edge does not know, or a subject with no access | HTTP 401 with error="invalid_token", empty body, the same for each cause |
| No valid answer of the PDP | HTTP 503, empty body |
| No answer of the service | HTTP 502 or 504, empty body |
Real output of 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 versionReference 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
| Step | What the PEP does | Where |
|---|---|---|
| 1 | Check the identity token, and send sub as the subject. | Pep::authenticate |
| 2 | Refuse a request with no valid token. | Refusal::to_http |
| 3 | Give each use one action and one resource with its chain. | Operation, ActionDocumentBuilder |
| 4 | Ask the PDP. Keep answers for cache_ttl at most. | Pep::decide, Pep::check, Pep::display |
| 5 | Send context.usage for a use of an action that lists a budget. | Pep::decide |
| 6 | Apply each ceiling of context.limits. | Ceilings |
| 7 | Map each refusal with 10.3. | Refusal::to_http |
How a refusal maps to HTTP
| Answer of the PDP | Refusal | HTTP |
|---|---|---|
false, no reason or another reason | Forbidden | 403 |
false with budget_exceeded | RateLimited | 429 with Retry-After |
| No answer, an HTTP error, or an answer that is not valid | Unavailable | 503 |
false with a reason of 17.1, for a route that cannot wait | Forbidden | 403 with {"error":"approval_cannot_wait"} |
true with no units for a use, or with a ceiling that the action does not list | Forbidden | 403 |
| No valid identity token | Unauthenticated | 401 |
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_approvalfollows the steps of 17.7 for a call that can wait. The moduleapprovalgives the calls, the verdicts and the refusals of binding 5.7a.Pep::approval_statscounts what the PEP received from the approval API. The MCP helpers give the result of binding 5.7 and the toolget_action_status.Pep::decide_route_without_actionserves a route that runs no action, for example a static file. It asks the actionaccesson the service (10.1c). A health-probe route asks nothing.token_cache_max_entriesabove 0 keeps the results of the token checks (9.7). A kept result serves untilexpplus the clock skew. The default 0 keeps no result.- The PEP reads
procurauth_directory_max_age_secondsfrom the metadata, for its logs only (3.9). Operation::also_allandIdentity::from_checked_tokenhelp 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
[dependencies.procurauth-pep]git = "https://github.com/ProcurAuth/procurauth"tag = "v1.1"# features = ["tls"] for the link over TLSThe crate is in the workspace of the repository and is not on crates.io. It needs Rust 1.89 or later.
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.
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.