Issue Type
Other: auth boundary cleanup
Description
app/utils/get_principal.py currently handles too many responsibilities in one place:
- FastAPI header handling
- bearer token parsing
- principal creation
- demo auth mapping
- HTTP error handling
This makes the authentication flow harder to reuse and harder to extend later.
A small shared token-decoder interface would improve separation of concerns while keeping the current demo authentication behaviour unchanged.
Steps to Review
- Open
app/utils/get_principal.py
- Review
get_current_principal
- Observe that FastAPI request handling and auth logic are mixed together
Expected Behaviour
Authentication logic should be separated from FastAPI request handling.
Current Behaviour
Token parsing, principal creation, and HTTP handling are all combined in one function.
Additional Context
Proposed Scope
- Add a small shared token-decoder interface
- Move token parsing and principal creation into shared auth logic
- Keep
get_current_principal focused on FastAPI boundary handling only
- Preserve the current demo-token behaviour
Out of Scope
- JWT validation
- Password hashing
- Database authentication
- Role redesign
- Security framework changes
Acceptance Criteria
- A small shared auth/token interface exists
- Token parsing no longer depends directly on FastAPI classes
get_current_principal becomes a thin FastAPI adapter
- Existing demo-token behaviour remains unchanged
Possible Solution
Create a small token-decoder service that returns Principal objects from bearer tokens, while keeping FastAPI request extraction and HTTP exceptions inside get_current_principal.
Environment
- OS: N/A
- Browser: N/A
- Version: current
main branch
Issue Type
Other: auth boundary cleanup
Description
app/utils/get_principal.pycurrently handles too many responsibilities in one place:This makes the authentication flow harder to reuse and harder to extend later.
A small shared token-decoder interface would improve separation of concerns while keeping the current demo authentication behaviour unchanged.
Steps to Review
app/utils/get_principal.pyget_current_principalExpected Behaviour
Authentication logic should be separated from FastAPI request handling.
Current Behaviour
Token parsing, principal creation, and HTTP handling are all combined in one function.
Additional Context
Proposed Scope
get_current_principalfocused on FastAPI boundary handling onlyOut of Scope
Acceptance Criteria
get_current_principalbecomes a thin FastAPI adapterPossible Solution
Create a small token-decoder service that returns
Principalobjects from bearer tokens, while keeping FastAPI request extraction and HTTP exceptions insideget_current_principal.Environment
mainbranch