Authentication
Support Bot provides enterprise-grade authentication with multiple sign-in options, secure token management, and fine-grained authorization through role-based access control (RBAC).Authentication Methods
Support Bot supports multiple authentication providers:Local Auth
Email and password authentication with secure bcrypt hashing
Google OAuth
Sign in with Google Workspace or Gmail accounts
GitHub OAuth
Authenticate using GitHub accounts for developer teams
Microsoft OAuth
Azure AD / Microsoft 365 single sign-on integration
How Authentication Works
Choose Authentication Method
Users select their preferred sign-in method:Admins can enable or disable each provider in system settings.
JWT Token Structure
Support Bot uses JWT tokens with the following claims:Token Claims
user_id - User Identifier
user_id - User Identifier
Unique UUID for the authenticated user. Used to look up user details and permissions.
role - User Role
role - User Role
The user’s assigned role (e.g., “Admin”, “Basic User”). Used for basic authorization checks.
auth_provider - Authentication Method
auth_provider - Authentication Method
Which method was used to authenticate:
local, google, github, or microsoft.token_version - Global Revocation
token_version - Global Revocation
Version number that increments when all user tokens need to be invalidated (e.g., password change).
jti - Token ID
jti - Token ID
Unique identifier for this specific token. Used for individual token revocation (logout).
exp - Expiration Time
exp - Expiration Time
Unix timestamp when the token expires. Configurable via
JWT_EXPIRY environment variable.User Registration
Local Signup
Create a new account with email and password:- Validates email format and uniqueness
- Hashes password with bcrypt
- Creates user record with default role
- Creates local auth identity
- Returns success message
New users are assigned the “Basic User” role by default. Admins can change roles after registration.
OAuth Auto-Registration
OAuth users are automatically created on first login:- Automatic user provisioning
- Linking multiple OAuth providers to one account
- Seamless first-time login experience
OAuth Configuration
Google OAuth
Configure Google authentication:- Create a new project
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs
GitHub OAuth
Configure GitHub authentication:- Go to Developer Settings → OAuth Apps
- Register new application
- Set authorization callback URL
- Copy client ID and secret
Microsoft OAuth
Configure Microsoft / Azure AD authentication:- Go to Azure Active Directory → App registrations
- Create new registration
- Add redirect URI
- Generate client secret
- Copy application ID and tenant ID
Token Management
Getting Current User
Retrieve authenticated user details:- Validates the JWT token
- Checks if token is revoked
- Verifies token version
- Returns user profile with permissions
Logout
Revoke the current token:Password Management
Update or set password for local authentication:- Creates or updates local auth identity
- Hashes new password with bcrypt
- Increments token_version (invalidates all tokens)
- Forces re-authentication
Authorization (RBAC)
Support Bot uses role-based access control with granular permissions:Permission-Based Authorization
Protect routes with specific permissions:Multiple Permission Checks
Require any one of several permissions:Dynamic Permission Checks
Check permissions within route handlers:Security Features
Token Revocation
Support Bot supports both individual and global token revocation:Individual Revocation
Logout revokes a specific token using its JTI:
Global Revocation
Password changes invalidate all user tokens:
Password Security
Passwords are hashed using bcrypt with automatic salt generation:Bcrypt is intentionally slow (adaptive hashing) to resist brute-force attacks. This is a security feature, not a performance issue.
State Parameter (OAuth)
OAuth flows use encrypted state parameters to prevent CSRF attacks:Best Practices
Token Storage
Web Applications
Web Applications
Store tokens in memory or httpOnly cookies:✅ Memory (React state, Redux store)
✅ httpOnly cookies (set by backend)❌ localStorage (vulnerable to XSS)
❌ sessionStorage (vulnerable to XSS)
Mobile Applications
Mobile Applications
Use secure storage mechanisms:
- iOS: Keychain Services
- Android: EncryptedSharedPreferences
- React Native: react-native-keychain
Server-to-Server
Server-to-Server
Use environment variables or secret management:
- AWS Secrets Manager
- Azure Key Vault
- HashiCorp Vault
- Environment variables (never commit to git)
Token Refresh Strategy
Support Bot tokens are long-lived (30 days by default):- Shorter token lifetimes (
JWT_EXPIRY=1) - Implementing refresh tokens
- Requiring re-authentication for critical actions
Multi-Provider Accounts
Users can link multiple authentication providers to one account:Troubleshooting
OAuth Redirect URI Mismatch
If OAuth fails with “redirect_uri_mismatch”:- Check provider configuration: Ensure redirect URI in provider console matches your environment
- Verify environment variables: Confirm
*_REDIRECT_URImatches your actual callback URL - Test with exact match: Include protocol, domain, port, and path exactly
Token Validation Failures
If requests return 401 Unauthorized:- Check token format: Ensure “Bearer ” prefix is included
- Verify expiration: Tokens expire after
JWT_EXPIRYdays - Review revocation: User may have logged out or changed password
- Validate secret:
JWT_SECRET_KEYmust match between token creation and validation
Password Reset Not Working
If password updates fail:- Verify authentication: Ensure user is logged in with valid token
- Check provider: OAuth-only users need to set password first
- Review password requirements: Implement minimum complexity if needed
Next Steps
User Management
Learn how to manage users, roles, and permissions
Role & Permissions
Configure granular access control for your team
API Reference
Complete API documentation for authentication endpoints
Security Settings
Configure authentication providers and security policies