This document provides comprehensive guidance on authentication for the Vector Knowledge Base application, including setup, security best practices, and troubleshooting.
The application supports two authentication methods:
- HTTP Basic Authentication (Primary Method) - Simple, widely supported method that works across all modern browsers and API clients
- Replit Auth (Legacy Support) - Maintained for backward compatibility
- When a user attempts to access a protected endpoint, they will be prompted for credentials if not already authenticated
- Credentials are verified against environment variables set in Replit Secrets
- Upon successful authentication, a session is created to maintain the user's authenticated state
- Future requests use the session for authentication
The authentication system requires the following environment variables to be set:
| Variable Name | Description |
|---|---|
BASIC_AUTH_USERNAME |
The username for HTTP Basic Authentication |
BASIC_AUTH_PASSWORD |
The password for HTTP Basic Authentication |
SESSION_SECRET |
A random secret key used to encrypt session data |
-
Default credentials are provided for convenience in development:
- Username:
admin - Password:
changeme123
Important: These credentials should never be used in production.
- Username:
-
To customize, add the required environment variables to your Replit workspace:
- In the Replit UI, navigate to the "Secrets" tab in the Tools panel
- Add each of the required environment variables with appropriate values:
- Key:
BASIC_AUTH_USERNAME| Value: Your desired username - Key:
BASIC_AUTH_PASSWORD| Value: Your secure password - Key:
SESSION_SECRET| Value: A random string (at least 32 characters recommended)
- Key:
- Add the same environment variables to your Replit deployment environment:
- Navigate to your deployment
- Click on the three dots menu (⋮) in the top-right corner
- Select "Deployment Settings"
- Add the same environment variables that you set in your development environment
- Important: Deployment secrets are managed separately from development secrets
Replit requires secrets to be added to both environments separately. There is no automatic synchronization between development and deployment secrets.
To ensure consistency between environments:
- Make note of all secrets in your development environment
- Manually add the same secrets to your deployment environment
- If a deployment shows "secrets out of sync," it means you need to update the secrets in your deployment environment
For more details on secrets management, see the Replit Secrets Guide.
- Login:
/login- Form-based login page - Logout:
/logout- Clears the session and logs out the user
- Use Strong Credentials: Complex username and password combinations
- Change Secrets Regularly: Rotate your secrets periodically
- HTTPS Only: Ensure your deployment uses HTTPS to protect credentials
- Session Security: Use a complex, random string for
SESSION_SECRET - No Hardcoding: Never hardcode credentials in the codebase
- Secure Sharing: Avoid sharing credentials in unsecured channels
- Audit Logs: Review authentication logs for suspicious activity
-
Authentication Failures:
- Verify Replit Secrets are properly set in both development and deployment environments
- Check logs for environment variable availability
- Ensure the application has been restarted after setting new secrets
-
Session Issues:
- Clear browser cookies if experiencing session problems
- Verify
SESSION_SECRETis set and consistent
-
Common Error Messages:
BASIC_AUTH_USERNAME is MISSING in production environment: The username environment variable is not setBASIC_AUTH_PASSWORD is MISSING in production environment: The password environment variable is not setSESSION_SECRET environment variable not set: The session secret is missing
- Application logs include detailed authentication diagnostics (with sensitive information filtered out)
- Check for "Authentication failed" messages in the logs
The authentication system is implemented in the web/http_auth.py module, which provides:
http_auth_requireddecorator for protecting routes- Session management functions
- Detailed logging for troubleshooting
This implementation is designed to be simple, reliable, and compatible with the Replit environment.
- API Specification - Learn how authentication is used in the API
- Replit Secrets Guide - Detailed guide on managing secrets
- Privacy Controls - How sensitive authentication data is protected