| Field | Value |
|---|---|
| Status | Accepted |
| Author | Paul / Claude |
| Date | 2026-02-08 |
| PR | #44 |
The Next.js web application was initially built with an API key authentication layer consisting of:
- Login page (
/login) requiring API key input - Middleware enforcing authentication on all routes
- Cookie-based session management
- Logout functionality
However, the FastAPI backend has require_auth: bool = False by default (apps/api/config.py:29), meaning the API does not require authentication in development mode. When require_auth is disabled, the API's authentication dependency returns "anonymous" without validating any credentials.
This created a misalignment where:
- Web app: Always enforces authentication (login required to access any page)
- API: Does not require or validate authentication by default
Users must "log in" with an API key to access a web UI that communicates with an open API, creating unnecessary friction without providing actual security.
Remove the web authentication layer entirely from the Next.js application, including:
- Login page (
apps/web/app/login/page.tsx) - Middleware authentication checks (
apps/web/middleware.ts) - Logout button component (
apps/web/components/logout-button.tsx) - API key cookie management in
api-client.ts - 401 redirect logic in the API client
-
API is open by default: The backend does not enforce authentication in development mode, making web-layer auth security theater
-
Development/demo platform: This application is:
- Migrated from Streamlit (which had no authentication)
- Used for stakeholder demos (Gradio app on HF Spaces is public)
- Intended for development and exploration
-
No security requirements: CLAUDE.md and project documentation do not specify security requirements or sensitive data handling
-
Better UX: Removing unnecessary login friction improves the developer and demo experience
-
Authentication framework preserved: The API retains its authentication module (
apps/api/auth.py,apps/api/routers/auth.py) for future use when/if authentication is needed
If the platform moves to production or handles sensitive data, authentication can be re-enabled by:
- Setting
CREDIT_RISK_REQUIRE_AUTH=truein API environment - Providing valid API keys via
CREDIT_RISK_API_KEYS="key1,key2" - Re-implementing web authentication (middleware, login page) if needed
- Using the existing
/auth/verifyendpoint
The API's auth infrastructure remains intact for this purpose.
- Simpler UX: Users can access the web app immediately without authentication barriers
- Consistency: Web app behavior now matches API authentication posture
- Less code: Removed ~100 lines of auth-related code
- Clearer intent: Application is explicitly positioned as a development/demo tool
- No access control: Anyone with network access can use the application
- Mitigation: This is already the case with the open API; web auth was not providing security
- Must rebuild auth for production: If security is needed later, web authentication must be re-implemented
- Mitigation: API auth framework is preserved; web auth can be quickly restored using git history
- API authentication unchanged: The backend's auth module remains available but unused (can be enabled via environment variables)
- Gradio app unchanged: The Gradio demo app did not use authentication; remains unaffected
Set require_auth = True and provide API keys to secure the backend.
Rejected because:
- Adds complexity for development/demo use cases
- No clear security requirement or threat model
- Would still require distributing API keys to demo users
Check API's auth status and conditionally show login page.
Rejected because:
- Added complexity without clear benefit
- Still requires maintaining auth infrastructure
- Authentication should be all-or-nothing, not configurable per-layer
Rely on web-layer authentication only.
Rejected because:
- API endpoints remain directly accessible, bypassing web auth
- Creates false sense of security
- Web auth cannot protect API without backend enforcement
- apps/api/config.py - API authentication configuration
- apps/api/auth.py - API authentication module (preserved)
- CLAUDE.md - Project guidelines (no security requirements specified)
Changes made in PR #44:
Deleted files:
apps/web/app/login/page.tsx(87 lines) - Login form componentapps/web/middleware.ts(22 lines) - Route authentication enforcementapps/web/components/logout-button.tsx(24 lines) - Logout button
Modified files:
apps/web/components/layout/header.tsx- Removed<LogoutButton />from headerapps/web/lib/api-client.ts- Removed:getApiKey()function- API key cookie reading
- Authorization header injection
- 401 redirect to
/login
Preserved (for future use):
apps/api/auth.py- Authentication dependencyapps/api/routers/auth.py-/auth/verifyendpoint- API configuration:
require_auth,api_keyssettings
Testing:
- Manual verification: Web app loads without login redirect
- API calls succeed without Authorization headers
- All pages (Train, Predict, Compare) accessible directly