Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chamals3n4/OpenATS/llms.txt
Use this file to discover all available pages before exploring further.
Overview
OpenATS uses WSO2 Asgardeo for authentication and authorization. Asgardeo is a cloud-native identity and access management (IAM) solution that provides secure OAuth 2.0 and OpenID Connect authentication.The web application (
/web) integrates with Asgardeo for user authentication. The API itself currently doesn’t enforce authentication middleware on endpoints, but the frontend handles authentication flow.Authentication Flow
OpenATS uses the Authorization Code Flow with Asgardeo for secure user authentication:- User visits the OpenATS web application
- User clicks sign in and is redirected to Asgardeo
- User authenticates with Asgardeo
- Asgardeo redirects back to OpenATS with an authorization code
- Application exchanges the code for access tokens
- Access tokens are used to make authenticated requests
Setting Up Asgardeo
To enable authentication in your OpenATS deployment, you need to configure WSO2 Asgardeo.Step 1: Create an Asgardeo Account
- Visit https://asgardeo.io
- Sign up for a free account or log in
- Create a new organization
Step 2: Register Your Application
- In the Asgardeo console, navigate to Applications
- Click New Application
- Select Single-Page Application (for Next.js)
- Configure the application:
- Name: OpenATS
- Authorized redirect URLs:
http://localhost:3000/api/auth/callback - Allowed origins:
http://localhost:3000
Step 3: Configure Environment Variables
The OpenATS web application uses the@asgardeo/nextjs package for authentication. Configure the following environment variables:
.env.local
Replace
your_client_id, your_client_secret, and your_org with your actual Asgardeo application credentials.Protected Routes
The OpenATS web application uses middleware to protect routes. The following routes are public and don’t require authentication:/login- Login page/careers/*- Public job board/assessment/*- Public assessment pages for candidates
Middleware Implementation
The authentication middleware is implemented in/web/proxy.ts:
Making Authenticated Requests
When making API requests from the authenticated web application, you can access the user’s session and tokens.Getting User Information
Example API Call with Authentication
Using cURL with Authentication
For testing purposes, you can make authenticated requests using cURL with a bearer token:Sign In Component
The web application provides a sign-in button component from Asgardeo:Session Management
The Asgardeo integration handles session management automatically:- Session Storage: Sessions are stored securely using encrypted cookies
- Token Refresh: Access tokens are automatically refreshed when expired
- Sign Out: The
SignOutButtoncomponent handles sign-out flow
Security Best Practices
Use HTTPS in Production
Use HTTPS in Production
Always use HTTPS for production deployments to protect tokens in transit.
Secure Token Storage
Secure Token Storage
The
@asgardeo/nextjs package stores tokens securely in encrypted cookies. Never store tokens in localStorage or sessionStorage.Configure CORS Properly
Configure CORS Properly
Ensure your API server has proper CORS configuration to only allow requests from your web application domain.
Rotate Client Secrets
Rotate Client Secrets
Regularly rotate your Asgardeo client secrets in the Asgardeo console.
Troubleshooting
Redirect URI Mismatch
If you see a redirect URI mismatch error, verify that the redirect URLs in your Asgardeo application settings match your environment variables.Token Expiration
If you receive 401 errors, your access token may have expired. The Asgardeo package should handle automatic token refresh, but you can manually check the session validity:CORS Errors
If you encounter CORS errors when making API requests, ensure your API server includes proper CORS headers. The API uses thecors package which should be configured in your server setup.
Next Steps
API Overview
Learn about the API structure and response formats
Company Endpoints
Start making API calls to manage company data