Code Review Summary
Overall assessment: π’ Excellent foundation β architecture, typing, and provider implementations are production-quality. The following items should be addressed before v1.0.
π΄ High Priority
1. No FastAPI Adapter Tests
The FastAPI adapter is ~384 lines with error mapping, telemetry, OIDC dependency factory, and all Auth.* methods β all untested. This is the largest code gap.
2. No Django Ninja Adapter Tests
Same issue β no tests for any of the Ninja auth classes (ApiKeyAuth, FirebaseAuth, GoogleAuth, OIDCAuth).
3. Flask Adapter Stores client_secret in Session
flask/__init__.py stores the OAuth2 client secret in the Flask session. If sessions are cookie-based (even encrypted), this is a security risk. The secret is already available from the client_secrets_file and does not need to be stored in the session.
4. Flask Adapter Bypasses AuthService
The Flask adapter directly uses google-auth and google-auth-oauthlib instead of going through the Provider β Service β Adapter pattern. This is architecturally inconsistent with the other adapters.
π‘ Medium Priority
5. No Telemetry in Django Ninja Adapter
The FastAPI adapter has _log_failure() and _set_request_auth_context() for structured auth telemetry. The Ninja adapter silently swallows errors (except AuthError: return None) with no logging. Should at least log failures for observability.
6. AuthCascade Does Not Handle Exceptions
If an auth method raises an exception instead of returning None, the cascade stops with an unhandled error. The Ninja auth classes return None on failure so this works today, but it is fragile.
Suggested fix:
# Current (fragile):
for method in self.auth_methods:
result = method.authenticate(request)
if result is not None:
return result
# Safer:
for method in self.auth_methods:
try:
result = method.authenticate(request)
if result is not None:
return result
except AuthError:
continue
7. AuthPrincipal Model is Dead Code
core/models.py defines AuthPrincipal but it is never referenced in service, adapters, or tests. Either integrate it or remove it.
8. No Coverage Threshold in CI
Tests run with --cov but no --cov-fail-under. Adding --cov-fail-under=80 would prevent coverage regression.
9. CHANGELOG Missing Flask Adapter
The [0.1.0] entry mentions FastAPI and Django Ninja adapters but not the Flask adapter. The date 2024-01-01 also appears to be a placeholder.
π’ Low Priority / Nitpicks
| Issue |
Notes |
AuthCascade typed as list[Any] |
Could use list[Callable] for type safety |
No reset() for test isolation |
Module-level _service singleton in FastAPI adapter has no reset function |
| IAP provider is header-only |
Does not verify IAP JWT tokens β documented but should be noted more prominently |
| No token refresh in Flask adapter |
Access token expiry is not handled |
| Poetry version not pinned in CI |
pipx install poetry should pin a version for reproducibility |
GoogleTokenInfo.jlt field |
Unusual JWT claim name β is this jti? Worth documenting |
Test Coverage Summary
| Area |
Status |
| Models |
β
Good |
| Exceptions |
β
Good |
| Policies |
β
Good |
| Service |
β
Good |
| Cascade |
β
Adequate |
| All 6 Providers |
β
Good to Excellent |
| Flask Adapter |
β
Good |
| FastAPI Adapter |
β No tests |
| Django Ninja Adapter |
β No tests |
| Telemetry |
β No tests |
Recommendations
- Add FastAPI and Django Ninja adapter tests
- Fix the Flask session
client_secret storage
- Add telemetry to the Django Ninja adapter
- Add exception handling to
AuthCascade
- Add
--cov-fail-under=80 to CI
- Either use
AuthPrincipal or remove it
- Update CHANGELOG to include Flask adapter and correct the date
Code Review Summary
Overall assessment: π’ Excellent foundation β architecture, typing, and provider implementations are production-quality. The following items should be addressed before v1.0.
π΄ High Priority
1. No FastAPI Adapter Tests
The FastAPI adapter is ~384 lines with error mapping, telemetry, OIDC dependency factory, and all
Auth.*methods β all untested. This is the largest code gap.2. No Django Ninja Adapter Tests
Same issue β no tests for any of the Ninja auth classes (
ApiKeyAuth,FirebaseAuth,GoogleAuth,OIDCAuth).3. Flask Adapter Stores
client_secretin Sessionflask/__init__.pystores the OAuth2 client secret in the Flask session. If sessions are cookie-based (even encrypted), this is a security risk. The secret is already available from theclient_secrets_fileand does not need to be stored in the session.4. Flask Adapter Bypasses AuthService
The Flask adapter directly uses
google-authandgoogle-auth-oauthlibinstead of going through the Provider β Service β Adapter pattern. This is architecturally inconsistent with the other adapters.π‘ Medium Priority
5. No Telemetry in Django Ninja Adapter
The FastAPI adapter has
_log_failure()and_set_request_auth_context()for structured auth telemetry. The Ninja adapter silently swallows errors (except AuthError: return None) with no logging. Should at least log failures for observability.6.
AuthCascadeDoes Not Handle ExceptionsIf an auth method raises an exception instead of returning
None, the cascade stops with an unhandled error. The Ninja auth classes returnNoneon failure so this works today, but it is fragile.Suggested fix:
7.
AuthPrincipalModel is Dead Codecore/models.pydefinesAuthPrincipalbut it is never referenced in service, adapters, or tests. Either integrate it or remove it.8. No Coverage Threshold in CI
Tests run with
--covbut no--cov-fail-under. Adding--cov-fail-under=80would prevent coverage regression.9. CHANGELOG Missing Flask Adapter
The
[0.1.0]entry mentions FastAPI and Django Ninja adapters but not the Flask adapter. The date2024-01-01also appears to be a placeholder.π’ Low Priority / Nitpicks
AuthCascadetyped aslist[Any]list[Callable]for type safetyreset()for test isolation_servicesingleton in FastAPI adapter has no reset functionpipx install poetryshould pin a version for reproducibilityGoogleTokenInfo.jltfieldjti? Worth documentingTest Coverage Summary
Recommendations
client_secretstorageAuthCascade--cov-fail-under=80to CIAuthPrincipalor remove it