Overview
Kolibri uses session-based authentication for the API. Users authenticate by creating a session, which is maintained via session cookies. The authentication system supports multiple methods including username/password, token-based authentication, and OS user integration.Authentication Methods
Session Authentication (Primary)
Kolibri uses Django session authentication as the primary authentication mechanism. After successful login, the server sets a session cookie that is included in subsequent requests.Token Authentication
Kolibri also supports token-based authentication usinguser_id and auth_token for specific use cases such as automatic login links.
OS User Authentication
When running in app context, Kolibri supports automatic authentication for OS users via app authentication tokens.Base URL
All authentication endpoints are under:Create Session (Login)
Request Body
Username of the user to authenticate. Required for username/password authentication.
User’s password. Can be an empty string if the facility allows passwordless login for learners.
UUID of the facility the user belongs to. If not provided, defaults to the default facility.
UUID of the user (alternative to username for token authentication).
Authentication token for token-based login.
Response
Session identifier (always “current” for the current session).
The authenticated user’s username.
The user’s full name.
UUID of the authenticated user.
UUID of the user’s facility.
Array of user types (e.g.,
["admin"], ["learner"], ["coach"]).Whether the user has permission to manage content.
Whether the user is a device superuser.
Current server time in ISO 8601 format.
Whether the request is in app context.
Error Responses
Invalid Credentials (401 Unauthorized):Get Current Session
Retrieve information about the current session.server_time.
Update Session
Update session activity and log user session data.Whether the user is currently active. When
true, updates the user session log.Operating system information for session logging.
Browser information for session logging.
Logout (Destroy Session)
End the current session and log out the user.Set Password for Passwordless Account
Set a password for a learner account that was created without one (when passwordless login was enabled).Username of the learner account.
New password to set for the account.
UUID of the facility the user belongs to.
- The user doesn’t exist
- The user already has a password set
- The user is an OS user
Check Username Availability
Check if a username is available for registration in a specific facility.Username to check for availability.
UUID of the facility to check within.
User Sign Up
Create a new learner account in a facility that allows self-registration.Desired username (must be unique within the facility).
User’s password.
User’s full name.
UUID of the facility to join.
User’s gender. Options:
"MALE", "FEMALE", "NOT_SPECIFIED", or "DEFERRED".User’s birth year as a string (e.g.,
"2010").- The facility does not allow learner self-registration (
learner_can_sign_upisfalse) - The facility is not a full facility import
Authentication Flow Example
Here’s a complete authentication flow example:Anonymous Access
Some endpoints allow anonymous (unauthenticated) access depending on facility settings:- Public facility information
- Public content metadata
- Sign up endpoints (when enabled)
visitor_id cookie for tracking purposes but have limited permissions.
Session Timeout
Sessions expire after a period of inactivity. The timeout duration is configurable. To prevent timeout:- Periodically send PUT requests to
/api/auth/session/current/withactive: true - The
last_session_requesttimestamp is updated on each request
Security Considerations
- HTTPS in Production: Always use HTTPS in production to protect credentials in transit
- CSRF Protection: Include CSRF tokens in all state-changing requests
- Password Strength: Enforce strong passwords at the application level
- Session Security: Configure secure session cookies with
HttpOnlyandSecureflags - Rate Limiting: Implement rate limiting on login endpoints to prevent brute force attacks
Related Endpoints
- Permissions - Understanding user roles and permissions
- Facility Management - Managing facilities and facility settings
- User Management - CRUD operations on user accounts