[Feature] : API ENDPOINTS PR 2: Auth#1131
Open
pulk17 wants to merge 3 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).
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.



Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Feature: Auth and Token Management Endpoints (PR 2/6)
Executive Summary
This Pull Request is Part 2 of 6 in the initiative to introduce a fully-featured JSON REST API (superseding #1117).
Building directly upon the foundational middleware and models established in PR 1, this PR introduces the highly critical Authentication and Token Lifecycle Management Endpoints. It exposes secure APIs for CI clients and third-party integrations to dynamically generate, list, and revoke their own access tokens, enforcing the principle of least privilege through scoped access controls.
Architectural Additions & Enhancements
1. Route Controllers (
mod_api/routes/auth.py)This PR mounts the authentication router at
/api/v1/auth/tokensand introduces the following operations:POST /(Generate Token):system:readscope, whereas Platform Administrators can request elevated scopes such asbaselines:write.GET /(List Tokens):?all=trueto view active tokens across the entire platform.DELETE /<token_id>(Revoke Specific Token):DELETE /current(Revoke Active Token):2. Request & Response Validation (
mod_api/schemas/auth.py)TokenCreateSchema: Validates incoming payloads for token generation, enforcing strict regex constraints on token names and validating requested scopes against system defaults.TokenResponseSchema: Defines the serialization contract for token representations, ensuring that hashed secrets never leak into JSON responses.3. Blueprint Integration
auth_routesBlueprint into the mainmod_api/__init__.pyrouter, officially exposing the endpoints to the application.Testing & Quality Assurance
This PR maintains strict code quality and has been heavily tested in isolation:
test_routes_auth.pyspecifically targeting token creation logic, RBAC boundary enforcement, and edge cases (e.g., duplicate names, invalid credentials). All 46 applicable tests pass perfectly.isort(fixed),pydocstyle,pycodestyle, andmypypass without errors.Next Steps
Following the review and merge of this PR, PR 3 (System Status & Run Management) will be submitted. It will introduce the system queue and CI run management routes, along with the full suite of middleware integration tests.