Authentication and access control
Understand frontend auth state, route guards, and backend access control areas.
Pinter uses token-based authentication with refresh support.
The frontend stores auth state in Zustand and sends bearer tokens through the shared authenticated request module.
Sign-in methods
| Method | Flow |
|---|---|
| Username and password | Standard login at /login. |
| Multi-factor authentication | After login, users with MFA enabled continue at /mfa. Pinter lists the available methods, sends a one-time password, and verifies it before issuing tokens. |
| SSO | External applications exchange a signed JWT for Pinter tokens at /api/identity/sso/jwt. The exchange verifies the application client_secret and provisions the user just-in-time when needed. |
Users change their password from the user menu in the sidebar, which opens the change password dialog.
Frontend auth state
Auth state lives in:
pinter-fe/src/shared/stores/auth-store.ts
Stored fields include:
- Access token.
- Refresh token.
- Current user.
- Authentication status.
On rehydration, the store checks token expiry. Expired sessions are cleared unless the refresh token can still be used.
Authenticated requests
All authenticated frontend calls should use:
pinter-fe/src/shared/auth/authenticated.ts
This module:
- Adds
Authorization: Bearer <token>. - Refreshes tokens before requests when needed.
- Retries once after
401. - Logs out when refresh fails.
- Parses backend
detailerrors intoAuthError.
Route guards
Frontend guards live in:
pinter-fe/src/shared/auth/route-guards.ts
Common guards include:
requireRoleLevel(level): Restricts navigation to users withrole_level <= level(or L99 auditor for admin views wherelevel <= 2).requireDocumentsAccess(): Legacy guard for shared document views (/share/d/$documentId). The/documentsmanagement route is now gated onrequireRoleLevel(2).requirePermission(permission): Checks capability permissions on the userβs authorization context.
Auditor Role (L99)
Users with role level 99 are read-only auditors:
- Can view internal documents across applications and search the Knowledge Hub.
- Strictly forbidden from modifying documents, uploading new files, changing share policies, attaching documents to agents, or downloading raw document files. All mutation endpoints return
403 Forbidden.
| Guard | Allows |
|---|---|
requireAdminLike() | Admin-like users. |
requireRoleLevel(level) | Users with role_level <= level. |
Users who fail a guard are redirected to /chat.
Role levels
| Level | Typical access |
|---|---|
1 | Super Admin, applications, all admin operations. |
2 | Admin dashboard, API Studio, admin management, agent creation/editing, and Documents management. |
3 | Workspace tools such as tools, MCP servers, integrations, evaluations, schedules, and read-only Agent Designer inspection. |
4 | Chat and personal feedback / profile usage. |
Access grants
Grants control which users can use or edit a specific agent. A grant is created in one of three ways:
| Path | Who acts | Flow |
|---|---|---|
| Access request | User, then admin | User requests access. The request stays pending until an admin approves or rejects it. |
| Fast grant | Admin | Admin creates and auto-approves a grant in one step. |
| Sharing | Agent owner | Owner shares directly or issues a claim code. See Sharing agents. |
Grant endpoints:
| Endpoint | Purpose |
|---|---|
POST /api/identity/grants/request | Create a pending access request. |
GET /api/identity/grants/my-requests | List your own requests. |
GET /api/identity/grants/my-access | List resources you can access. |
GET /api/identity/grants/mapping | Admin view of the access mapping. |
GET /api/identity/grants/pending | List pending requests (admin only). |
PUT /api/identity/grants/{grant_id}/approve | Approve a request (admin only). |
PUT /api/identity/grants/{grant_id}/reject | Reject a request (admin only). |
POST /api/identity/grants/fast-grant | Create and auto-approve a grant (admin only). |
DELETE /api/identity/grants/{grant_id} | Revoke a grant (admin only). |
GET /api/conversations/shares/grants/{agent_id} | List active grants on an agent (its creator, not admin-only). |
Admins review and manage grants from the Users admin area at /admin/users.
User directory & search authorization
The /api/identity/users/search endpoint implements role-aware authorization and field-level data minimization:
| Caller role | Search capability | Returned schema | unscoped=true |
|---|---|---|---|
| L1 (Platform Architect) | Organization-wide | Full user summary (role assignments, PII, security metadata) | Allowed |
| L2 (App Director) | Scoped to active role group (or all if unscoped=true) | Full user summary | Allowed |
| L99 (Auditor) | Organization-wide audit view | Full user summary | Allowed |
| L3 / L4 (Designer / Navigator) | Organization-wide directory search (requires min 3 characters) | Minimal projection (uuid, username, name, email) | 403 Forbidden |
Protection mechanisms
- Data minimization: Low-privilege users never receive sensitive PII (
phone_number), administrative metadata (is_admin,role_assignments,role_level), or account security flags (use_sso,is_disabled,created_at). - Anti-enumeration: Calling without a search query or with fewer than 3 characters is rejected with
HTTP 400 Bad Requestfor non-admin callers. - Client debouncing: UI recipient pickers debounce queries with a 300ms delay to prevent request spamming during typing.
Backend route groups
Backend routes use FastAPI dependencies such as active user and admin user checks.
Common protected route groups:
| Route prefix | Purpose |
|---|---|
/api/agents | Agent CRUD, publish, export, import, restore. |
/api/conversations | Conversations, messages, attachments, streaming sends. |
/api/identity/grants | Access requests, approvals, direct grants, revoke. |
/api/governance/quotas | Quotas, usage, alerts. |
/api/identity/users | User and role group administration. |
/api/identity/applications | Application credentials. |