Overview
The AGO platform implements a multi-authentication system that tries different authentication methods in sequence until one succeeds. This approach ensures compatibility with various client types while maintaining security standards.How Multi-Authentication Works
When a request is received, AGO’s authentication system processes it in the following order:- Clerk JWT Authentication: Checks for
Authorization: Bearer <token>header - Reverse Proxy Authentication (deployment-specific): Checks for headers set by an authenticating reverse proxy, if configured
- Widget Authentication: Checks for the
X-User-Anon-Idheader - API Key Authentication: Checks for
X-API-Keyheader
Reverse proxy authentication is only active in deployments that use an authenticating reverse proxy. Most deployments use Clerk JWT, Widget, or API Key authentication.
Available Authentication Methods
AGO supports the following authentication mechanisms:- Clerk JWT
- Widget
- API Key
Use Case: Primary authentication for web applications and authenticated usersHow It Works: Uses JSON Web Tokens (JWT) issued by Clerk for user authentication. The JWT is sent via the
Authorization: Bearer <token> header.Best For:- Web applications
- Mobile applications
- Authenticated user sessions
- Multi-tenant environments
Configuration
Clerk authentication requires your Clerk instance’s JWKS URL to be configured in the AGO backend settings. This URL points to Clerk’s public keys used to verify JWT signatures.How It Works
- Request Received: AGO receives a request with
Authorization: Bearer <jwt-token>header - JWKS Retrieval: The system fetches the JSON Web Key Set (JWKS) from Clerk (cached for 1 hour)
- Token Verification: The JWT is verified using RS256 algorithm and validated against Clerk’s public keys
- User Creation/Update: User is created or updated based on JWT claims:
- Email from
emailclaim - First name from
firstNameclaim - Last name from
lastNameclaim - Clerk user ID from
subclaim
- Email from
- Organization Linking: User is automatically linked to their organization based on email domain
- Access Control: System verifies the user has access to the current tenant
- Request Processing: The request proceeds with the authenticated user
Example Request
Security Considerations
- JWT tokens are verified using RS256 asymmetric encryption
- JWKS is cached for performance (1 hour TTL)
- Tokens are validated for audience:
https://api.clerk.com - User information is automatically synchronized on each request
- Access control is enforced at the tenant level
Troubleshooting
JWT verification fails- Verify token hasn’t expired
- Check that JWKS URL is accessible
- Ensure token signature is valid
- Confirm audience claim matches configuration
- Check user permissions in the admin interface
- Contact your administrator if user creation errors persist
- Verify JWT claims include required fields (email, sub)
- Ensure Clerk user ID format is valid
Security Best Practices
General Security Guidelines
- HTTPS Only: All authentication methods must be used over HTTPS in production
- Key Rotation: Regularly rotate API keys and secrets (recommended: every 90 days)
- Environment Separation: Use different credentials for development, staging, and production
- Least Privilege: Grant only necessary permissions to users and systems
- Audit Logging: Monitor authentication attempts and access patterns
- Rate Limiting: Implement rate limiting to prevent brute force attacks
Authentication-Specific Guidelines
- JWT Tokens: Keep tokens short-lived and implement proper refresh token flows
- API Keys: Store securely in environment variables or secret management systems
- Widget Keys: Configure allowed domains to prevent unauthorized usage
What NOT to Do
- ❌ Don’t commit API keys or secrets to version control
- ❌ Don’t share credentials across environments
- ❌ Don’t use simple or predictable keys
- ❌ Don’t send credentials over unencrypted connections
- ❌ Don’t log sensitive authentication data
- ❌ Don’t share API keys in public documentation or examples
Access Control & Permissions
Beyond authentication, AGO implements fine-grained access control:Agent Permissions
Control which agents users can access
Access Control Rules
Define rules for user access
Access Control Examples
Practical examples of access control configuration
User Impersonation
Temporarily assume another user’s identity for support purposes
Configuration
All authentication methods are configured through backend settings:- API Key: For server-to-server authentication
- Allowed Domains: For widget domain validation
- JWT Configuration: For Clerk and widget JWT authentication
- Default Permissions: For widget users (authenticated and anonymous)
Troubleshooting
Common Issues
Authentication fails for all methods
Authentication fails for all methods
- Check that the request includes proper authentication headers
- Verify credentials match configuration
- Review server logs for specific error messages
- Ensure the authentication method is properly configured
CORS errors with widget authentication
CORS errors with widget authentication
- Add the widget domain to
widget_allowed_domains - Ensure HTTPS is used on both ends
- Check browser console for specific CORS errors
JWT verification fails
JWT verification fails
- Verify token hasn’t expired
- Check that public keys are properly configured
- Ensure token signature is valid
- Confirm JWKS URL is accessible
API key rejected
API key rejected
- Confirm API key matches the configured value
- Check that the
X-API-Keyheader is being sent - Verify no whitespace or formatting issues in the key
- Ensure the header name is exactly
X-API-Key(case-sensitive)
Widget authentication fails
Widget authentication fails
- Verify the Origin header is in the allowed domains list
- Ensure the X-User-Anon-Id header is present
- Review widget configuration in admin panel
Authentication order issues
Authentication order issues
- Remember that Clerk auth is tried first, so if a Bearer token is present, it will be used
- Widget auth is only tried if Clerk auth fails
- API key auth is attempted last
Getting Help
For additional support:- Check the specific authentication method documentation
- Review server logs for detailed error messages
- Verify configuration in AGO admin panel
- Contact your system administrator or AGO support team
Related Documentation
Widget Authentication
Authentication for embedded widget integrations
API Key Authentication
Server-to-server API key authentication
Agent Permissions
Control which agents users can access
Access Control Rules
Define rules for user access
Access Control Examples
Practical examples of access control configuration
