[Feature] : API ENDPOINTS PR 2: Auth#1131
Open
pulk17 wants to merge 4 commits into
Open
Conversation
cfsmp3
requested changes
Jun 24, 2026
cfsmp3
left a comment
Contributor
There was a problem hiding this comment.
Missing tests:
- Rate limiter still untested (tests bypass it via TESTING + _rate_limit_store.clear()). The 5/15min create limit is unverified.
- H4 fix (500→JSON) still unverified — no test forces a real route 500.
Bug:
- Non-admins can still request tokens:manage scope (harmless given role gates, but loose).
99fa8c1 to
f409134
Compare
|
This was referenced Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



[FEATURE]
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Auth and token management endpoints (PR 2/6)
Summary
Part 2 of 6 (supersedes #1117). Builds on the middleware and
ApiTokenmodelfrom PR 1 (#1130) to add the token lifecycle: create, list, revoke.
Endpoints (
mod_api/routes/auth.py, mounted at/api/v1/auth/tokens)POST /— create token. Public (the only public endpoint besides/system/health); authenticates with email + password, rate-limited 5/15minby IP, and returns the plaintext token once. Scope grants are role-based:
every authenticated role may request
runs:read,runs:write,results:read,system:read;tokens:manageandbaselines:writeare admin-only.Default scopes when none are requested:
runs:read,results:read.GET /— list tokens. Requirestokens:manage(so, in practice, admin).Returns the caller's tokens (admins may pass
?all=true). Metadata only —never the plaintext or hash; revoked/expired tokens are included with an
is_revokedflag.DELETE /current— self-revoke. Scope-free by design: any valid token mayrevoke itself.
DELETE /{token_id}— revoke by ID. Owners revoke their own; admins revokeanyone's. Non-owners get a uniform 404 to prevent token-ID enumeration.
Validation (
mod_api/schemas/auth.py)TokenCreateRequestSchemais strict (unknown=RAISE): validated email,password length,
token_nameregex,expires_in_days(1–30), scope whitelist.Response schemas never serialize the hash.
Notes for reviewers
side-channel.
exercise exist.
Testing
New tests for token creation, RBAC boundaries, and edge cases (duplicate name,
bad credentials). Lint/type clean.
Next
PR 3 (#1132): system status and run management.