Authentication & Authorization
This document defines the planned authentication and authorization model for the Tripinger API.
Document Purpose
This document defines the planned authentication and authorization model for the Tripinger API. It explains how identities are created, how users authenticate, how sessions and tokens are handled, how roles and permissions are enforced, and how access differs across traveler, partner, and admin surfaces.
Tripinger serves multiple product surfaces through one core API platform, including the public web app, partner portal, and admin dashboard. Because these surfaces expose different capabilities and risk levels, the platform needs one consistent identity system with clear authorization boundaries rather than separate ad hoc auth logic in each client.
Auth Model Overview
The API should use a centralized identity and access model with these core characteristics:
- One backend-owned authentication system
- JWT-based session access for authenticated API usage
- Refresh-token support for session renewal
- Email/password login support
- OAuth 2.0 social login support
- Role-based access control for broad access categories
- Resource ownership checks for tenant and user isolation
- Separate treatment of traveler, partner, and admin permissions
- Stronger controls for privileged actions such as moderation, verification, payouts, and internal operations
The current API documentation already identifies JWT and OAuth 2.0 support as the planned direction and explicitly states that role-based access control and resource ownership checks should both be supported. It also names traveler, partner, hotel partner, vehicle owner, restaurant partner, guide or activity partner, admin, super admin, and support agent as the main access roles in scope.
Identity Principles
The authentication system should follow these principles:
-
Backend authority Authentication and authorization decisions must be enforced in the API, not trusted to frontend route hiding or client-side role checks alone. This is especially important because the admin dashboard and partner portal expose sensitive operations.
-
One identity foundation, many access contexts The same core identity system should support travelers, partners, and internal staff while still enforcing different role and permission boundaries. The architecture and API docs both treat the API platform as the shared identity boundary across all product surfaces.
-
Least privilege Users should receive only the access required for their current role and account state. A partner account should not gain admin visibility, and a traveler account should not gain supplier controls unless explicitly authorized.
-
Ownership plus role checks Roles alone are not sufficient. The API should also enforce whether the authenticated actor owns or is assigned to the resource being accessed, such as a hotel, vehicle, booking, or moderation queue item. The current API README explicitly calls for both role-based access control and resource ownership rules.
-
Auditability for privileged access Admin actions, partner-verification decisions, and other sensitive operations should be attributable to authenticated identities and logged appropriately. The architecture document calls out auditability for moderation, payouts, and privileged internal actions as a security requirement.
Authentication Methods
The API should support multiple authentication paths because the public web app is expected to support both traditional login and social onboarding, while partner and admin surfaces require secure authenticated access as well.
Email and password
Email/password authentication should be available as a first-class login method. The API README identifies this as part of the auth module baseline together with token refresh, password reset, and account verification.
This method should support:
- registration
- login
- email verification
- forgot-password initiation
- password reset completion
- refresh token renewal
- logout / token invalidation behavior
OAuth 2.0 social login
The current documentation already lists Google, Facebook, and Apple login as planned social sign-in providers. The API should therefore support OAuth 2.0 or provider-equivalent flows through backend-managed callbacks and account linking logic.
Initial provider priority should follow product needs:
- Apple
This ordering is practical because the public web app explicitly prioritizes traveler signup and login simplicity, and the API already names those providers in scope.
Admin and partner login
Admin and partner users should authenticate through the same backend identity platform, but their authorization state must be evaluated separately from traveler access. The partner portal docs describe an approval-aware access model, and the admin docs require backend-enforced role checks rather than hidden frontend routes.
Supported Actor Types
The API should treat these as distinct identity contexts even if they share a common underlying user record model.
| Actor type | Description | Typical surfaces |
|---|---|---|
| Traveler | Demand-side end user booking and planning trips | Public web app |
| Partner user | Supply-side operator managing inventory and bookings | Partner portal |
| Admin user | Internal operator performing moderation and oversight | Admin dashboard |
| Support or operations user | Internal staff with limited operational permissions | Admin dashboard |
A single person may eventually have more than one access context, but the API should still issue and evaluate permissions explicitly rather than assuming one role implies another.
Roles
The current API documentation already suggests the following role set, which should be treated as the Phase 1 baseline role vocabulary.
Core roles
travelerpartnerhotel_partnervehicle_ownerrestaurant_partnerguide_partneradminsuper_adminsupport_agent
These role names may later be normalized for implementation consistency, but the access categories themselves are already part of the approved documentation direction.
Role meaning
| Role | Purpose | Notes |
|---|---|---|
traveler | End-user trip planning, booking, reviews, profile actions | Default customer role |
partner | Generic supply-side account | Base role for partner portal access |
hotel_partner | Hotel or stay inventory management | Scoped supplier role |
vehicle_owner | Vehicle or fleet inventory management | Scoped supplier role |
restaurant_partner | Restaurant and food-related inventory management | Scoped supplier role |
guide_partner | Activities, tours, or guide-related inventory | Scoped supplier role |
admin | Standard internal platform operations | Restricted internal role |
support_agent | User support and limited operational actions | Restricted internal role |
super_admin | Highest privileged internal operator | Reserved for tightly controlled actions |
Role hierarchy guidance
The API should not rely on a loose “higher role can do everything” model without limits. Instead:
super_adminmay include the broadest internal permissions.adminshould be limited to approved operational capabilities.support_agentshould remain narrower thanadmin.- specialized partner roles should be narrower than generic internal roles.
travelershould never inherit partner or admin permissions.
This reduces accidental privilege escalation and matches the documented need for fine-grained admin and partner access control.
Account States
Authentication is not only about who the user is. It is also about whether the account is allowed to perform the next action.
Traveler states
Recommended traveler account states:
pending_verificationactivesuspendeddeleted_or_archived
The public web app documentation already expects registration, login, email verification, reset-password flows, and account preferences, which implies at least a basic lifecycle around account activation and access eligibility.
Partner states
The partner portal documentation already defines these suggested partner account states:
invitedregisteredonboardingpending_verificationapprovedsuspended
The API should enforce these states server-side. For example:
- a
registeredoronboardingpartner may sign in - a
pending_verificationpartner may access onboarding and document flows - only an
approvedpartner should gain full listing, availability, pricing, and booking-management permissions - a
suspendedpartner should lose normal operational access
Admin states
Recommended admin states:
activeinactivesuspended
Internal access should be revocable immediately and should not depend only on UI configuration.
Session and Token Strategy
The architecture document explicitly lists authentication tokens and refresh flows as security-sensitive areas, and the API README names JWT access and refresh secrets as required environment inputs. That makes a token-based session model the expected API design.
Token model
The API should issue:
- a short-lived access token
- a longer-lived refresh token
The access token should be used for normal authenticated API requests. The refresh token should be used only to obtain new access credentials through a dedicated refresh flow.
Recommended token claims
Access tokens should minimally include:
- subject identifier
- role or roles
- account type or access context where helpful
- token issue time
- token expiry
- session or token version where needed
Avoid putting sensitive profile data or mutable business data directly into tokens.
Refresh token handling
Refresh tokens should support:
- rotation on use where practical
- revocation on logout or security events
- invalidation after password reset where appropriate
- invalidation when account status changes materially
- server-side tracking if stronger session control is required
Transport direction
The exact transport mechanism is not fully fixed in the current docs, but the API should choose one consistent model per client class and document it clearly. For browser-based clients, the design should favor secure handling that minimizes token exposure and supports logout, refresh, and revocation predictably.
Auth Flows
The auth module should support the following main flows.
1. Traveler registration
- User submits registration details.
- API creates the user record in a non-fully-active or verification-aware state.
- API initiates email verification where enabled.
- User verifies the account.
- API allows authenticated traveler access.
2. Traveler login
- User submits email/password or social sign-in request.
- API validates credentials or provider identity.
- API checks account status.
- API issues access and refresh credentials.
- User gains traveler-scoped access to booking, profile, planner, and other authenticated flows.
3. Partner registration and onboarding
- User creates or receives a partner-capable account.
- API assigns initial partner identity state.
- User enters onboarding and document flows.
- API tracks verification status and role scope.
- Approval by admin unlocks full supplier functionality.
4. Admin login
- Internal user submits credentials.
- API verifies identity and active internal role assignment.
- API issues authenticated session credentials.
- API authorizes access only to approved admin routes and actions.
5. Refresh flow
- Client presents refresh credential.
- API validates session eligibility.
- API issues a new access token and, if rotation is enabled, a new refresh token.
- API rejects invalid, revoked, expired, or mismatched refresh attempts.
6. Forgot password / reset password
- User requests password reset.
- API creates a time-bound reset flow.
- User proves control of the relevant email channel.
- API accepts the new password.
- Old sessions may be invalidated depending on policy.
Authorization Model
Tripinger needs more than login. It needs layered authorization because different users interact with different modules and different data scopes. The API README explicitly states that authorization should combine role-based access control with resource ownership rules.
Layer 1: Authentication
Is the caller authenticated?
Layer 2: Role check
Does the caller have a role that is allowed to enter this route or capability area?
Layer 3: Account-state check
Is the account active, approved, verified, or otherwise eligible for this action?
Layer 4: Resource ownership or assignment check
Does the caller own or control the specific resource, or has the platform assigned them permission over it?
Layer 5: Action-specific policy
Is the requested action permitted under business rules, such as verification state, booking state, moderation state, or internal workflow controls?
This layered model is necessary because a hotel partner should not access another hotel partner’s inventory, and an admin support role should not automatically gain finance or super-admin capabilities.
Ownership Rules
Ownership checks should be enforced for any data or action tied to a specific user, partner, or tenant-like scope.
Traveler ownership examples
A traveler may:
- read and update their own profile
- view their own bookings
- manage their own planner drafts
- submit reviews only when eligible
- access their own saved content and preferences
A traveler may not:
- read another traveler’s profile
- view another user’s bookings
- access partner-only inventory controls
- access internal moderation or finance operations
Partner ownership examples
A partner user may:
- manage listings belonging to their own approved partner entity
- update availability and pricing for their own inventory
- view their own bookings and payout-relevant data
- upload and manage their own documents
A partner user may not:
- edit another partner’s listings
- see internal moderation queues by default
- perform admin verification actions
- bypass approval state requirements
Admin ownership and assignment examples
Internal admins may access broader platform data, but not all admin users should access everything. For example:
- a support agent may inspect a booking and add notes
- a moderator may act on review or content issues
- a compliance reviewer may assess partner documents
- a finance-oriented admin may inspect payment problems
- only stronger internal roles should perform high-risk configuration or privileged user-management actions
Permission Strategy
The API should implement permissions in a way that goes beyond raw role strings.
Recommended permission layers
- Role gates for broad module access
- Action permissions for sensitive operations
- Ownership checks for tenant isolation
- State-aware rules for workflows that depend on verification, booking, or moderation states
Example permission groups
| Permission area | Example actions |
|---|---|
| Auth and profile | read profile, update profile, manage password |
| Traveler booking | create booking, cancel own booking, view own booking |
| Partner inventory | create listing, update listing, manage pricing, manage availability |
| Partner finance | view payout summary, view booking-linked earnings |
| Admin moderation | review content, hide content, approve or reject moderation actions |
| Admin verification | review documents, approve partner, reject partner |
| Admin support | view traveler account, add support note, inspect booking state |
| Finance operations | inspect payment issues, review refund path, review payout state |
Why permissions matter
The admin README already recommends a fine-grained permission model and explicitly warns against relying only on hidden routes. That same principle should apply across the API.
Route Protection Categories
The API should group routes by access sensitivity.
Public routes
No authentication required.
Examples:
- health checks
- public listing search
- public listing detail fetch
- public destination discovery
- login and registration initiation
Authenticated traveler routes
Require authenticated traveler context.
Examples:
- profile
- saved trips
- personal bookings
- planner drafts
- review submission eligibility
Partner routes
Require authenticated partner context plus approval-aware checks where necessary.
Examples:
- onboarding
- listing creation
- availability updates
- booking inbox
- document uploads
- analytics summaries
Admin routes
Require authenticated internal role checks and, where needed, finer permission checks.
Examples:
- partner approval
- listing review
- booking lookup
- payment issue inspection
- moderation actions
- reporting dashboards
Service or internal routes
May require internal service credentials, stronger guards, or non-public exposure patterns for operational workflows.
OAuth Account Linking Strategy
When a user authenticates through social login, the API should determine whether to:
- create a new user
- link to an existing user
- reject the login because of conflicting identity state
- require additional verification or completion steps
This is especially important for partner and admin users, where identity certainty and controlled access matter more than frictionless sign-in alone.
Recommended rules:
- travelers may use password or supported social sign-in
- partner social login may be allowed later if it does not weaken identity control
- admin social login should be introduced only if operational security standards are satisfied
The current documentation confirms social login intent for the public product, but it does not require that every internal role use social auth in Phase 1.
Verification and Trust Flows
Tripinger’s trust model depends on verified suppliers, verified reviews, and operational oversight. That means auth must interact cleanly with verification state.
Email verification
Email verification should be part of account trust for standard user signup flows. The web and API docs both include email verification among expected auth flows.
Partner verification
Partner accounts should not gain full operational access simply because they authenticated successfully. The partner portal already defines onboarding, document submission, pending verification, and approved states, while the architecture and admin docs describe admin review as part of the partner onboarding journey.
Review eligibility tie-in
The API documentation treats verified reviews and review eligibility as system-level concerns. Authorization should therefore also check eligibility context before allowing review creation, not just whether the user is signed in.
Security Controls
The architecture document explicitly identifies authentication tokens, payment verification, admin access boundaries, partner documents, and AI handling as security-sensitive areas. The auth system should therefore include protective controls from the beginning.
Required controls
- Strong password rules and hashing
- Rate limiting on login and reset flows
- Refresh-token validation and revocation controls
- Secure email verification and reset mechanisms
- Backend-only authorization enforcement
- Audit logging for privileged actions
- Immediate access revocation for suspended internal or partner users
- Verified webhook-driven trust in payment-related downstream flows where auth meets booking lifecycle
Additional recommended controls
- device or session tracking for internal users
- suspicious login detection
- brute-force mitigation
- role-change invalidation of active sessions
- optional MFA for admin users in later phases
Module Responsibilities
The auth model should be implemented through clearly separated backend modules.
Auth module
Owns:
- registration
- login
- token issuance
- refresh flow
- password reset
- email verification
- OAuth callback handling
Users module
Owns:
- user profile and identity-linked non-auth account data
- preferences
- public-safe and self-service profile operations
Partners module
Owns:
- partner role assignment context
- onboarding state
- verification state
- partner access readiness
Admin module
Owns:
- internal role assignment
- privileged access checks
- internal operational action boundaries
This separation follows the modular backend direction already described in the API and architecture docs.
Suggested Endpoint Groups
Exact paths may differ, but the auth surface should likely include groups like these:
Public auth endpoints
POST /auth/registerPOST /auth/loginPOST /auth/refreshPOST /auth/forgot-passwordPOST /auth/reset-passwordPOST /auth/logoutGET /auth/verify-emailGET /auth/oauth/:providerGET /auth/oauth/:provider/callback
Self-service account endpoints
GET /mePATCH /mePATCH /me/passwordGET /me/sessionsif session management is exposed later
Internal auth-related endpoints
- partner approval state checks
- admin user role or permission lookup
- session invalidation operations for privileged support or security workflows
Error Handling Direction
Auth and authorization errors should be predictable and safe.
Examples of expected response categories
- invalid credentials
- unverified account
- suspended account
- forbidden role
- forbidden resource ownership
- expired refresh token
- invalid reset token
- partner not approved
- internal permission denied
The API conventions document should later define the exact response envelope format, but auth routes should already follow a consistent error taxonomy that clients can handle reliably. The architecture also calls out the importance of documented API standards and security boundaries across these flows.
Testing Priorities
The API README already lists auth flow tests among the highest-priority Phase 1 backend tests.
Minimum Phase 1 auth test coverage
- user registration
- email/password login
- token refresh
- password reset request and completion
- route protection for authenticated traveler endpoints
- partner login with approval-state restrictions
- admin login and restricted-route enforcement
- ownership checks on traveler and partner resources
- role enforcement on privileged admin actions
- review-submission eligibility enforcement where applicable
High-risk cases to test
- suspended user attempting access
- pending-verification partner attempting operational actions
- partner accessing another partner’s listing
- support agent attempting super-admin action
- expired or revoked refresh token reuse
- social login conflict with existing account identity
- password reset invalidating prior sessions where policy requires it
Environment Variables
The API README already documents key auth-related environment variables, including:
JWT_ACCESS_SECRETJWT_REFRESH_SECRET
Depending on implementation, the auth module may also require:
- OAuth client IDs and secrets per provider
- email verification URL configuration
- password reset URL configuration
- token expiry settings
- trusted frontend origin settings
These values should be documented in the root .env.example once finalized, consistent with the repository-wide configuration pattern described in the current docs.
Assumptions
This document uses the following planning assumptions:
- The Tripinger API is the single backend authority for auth across web, admin, and partner surfaces.
- JWT access and refresh tokens are the intended session model.
- OAuth sign-in support is planned for Google, Facebook, and Apple.
- Authorization combines role-based access control and resource ownership rules.
- Partner access is approval-aware and must not rely only on successful login.
- Admin access must be enforced server-side with fine-grained permissions, not just hidden routes.
Current Status
This document defines the planned authentication and authorization model for the Tripinger API based on the current generated Phase 1 documentation. Exact endpoint paths, token transport details, password policies, provider onboarding details, and MFA decisions should be finalized during implementation, but the centralized auth model, JWT direction, OAuth support, role system, and layered authorization rules described here should be treated as the Phase 1 baseline.