Skip to main content

Canonical Veltro suite auth contract: Auth.js session decode + suite-service token mint/verify.

Project description

veltro-suite-auth

The canonical Veltro suite auth contract — one published Python package for the two cross-service security primitives shared across the Veltro suite (VectorFlow, CHAD, WARDEN). Before this package each app carried its own byte-identical copy of the decoder/verifier; CHAD and WARDEN now depend on this package and carry none.

What it provides

  • veltro_suite_auth.session — decode VectorFlow's Auth.js v5 session cookie (JWE, alg=dir / enc=A256CBC-HS512, HKDF-SHA256 key salted by the cookie name) for delegated suite login.
    • decode_session(cookies, secret) -> SessionClaims | None
    • SessionClaims, SessionError / SessionInvalid / SessionExpired
    • SESSION_COOKIE_NAMES, derive_encryption_key
  • veltro_suite_auth.service_token — mint + verify the short-lived (60s), scoped, HS256 suite-service token used for machine-to-machine calls between suite apps (issuer veltro-suite, audience suite-service).
    • mint_service_token(secret, *, scope, svc, actor_email=None, actor_suite_role=None) -> str
    • verify_service_token(token, secret, required_scope) -> ServiceTokenClaims
    • ServiceTokenClaims, ServiceTokenError / ServiceTokenInvalid / ServiceTokenExpired
    • SUITE_SERVICE_ISSUER, SUITE_SERVICE_AUDIENCE, SUITE_SERVICE_MINTERS, SUITE_SERVICE_TOKEN_TTL_SECONDS
  • veltro_suite_auth.testing — golden cross-language vectors, shipped in the wheel: session_fixture(), service_token_vectors().

All decode/verify behavior (including the suite_role fail-open-to-viewer semantics, family-aware scope satisfaction, and the optional svc/actor claims) is preserved exactly from the original CHAD/WARDEN implementations.

Contract source & rename map

The code was moved verbatim from CHAD's backend/app/core/vf_session.py and backend/app/core/suite_service_token.py, plus WARDEN's minting logic from backend/app/services/suite_token.py. Only symbol names and CHAD/WARDEN-specific docstring prose changed:

old (CHAD / WARDEN) new (veltro_suite_auth)
decode_vf_session decode_session
VfSessionClaims SessionClaims
VfSessionError / VfSessionInvalid / VfSessionExpired SessionError / SessionInvalid / SessionExpired
SESSION_COOKIE_NAMES, derive_encryption_key unchanged
verify_suite_service_token verify_service_token
SuiteServiceClaims ServiceTokenClaims
SuiteServiceTokenError / ...Invalid / ...Expired ServiceTokenError / ServiceTokenInvalid / ServiceTokenExpired
SUITE_SERVICE_ISSUER / SUITE_SERVICE_AUDIENCE / SUITE_SERVICE_MINTERS unchanged
WARDEN mint_suite_service_token(scope) (settings-coupled) mint_service_token(secret, *, scope, svc, ...) (explicit params)

Cross-language conformance

The suite has a TypeScript minter (VectorFlow's src/server/services/suite/service-token.ts) and this Python decoder/verifier. Two per-PR gates in the VectorFlow repo keep them from drifting:

  • suite-auth-contract CI job — installs this package and runs its tests, including tests/conformance/test_fresh_session_roundtrip.py, which shells node scripts/mint-test-session.mjs to mint a fresh Auth.js cookie and decodes it here. Catches VF-minter ⟂ Python-decoder drift on the session cookie.
  • contract-vectors.test.ts — pins the committed vectors/service-token-vectors.json against the live TS minters (mintSuiteServiceToken / mintSuiteExternalToken). Catches TS-minter drift on the service token; the Python side of the same vectors is asserted by tests/test_vectors.py.

Regenerating the vectors

  • session-fixture.json — a fixed Auth.js cookie. Regenerate with VectorFlow's script (from the repo root):

    node scripts/mint-test-session.mjs > packages/suite-auth-py/src/veltro_suite_auth/vectors/session-fixture.json
    
  • service-token-vectors.json — the four suite-service token vectors (settings:read, settings:write with actor; external:read, external:write without actor), captured from the real TS minters under a frozen clock. Regenerate with (from the repo root):

    EMIT_CONTRACT_VECTORS=1 pnpm vitest run src/server/services/suite/__tests__/contract-vectors.test.ts
    

Local development

# from packages/suite-auth-py/
python3.11 -m venv .venv && . .venv/bin/activate
pip install -e . pytest
pytest -v            # conformance test needs `node` + a repo checkout, else it skips

Manual publish (after merge to main)

There is no publish workflow — publishing is a manual step by the maintainer (matching the design system's manual-npm-publish precedent). From a clean checkout of main:

cd packages/suite-auth-py
uv build            # or: python -m build
uv publish          # or: twine upload dist/*   (needs a PyPI token)

Never republish an existing version — ship a new 0.1.x for any fix.

Project details


Download files

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

Source Distribution

veltro_suite_auth-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

veltro_suite_auth-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file veltro_suite_auth-0.1.0.tar.gz.

File metadata

  • Download URL: veltro_suite_auth-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for veltro_suite_auth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f295423aed3a6c7809b739767c2b3228625b4f8e15728ca14523753390d0a593
MD5 5427e08b0eb58067bdc047b5e8587449
BLAKE2b-256 89b9bcc0b2f2698374a8dff1937ea4d72746cd41a76f8faa97ad8b50b07edf44

See more details on using hashes here.

File details

Details for the file veltro_suite_auth-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: veltro_suite_auth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for veltro_suite_auth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8f59b51c37a6c42966c130032e10c13c182ecc758097c1133d8547e0de66323
MD5 aa575b3174d39b5c889b6e7d193e4b2f
BLAKE2b-256 c277fb0c51f79a6b153e834925a257f2b34bf0d71e56cd2f9de8ee23883155df

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