API Authentication¶
Bookcard supports two authentication methods:
- JWT (JSON Web Tokens) - Default authentication
- OIDC (OpenID Connect) - Enterprise SSO integration
JWT Authentication¶
Register a User¶
POST /api/auth/register
Content-Type: application/json
{
"username": "newuser",
"email": "user@example.com",
"password": "secure-password"
}
Login¶
POST /api/auth/login
Content-Type: application/json
{
"username": "newuser",
"password": "secure-password"
}
Response:
Using the Token¶
Include the token in the Authorization header:
Token Expiration¶
Tokens expire after a configurable period (default: 3 months). Refresh by logging in again.
OIDC Authentication¶
When OIDC is enabled, authentication is handled through your OIDC provider. See the User Guide for OIDC configuration.
OIDC Flow¶
- User initiates login via
/api/auth/oidc/login - Redirected to OIDC provider
- User authenticates with provider
- Redirected back to
/api/auth/oidc/callback - Application issues JWT token
Current User¶
Get information about the authenticated user:
Response:
Permissions¶
Different endpoints require different permissions. Check the API Reference for endpoint-specific requirements.
Common permissions:
- books:read - Read books
- books:write - Create/update books
- books:delete - Delete books
- shelves:read - Read shelves
- shelves:write - Create/update shelves
- admin:* - Administrative access