Overview
GZCTF supports multiple authentication methods for API access:- Session-based authentication - Cookie-based sessions for web applications
- API tokens - Bearer tokens for programmatic access (Admin only)
Session Authentication
Login
Authenticate using username/email and password to establish a session.Endpoint: POST /api/account/login
Username or email address
User password (may require encryption based on platform settings)
HTTP status code: 200 for success, 401 for invalid credentials
Logout
Terminate the current session.Endpoint: POST /api/account/logout
Requires authentication. This endpoint will clear the session cookie.
API Tokens
API tokens provide a secure way for administrators to access the API programmatically without session cookies.Generate Token
Create a new API token with optional expiration.Endpoint: POST /api/tokens
Requires Admin permission. Tokens are shown only once upon creation.
Descriptive name for the token
Number of days until token expiration (optional, 0 = no expiration)
List Tokens
Retrieve all API tokens.Endpoint: GET /api/tokens
Requires Admin permission.
Revoke Token
Revoke or delete an API token.Endpoint: DELETE /api/tokens/
Token UUID
If true, permanently delete the token instead of just revoking it
Restore Token
Restore a previously revoked token.Endpoint: POST /api/tokens//restore
Token UUID
Using API Tokens
Include the token in theAuthorization header:
Permission Levels
GZCTF uses role-based access control:| Role | Description |
|---|---|
User | Standard user with access to games and teams |
Monitor | Can view game events, submissions, and captures |
Admin | Full administrative access |
Banned | No access (authentication fails) |
Authorization Attributes
Endpoints are protected by middleware attributes:[RequireUser]- Requires authenticated user[RequireMonitor]- Requires Monitor or Admin role[RequireAdmin]- Requires Admin role
Security Best Practices
Password Encryption
Password Encryption
When the platform has
ApiEncryption enabled, passwords must be encrypted client-side before transmission. Check /api/admin/config for the current setting.Captcha Protection
Captcha Protection
Registration and login endpoints may require captcha verification when
UseCaptcha is enabled in account policies.Session Management
Session Management
Sessions are managed through cookies (
AspNetCore.Identity.Application). Ensure your HTTP client supports cookies for session-based authentication.Next Steps
Account API
User registration and profile management
Admin API
Administrative endpoints