Authentication Service
Relevant source files
The following files were used as context for generating this wiki page:
The Authentication Service is a fundamental component of the AI Anomaly Detection system, responsible for managing user identities, securing access to administrative tools, and maintaining a clear audit trail for human feedback. Its primary purpose is to differentiate between standard users and administrative reviewers who audit AI-generated medical advice for safety and factuality risks.
The service facilitates secure access to the "Watchtower UI," where administrators can ingest logs, run multi-stage anomaly detection pipelines, and provide human labels (SAFE/UNSAFE/BORDERLINE) on flagged interactions. It ensures that sensitive clinical risk data is only accessible to authorized personnel, preventing unauthorized access to the system's internal scoring and RAG-backed explanation records.
Sources: AI Service/plan.md, backend/README.md
System Architecture and Integration
The Authentication Service sits at the perimeter of both the backend API and the frontend management portal. It integrates directly with the logging layer to associate user_id and reviewer_id with specific interaction and feedback records.
This diagram illustrates the flow of a user through the authentication layer to access protected administrative functions and logging data.
Sources: AI Service/plan.md:10-50, backend/test_enhanced_endpoints.py:15-25
Administrative Access Control
Access to the enhanced anomaly detection system is restricted via Bearer tokens. The system supports specialized roles, particularly for the Human Feedback Loop, where reviewers must be identified to track accountability for safety labels and corrected AI responses.
| Component | Responsibility | Relevant Fields |
|---|---|---|
| Admin User | High-level management and system configuration. | email, username, password |
| Reviewer | Experts who verify AI safety and provide corrections. | reviewer_id, human_label |
| Token System | Issues JWT or similar Bearer tokens for API authorization. | Authorization: Bearer <TOKEN> |
Sources: backend/README.md:10-15, AI Service/plan.md:50-65, backend/test_enhanced_endpoints.py:20-22
Data Schemas and Identity Tracking
The system tracks identity through various data structures to ensure every action in the anomaly detection pipeline is attributed to a specific entity.
Interaction Log Identity
The InteractionLog schema captures basic user identification during the initial ingestion phase.
- user_id: String identifier for the user who prompted the AI.
- conversation_id: Tracks the session or thread identity.
Human Feedback Identity
The FeedbackRecord schema is critical for the "Human-in-the-Loop" stage, where expert reviewers audit the AI's behavior.
- reviewer_id: An optional identifier for the admin or clinician who reviewed the interaction.
- timestamp: ISO-8601 formatted time of the review.
Sources: AI Service/plan.md:14-25, 52-60
Frontend Implementation
The authentication interface is designed using a production-grade, split-screen layout that emphasizes brand identity on one side and functional form input on the other.
Layout and Aesthetics
The interface uses a linear-gradient branding panel with CSS animations (e.g., fadeInUp, slideInLeft) to create a professional administrative environment. The form panel supports error and success banners for real-time feedback during the login/registration process.
Sequence of the authentication flow leading to dashboard access.
Sources: frontend/src/components/auth/AuthLayout.css, frontend/src/components/auth/AuthForm.css
Security Interface Features
The authentication forms include several safety and usability features:
- Password Strength Indicator: Visual feedback with color-coded segments (Weak, Fair, Good, Strong).
- Social Login Support: Containers for third-party OAuth providers.
- Error Handling: Shake animations (
shakeX) on error banners to draw immediate attention to failed attempts.
Sources: frontend/src/components/auth/AuthForm.css:12-40, 160-200
Integration with Administrative Endpoints
Authenticated sessions are required to interact with the enhanced metrics and analytics endpoints. The ADMIN_TOKEN must be included in the headers for the following types of requests:
# Example of authenticated request setup
headers = {
"Authorization": f"Bearer {ADMIN_TOKEN}",
"Content-Type": "application/json"
}
Sources: backend/test_enhanced_endpoints.py:21-25
Protected Administrative Actions
- Log Ingestion: Loading interaction logs from files or APIs into the
LogAgent. - Anomaly Breakdown: Accessing multi-dimensional detection scores (Hallucination, Quality, Safety).
- Feedback Submission: Submitting
SAFEorUNSAFElabels to the SQLite database.
Sources: AI Service/plan.md:65-80, backend/test_enhanced_endpoints.py:48-90
Summary
The Authentication Service provides the necessary security infrastructure to support a medical safety "Watchtower." By managing administrative identities and securing the feedback loop, it ensures that only qualified reviewers can influence the scoring thresholds and RAG-grounded explanations used to monitor AI medical outputs. This service is the gateway to the system's hybrid scoring and future machine learning classifier training datasets.