Overview
OpsHub NAV uses Supabase Auth with JWT tokens for authentication. All API requests must include a valid authentication token.Authentication Flow
1
Sign In
Authenticate with email/password or OAuth provider
2
Receive JWT
Get access token and refresh token
3
Include in Requests
Add token to
Authorization header4
Refresh Token
Use refresh token to get new access token before expiry
API Key Authentication
For server-to-server communication, use API keys:Generate API Key
Use API Key
Store API keys securely. Never commit them to version control or expose them in client-side code.
Email/Password Authentication
Sign Up
Sign In
Refresh Token
Access tokens expire after 1 hour. Use refresh tokens to get new access tokens:OAuth Authentication
Authenticate with OAuth providers:Supported Providers
- Microsoft Azure AD
- GitHub
- GitLab
OAuth Flow
Service Role Authentication
For administrative operations and server-to-server communication:The service role key bypasses Row Level Security (RLS). Use only in trusted server environments.
Row Level Security (RLS)
OpsHub uses PostgreSQL Row Level Security to enforce access control:Role-Based Access
Users are automatically assigned roles:- ADMIN - Full system access
- FUND_MANAGER - Manage funds and strategies
- PORTFOLIO_MANAGER - Manage portfolios
- OPERATIONS_LEAD - Operational activities
- COMPLIANCE_OFFICER - Compliance and audits
- VIEWER - Read-only access
Team-Based Access
Users can only access data for teams they belong to:Check Your Permissions
Multi-Factor Authentication (MFA)
Enable MFA for enhanced security:Enroll MFA
Verify MFA
Session Management
Get Current Session
Sign Out
Listen to Auth Changes
Security Best Practices
Store Credentials Securely
Store Credentials Securely
- Use environment variables for API keys
- Never commit credentials to version control
- Rotate API keys regularly
- Use different keys for different environments
Use HTTPS Only
Use HTTPS Only
- Always use HTTPS for API requests
- Enable HSTS in your application
- Validate SSL certificates
Implement Rate Limiting
Implement Rate Limiting
- Respect API rate limits
- Implement exponential backoff for retries
- Cache responses when appropriate
Handle Token Expiry
Handle Token Expiry
- Implement automatic token refresh
- Handle 401 errors gracefully
- Store refresh tokens securely
Enable MFA
Enable MFA
- Require MFA for admin accounts
- Use TOTP or WebAuthn
- Provide backup codes
Troubleshooting
Common Issues
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
Cause: Insufficient permissionsSolution:
- Check your user role and permissions
- Verify you’re a member of the required team
- Contact your admin to grant access
Token Refresh Fails
Token Refresh Fails
Cause: Invalid or expired refresh tokenSolution:
- Sign in again to get a new session
- Check refresh token is stored correctly
- Verify refresh token hasn’t been revoked