Auth & Users
Configure your auth and users
Authentication Configuration
R2R provides a flexible authentication system that supports both server-side configuration and runtime customization. The authentication system manages user registration, login, session management, and access control.
Server Configuration
The authentication settings can be configured in your r2r.toml
file under the auth
section:
Environment Variables
You can also configure authentication using environment variables:
Key Features
1. User Management
- User registration with optional email verification
- Password hashing and security
- Linking of ingested documents to user
- Assignment of document collections to / from user
- User roles (superuser/admin and regular users)
2. Token Management
- JWT-based authentication
- Access and refresh token system
- Configurable token lifetimes
- Token blacklisting for logout
3. Security Features
- Password reset functionality
- Email verification (optional)
- Token expiration and refresh
- Password change capabilities
API Methods
The authentication system provides several key endpoints:
- Registration:
- Login:
- Token Refresh:
- Logout:
Refer directly to the Users API Reference for more details.
Email Configuration
If email verification is enabled, you’ll need to configure an email provider:
Cryptography Configuration
R2R is designed to support arbitrary crypotgraphy providers through the r2r.toml
:
Protected Endpoints
When authentication is enabled (require_authentication = true
), all secure R2R endpoints require a valid access token. The user’s access token will automatically be included in API calls after login:
Error Handling
The authentication system provides detailed error messages for common scenarios:
- Invalid credentials
- Expired tokens
- Unauthorized access
- Email verification required
- Invalid reset tokens
Example error handling: