Pinter
ENID
Architecture
View as Markdown

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

MethodFlow
Username and passwordStandard login at /login.
Multi-factor authenticationAfter login, users with MFA enabled continue at /mfa. Pinter lists the available methods, sends a one-time password, and verifies it before issuing tokens.
SSOExternal 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 detail errors into AuthError.

Route guards

Frontend guards live in:

pinter-fe/src/shared/auth/route-guards.ts

Common guards include:

  • requireRoleLevel(level): Restricts navigation to users with role_level <= level (or L99 auditor for admin views where level <= 2).
  • requireDocumentsAccess(): Legacy guard for shared document views (/share/d/$documentId). The /documents management route is now gated on requireRoleLevel(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.
GuardAllows
requireAdminLike()Admin-like users.
requireRoleLevel(level)Users with role_level <= level.

Users who fail a guard are redirected to /chat.

Role levels

LevelTypical access
1Super Admin, applications, all admin operations.
2Admin dashboard, API Studio, admin management, agent creation/editing, and Documents management.
3Workspace tools such as tools, MCP servers, integrations, evaluations, schedules, and read-only Agent Designer inspection.
4Chat 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:

PathWho actsFlow
Access requestUser, then adminUser requests access. The request stays pending until an admin approves or rejects it.
Fast grantAdminAdmin creates and auto-approves a grant in one step.
SharingAgent ownerOwner shares directly or issues a claim code. See Sharing agents.

Grant endpoints:

EndpointPurpose
POST /api/identity/grants/requestCreate a pending access request.
GET /api/identity/grants/my-requestsList your own requests.
GET /api/identity/grants/my-accessList resources you can access.
GET /api/identity/grants/mappingAdmin view of the access mapping.
GET /api/identity/grants/pendingList pending requests (admin only).
PUT /api/identity/grants/{grant_id}/approveApprove a request (admin only).
PUT /api/identity/grants/{grant_id}/rejectReject a request (admin only).
POST /api/identity/grants/fast-grantCreate 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 roleSearch capabilityReturned schemaunscoped=true
L1 (Platform Architect)Organization-wideFull user summary (role assignments, PII, security metadata)Allowed
L2 (App Director)Scoped to active role group (or all if unscoped=true)Full user summaryAllowed
L99 (Auditor)Organization-wide audit viewFull user summaryAllowed
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 Request for 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 prefixPurpose
/api/agentsAgent CRUD, publish, export, import, restore.
/api/conversationsConversations, messages, attachments, streaming sends.
/api/identity/grantsAccess requests, approvals, direct grants, revoke.
/api/governance/quotasQuotas, usage, alerts.
/api/identity/usersUser and role group administration.
/api/identity/applicationsApplication credentials.