Overview
The tenant registration flow involves coordination between your frontend application, backend services, and the Upsolve API to securely register tenants and manage their access tokens.Key Requirements
Critical Implementation Points: - Token must be passed to frontend -
** Required for UpsolveDashboard component - 1-hour expiration - Tokens
expire after 1 hour and must be refreshed - No server-side caching -
Upsolve does not cache/store permissions for users - ** Fresh token required -
** Each dashboard view requires a valid, current token - **JWT change triggers
refresh ** - Changing/updating the JWT token will automatically refresh the
entire dashboard to apply new tenant permissions
Critical Data Flow
Step-by-Step Process
1. Initial Tenant Registration
Frontend Request2. Token Storage
The backend should save the token and expiry information to theUpsolveTenant model/entity for future use.
3. Permission Retrieval
Frontend Request4. Token Refresh
Since tokens expire after 1 hour, implement a refresh mechanism: Frontend Request5. Frontend Integration
Pass the valid token to the UpsolveDashboard component:Implementation Details
Token Management
- Expiration: Tokens expire after 1 hour
- No Caching: Upsolve does not cache or store permissions - fresh tokens required
- Frontend Requirement: Token must be passed to frontend for dashboard rendering
- Refresh Strategy: Implement automatic refresh before expiration
- Storage: Store tokens securely in your backend database
- Validation: Always check token validity before dashboard rendering
Error Handling
Common Error Scenarios: Invalid API KeySecurity Considerations
- API Key Protection: Never expose API keys in frontend code
- Token Scope: Tokens are tenant-specific and cannot access other tenant data
- HTTPS Required: All API communications must use HTTPS
- Token Rotation: Implement regular token refresh cycles
Frontend Integration Requirements
Critical: The token must be passed to the frontend since Upsolve does not
store user permissions server-side. Each dashboard render requires a valid
token.
Token Passing
The frontend must receive and use the token from the backend:Dashboard Component
Automatic Refresh
Implement automatic token refresh:Dashboard Refresh Behavior
Important: When the JWT token changes (either through refresh, tenant
switching, or permission updates), the dashboard will automatically reload to
apply the new authentication context and data permissions.
How JWT Changes Trigger Refresh
Understanding the refresh mechanism is critical for proper implementation:For iFrame Embedding
When the JWT in the iframesrc URL changes, the browser automatically reloads the entire iframe content. This is standard browser behavior for any src attribute change.
For React Component Embedding
When thetenantJWT prop changes, React’s useEffect hooks detect the change and trigger:
- Re-fetching of dashboard data with new permissions
- Re-fetching of filter options based on new tenant context
- Re-rendering of all charts with the updated authentication
Common Use Cases for JWT Changes
- Token Expiration Refresh: When the 1-hour token expires, refreshing it will reload the dashboard
- Tenant Switching: Switching between different tenants/organizations updates the JWT and reloads with new data permissions
- Permission Updates: If tenant permissions change, generating a new JWT will refresh the dashboard with updated capabilities
- User Login/Logout: Authentication state changes will update the JWT and refresh the dashboard context
Best Practices
Minimize Unnecessary JWT Updates
Minimize Unnecessary JWT Updates
Only update the JWT when necessary (expiration, tenant switch, permission change). Frequent unnecessary updates will cause dashboard reloads and degrade user experience.
Show Loading States
Show Loading States
When updating the JWT, show a loading indicator to inform users the dashboard is refreshing:
Pre-fetch Tokens When Possible
Pre-fetch Tokens When Possible
To reduce perceived latency, pre-fetch new tokens before the user needs them (e.g., when switching tabs or navigation):