Authentication
Admin Login
Administrator login with enhanced user verification and admin status validation
POST
Enhanced authentication endpoint specifically for administrators. This endpoint performs standard user authentication followed by admin privilege verification via REST API lookup.
Overview
The admin login endpoint performs a two-step authentication process:- Standard Authentication: Validates user credentials using the OAuth2 password grant
- Admin Verification: Queries the user database to verify admin privileges
- Combined Response: Returns authentication tokens plus admin-specific user details
This endpoint requires the user to have
is_admin: true in the user database.
Non-admin users will receive a 403 Forbidden response even with valid
credentials.Request
Request Body
Administrator’s email address
Administrator’s password
Response
JWT access token for authenticating API requests
Token type, always “bearer”
Token expiration time in seconds (typically 3600 for 1 hour)
Token expiration timestamp (Unix timestamp)
Refresh token for obtaining new access tokens
Standard user information object from authentication
Additional admin-specific user details from database lookup
Error Responses
Authentication Flow
The admin login process involves multiple steps with comprehensive error handling:Database Lookup
A REST API call is made to
/rest/v1/users?id=eq.<UUID> with header Accept-Profile: users to fetch details from the users.users table (ensure the users schema is exposed in Supabase Settings → API).Use Cases
Admin Dashboard Access
Use this endpoint for admin-only applications like admin dashboards:JavaScript
API Integration
For backend services that need to verify admin status:Python
Security Considerations
Best Practices
- Rate Limiting: Implement aggressive rate limiting for admin login attempts
- Audit Logging: Log all admin login attempts for security monitoring
- Token Management: Use the same token security practices as regular authentication
- Database Security: Ensure the
userstable has proper RLS policies
Error Handling
The endpoint provides detailed error responses to help with debugging:- 400: Invalid request body or credentials
- 403: Valid user but not an admin
- 404: User not found in database
- 500: Internal server errors (database connectivity, parsing errors)