Documentation Index
Fetch the complete documentation index at: https://mintlify.com/iamngoni/heimdall/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Heimdall supports OAuth authentication with GitHub and GitLab. The OAuth flow allows users to authenticate using their existing provider accounts and automatically links repository access.GitHub OAuth
GET /api/auth/github/authorize
Initiates the GitHub OAuth flow by redirecting the user to GitHub’s authorization page.Query Parameters
Optional redirect path after successful authentication. Must be a relative path starting with
/.Response
Redirects to GitHub’s OAuth authorization page with the following scopes:read:user- Access to user profile informationuser:email- Access to user email addressesrepo- Access to repositories
Example Request
GET /api/auth/github/callback
Handles the OAuth callback from GitHub after user authorization.Query Parameters
Authorization code from GitHub.
CSRF protection state parameter.
Error code if authorization failed.
Human-readable error description.
Response
On success, redirects to the specifiednext path (or /repos/new by default) with a session cookie set.
Error Responses
Missing Authorization Code (400)
Invalid State Parameter (400)
GitHub Account Already Linked (302)
If the GitHub account is already linked to a different user, redirects to/settings?integration_error=github-account-in-use.
GitLab OAuth
GET /api/auth/gitlab/authorize
Initiates the GitLab OAuth flow by redirecting the user to GitLab’s authorization page.Query Parameters
Optional redirect path after successful authentication. Must be a relative path starting with
/.Response
Redirects to GitLab’s OAuth authorization page with the following scopes:read_user- Access to user profile informationread_repository- Read access to repositories
Configuration
The GitLab base URL is configurable via theGITLAB_BASE_URL environment variable (defaults to https://gitlab.com).
Example Request
GET /api/auth/gitlab/callback
Handles the OAuth callback from GitLab after user authorization.Query Parameters
Authorization code from GitLab.
CSRF protection state parameter.
Error code if authorization failed.
Human-readable error description.
Response
On success, redirects to the specifiednext path (or /repos/new by default) with a session cookie set.
Error Responses
Missing Authorization Code (400)
Invalid State Parameter (400)
GitLab Account Already Linked (302)
If the GitLab account is already linked to a different user, redirects to/settings?integration_error=gitlab-account-in-use.
OAuth Flow Details
First-Time Authentication
When a user authenticates via OAuth for the first time:- If a user with the same email exists, the OAuth account is linked to that user
- If no user exists, a new user account is created with:
- Email from the OAuth provider
- Display name from the provider profile
- Avatar URL from the provider profile
- A random password hash (OAuth users don’t use password login)
- A session token is created and returned as a cookie
- OAuth connection details are stored (access token, refresh token, scopes, expiry)
Linking to Existing Session
If a user is already logged in and initiates OAuth:- The OAuth account is linked to the current user
- If the OAuth account is already linked to a different user, an error is returned
- User avatar is updated from the OAuth provider
- The existing session is maintained (no new session created)
Security Features
- CSRF Protection: State parameter is validated to prevent cross-site request forgery
- Secure Cookies: Session cookies are HTTP-only and use
SameSite=Lax - Token Encryption: OAuth access tokens are encrypted before storage using AES-GCM
- Token Expiry: OAuth tokens with expiry times are tracked and can be refreshed