Overview
Bar Galileo uses django-allauth for authentication, providing both traditional username/password login and Google OAuth integration.Authentication Backend
Login Endpoints
Standard Login
POST /accounts/login/
Authenticate with username and password
POST /accounts/login/
Username or email address
User password
Remember this device (extends session)
CSRF token from the login form
Example Request
Response
On successful login, redirects toLOGIN_REDIRECT_URL (default: /)
Google OAuth Login
GET /accounts/google/login/
Authenticate using Google OAuth
GET /accounts/google/login/
Initiates OAuth flow with Google. Configuration in bar_galileo/settings.py:215:
OAuth Flow
- User clicks “Login with Google”
- Redirected to Google consent screen
- Google redirects back to
/accounts/google/login/callback/ - Session created, user logged in
Requires Google OAuth credentials configured in Django admin under Social Applications.
Logout
POST /accounts/logout/
End the current user session
POST /accounts/logout/
Session Management
Login Configuration
Session Cookies
Bar Galileo uses Django’s session framework:| Cookie | Description |
|---|---|
sessionid | Session identifier (httponly) |
csrftoken | CSRF protection token |
Production Security Settings
Email Management
Add Email Address
POST /accounts/email/
Add or manage email addresses for the account
POST /accounts/email/
Action to perform:
add, remove, or primaryEmail address
CAPTCHA challenge ID
CAPTCHA answer (math problem solution)
accounts/views.py:4 as CustomEmailView.
Example Request
Protected Routes
Login Required Decorator
Many views require authentication using Django’sLoginRequiredMixin:
User Object
Authenticated requests have access torequest.user:
CAPTCHA Protection
Configuration inbar_galileo/settings.py:275:
GET /captcha/image/<key>/- Retrieve CAPTCHA imageGET /captcha/audio/<key>/- Audio CAPTCHA (requires Flite)
Custom Forms
Bar Galileo uses custom authentication forms:accounts/forms.py for implementation details.
Permission Middleware
Custom permission checking viaroles.middleware.PermissionMiddleware at bar_galileo/settings.py:94.
This middleware validates user permissions based on their assigned roles before processing requests.
Error Responses
Unauthorized (401)
Forbidden (403)
Best Practices
- Always use HTTPS in production
- Store session cookies securely
- Implement rate limiting for login attempts
- Use strong password policies
- Enable two-factor authentication (not currently implemented)
Next Steps
RAG Chat API
Explore authenticated RAG endpoints
API Overview
Return to API overview
