Authentication & RBAC¶
BGSTM uses JWT Bearer token authentication and a simple three-tier role-based access control (RBAC) model.
Roles¶
| Role | Permissions |
|---|---|
admin | Full access: user management, audit log access, all reviewer permissions |
reviewer | Create/edit requirements, test cases, and links; review and generate suggestions |
viewer | Read-only access to all resources |
Every registered user is assigned the viewer role by default. An admin can promote users via the Users API.
Endpoints¶
Register¶
Create a new user account.
Request body:
Example (curl):
curl -X POST http://localhost:8000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"alice@example.com","password":"s3cr3t!","full_name":"Alice Smith"}'
Example (httpie):
http POST http://localhost:8000/api/v1/auth/register \
email=alice@example.com password=s3cr3t! full_name="Alice Smith"
Login¶
Authenticate and receive a JWT access token.
Request body (form data):
Example (curl):
curl -X POST http://localhost:8000/api/v1/auth/login \
-d "username=alice@example.com&password=s3cr3t!"
Response:
Tokens are valid for 60 minutes by default (configurable via ACCESS_TOKEN_EXPIRE_MINUTES).
Current User Profile¶
Returns the profile of the currently authenticated user.
Example (curl):
Response:
{
"id": 1,
"email": "alice@example.com",
"full_name": "Alice Smith",
"role": "viewer",
"is_active": true
}
Using the Token¶
Include the token in the Authorization header for every protected request:
Example (curl):
TOKEN=$(curl -s -X POST http://localhost:8000/api/v1/auth/login \
-d "username=alice@example.com&password=s3cr3t!" | jq -r .access_token)
curl http://localhost:8000/api/v1/requirements \
-H "Authorization: Bearer $TOKEN"
Default Admin Account¶
On first startup, BGSTM seeds a default admin user:
| Field | Default value |
|---|---|
admin@bgstm.local | |
| Password | admin1234 |
Change the default password immediately in any non-development environment.
Set the DEFAULT_ADMIN_EMAIL and DEFAULT_ADMIN_PASSWORD environment variables before the first run, or update the account via the Users API after login.