Quick-start notes for any agent touching this repo.
- Rust service offering Traefik forward-auth plus API token CRUD.
- Tokens live in Valkey as blake3 hashes; Lua keeps user/token sets in sync.
- OAuth2 resource server (tower-oauth2-resource-server 0.8.0) secures the admin API and provides self-service user flows.
cargo checkfor fast validation.cargo clippyandcargo clippy --testfor linting.cargo fmtfor formatting.cargo testto run tests.cargo run(config viaPORT,ADDRESS,VALKEY_URL, orCONFIG_FILE).
config.rs: load settings from env +settings.tomlwithconfique.storage.rs: Valkey CRUD for tokens (auth:token:{hash}+auth:user_tokens:{sub}), includes Lua delete script.http.rs: Axum HTTP layer (/health/*,/api/users/{sub}/tokens,/forward-auth, docs at/docs).auth.rs: wraps tower-oauth2-resource-server, builds claim helpers, and exposes middleware/extractors for admin & user endpoints.
- Configure
oauth.issuer_url(oroauth.jwks_url) plus anyoauth.audiencesto enable validation; the service will refuse to start without a usable resource-server setup. oauth.claims.subjectselects the claim that becomes the usersub;oauth.claims.groups&oauth.admin.groupcontrol admin gating (case-sensitivity toggles available).- Admin token management lives at
/api/users/{sub}/tokensand requires the configured admin group to pass validation. - Authenticated users may manage their own tokens via
/api/me/tokensand/api/me/tokens/{id}(subject derived from the validated JWT). - Forward-auth remains standalone and does not participate in OAuth2 validation.
- Needs Valkey on
localhost:6379. - Existing tests cover happy-path and edge cases; keep new ones serial.
- KISS: keep it simple, stupid.
- Prefer clarity over cleverness.
- Always run cargo clippy and cargo fmt to check that you did things correctly.
- Things must be tested. Run cargo test to check. Running the tests in the sandbox requires elevated privilege I guess ($ /bin/zsh -lc 'cargo test'), with a longer timeout than the default one.