Skip to main content

auth — RBAC authorization service

CI Python License: MIT

Role-based access control over HTTP. auth answers one question — may user X do Y — so your services don't reinvent roles and permissions.

It is authorization, not authentication: it does not log anyone in, store passwords, or issue tokens. It trusts that the caller already knows who the user is, and decides what they may do. Model: user → (member of) → role → (holds) → permission.

Quickstart

Your client key is any UUID4 — it is also your private, isolated namespace. Generate one, keep it secret, and reuse it for every call. A role must exist before you add members or permissions to it.

KEY=$(python3 -c "import uuid; print(uuid.uuid4())")
BASE=https://auth.rodmena.app

curl -X POST -H "Authorization: Bearer $KEY" $BASE/api/role/engineers
curl -X POST -H "Authorization: Bearer $KEY" $BASE/api/permission/engineers/deploy
curl -X POST -H "Authorization: Bearer $KEY" $BASE/api/membership/alice/engineers
curl        -H "Authorization: Bearer $KEY" $BASE/api/has_permission/alice/deploy
# -> {"success": true, "data": {"has_permission": true}, ...}

With the Python client (pip install auth):

from auth import Client

with Client(api_key=KEY, service_url="https://auth.rodmena.app") as c:
    c.create_role("engineers")
    c.add_permission("engineers", "deploy")
    c.add_membership("alice", "engineers")
    c.user_has_permission("alice", "deploy")   # -> {... "has_permission": true}

Things to know before you write code

  • Writes can return HTTP 200 with {"result": false} (e.g. adding to a missing role). Check the result/data field, not just the status code.
  • Two response shapes — bare {"result": ...} and wrapped {"success", "data", ...}. The API reference says which per endpoint.
  • Errors below 2xx are HTML, not JSON. Branch on the status code first.
  • Python client: check success before reading data. On transport failure the client does not raise by default — it returns {"error", "success": False, "transport_error": True, "data": {...}} where data only echoes your inputs and does NOT contain the answer field (has_permission, count, ...). Reading data blindly turns an outage into a false "no". Pass Client(..., raise_on_error=True) to get an AuthTransportError exception instead of the error dict.
  • Reuse one key. A new key is a new empty namespace, not an error. Keep the key out of source control, logs, and URLs — it is the only thing protecting your data. Rotate it with POST /api/keys/rotate if it leaks.
  • Per-user API keys (2.4.0): /api/apikeys/user/<user> (create/list), /api/apikeys/user/<user>/<key_id> (revoke), /api/apikeys/validate. auth mints rak_... secrets for your users, shows each exactly once, stores only a hash, and validates them inside your namespace — an identity UI fronts the lifecycle, backends validate then use the RBAC checks. Client methods: create_api_key, list_api_keys, revoke_api_key, validate_api_key, check_api_key_permission (validate + permission in one round trip), plus get_settings/set_strict_users. All of these also exist on the in-process Authorization wrapper for embedded consumers.
  • DEPRECATED — bare user strings. Asserting a <user> that no validated API key backs is scheduled for decommission. The opt-in phase is live (2.5.0): PUT /api/settings {"strict_users": true} makes keyless users answer negatively (user_not_key_backed), and POST /api/apikeys/check_permission does validate + permission in one round trip. 3.0.0 makes strict identity the default (the audited per-tenant opt-out survives for validated machine-subject architectures) — and ships only after every consuming platform confirms. Details: docs/DEPRECATIONS.md.

Documentation

Doc What's in it
Live API reference/docs · /llms.txt Every endpoint and exact response shape, served by the app (agent-friendly).
docs/ARCHITECTURE.md Design, components, request lifecycle, data model, permission-check and key-rotation flows, diagrams.
SECURITY.md Security model (tenant isolation, encryption, audit, rotation), threat notes, reporting.
MIGRATIONS.md Schema creation vs migrations, upgrade/rollback runbook.
CONTRIBUTING.md Local setup, tests (sqlite + postgres), lint/type-check, CI.
docs/ Full Sphinx docs (concepts, configuration, encryption, deployment, REST & Python usage).

When to use — and not

Use it for RBAC: named roles, permissions, group membership, and boolean "can user X do Y" gates for a service, CLI, or workflow engine.

Not for authentication (login/passwords/sessions/OAuth/JWT), fine-grained / attribute-based rules (owner-of-this-record, time-of-day, row-level tenancy — reach for an ABAC/policy engine), or air-gapped hot loops where a network hop per check is too costly (cache, or use the library in-process).

Development

python3.11 -m venv .venv && . .venv/bin/activate
pip install -e ".[dev,ratelimit,migrations]"
make check   # ruff + mypy
make test    # sqlite suite
make test-postgres   # postgres integration (Docker), encryption on

See CONTRIBUTING.md for the full workflow. Licensed under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auth-2.5.2.tar.gz (94.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auth-2.5.2-py3-none-any.whl (67.8 kB view details)

Uploaded Python 3

File details

Details for the file auth-2.5.2.tar.gz.

File metadata

  • Download URL: auth-2.5.2.tar.gz
  • Upload date:
  • Size: 94.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.14

File hashes

Hashes for auth-2.5.2.tar.gz
Algorithm Hash digest
SHA256 b2bebe8f8f2836487b2dbad6220183e722c8d423e1d5b04c18929f8119b13c45
MD5 42be2fb18c5ccbec197d1087d44f01cd
BLAKE2b-256 e90d024f043fdd81095f904f88aec67a3d29de3e6b4ef6918f12852bdc9ecda2

See more details on using hashes here.

File details

Details for the file auth-2.5.2-py3-none-any.whl.

File metadata

  • Download URL: auth-2.5.2-py3-none-any.whl
  • Upload date:
  • Size: 67.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.14

File hashes

Hashes for auth-2.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5e4e2e88179bc90784c6dca442cd6cfaeb4e9e9558f54a3752688f21b0a393b3
MD5 93f5e30108126f4266f5ea7c41d1731d
BLAKE2b-256 9d00eccff5da8c1d126e07651b62cd9a1b6612aa7559c0930de10f824c2f2993

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page