OpenID Connect (OIDC)
Authentication using penID Connect (OIDC) providers.
π OpenID Connect (OIDC) Login
Kurrier supports authentication using OpenID Connect (OIDC) providers.
Currently, Google login is available out of the box, but the architecture is provider-agnostic and additional providers such as GitHub, Microsoft, Auth0, Okta, Keycloak, Zitadel, and others can be added easily.
β¨ Currently Supported
- Google OIDC Login
Additional providers can be implemented by adding another OIDC route and provider configuration.
π§ How It Works
Kurrier uses the standard:
- OAuth 2.0 Authorization Code Flow
- PKCE (Proof Key for Code Exchange)
- OpenID Connect identity claims
The authentication flow is:
- User clicks βContinue with Googleβ
- Kurrier redirects the user to Google
- Google authenticates the user
- Google redirects back to Kurrier callback route
- Kurrier verifies the response
- User account + workspace are created automatically if they do not exist
- Session cookie is issued
- User is redirected into the workspace dashboard
π¦ Environment Variables
Add the following to your .env:
env
OIDC_GOOGLE_CLIENT_ID=your_google_client_id
OIDC_GOOGLE_CLIENT_SECRET=your_google_client_secretπ Creating Google OAuth Credentials
- Open Google Cloud Console
- Navigate to:
- APIs & Services β Credentials
- Click:
- Create Credentials β OAuth Client ID
- Choose:
- Web Application
Authorized Redirect URI
Add:
http://localhost:3000/api/auth/oidc/google/callbackFor production:
https://your-domain.com/api/auth/oidc/google/callbackπ Route Structure
Google OIDC flow is implemented using App Router route handlers.
app/
βββ api/
βββ auth/
βββ oidc/
βββ google/
βββ route.ts
βββ callback/
βββ route.tsπ Start Route
The start route:
/api/auth/oidc/googleResponsibilities:
- Discover Google OIDC configuration
- Generate PKCE verifier/challenge
- Generate state token
- Store temporary cookies
- Redirect user to Google authorization endpoint
β© Callback Route
The callback route:
/api/auth/oidc/google/callbackResponsibilities:
- Validate PKCE verifier
- Validate state
- Exchange authorization code for tokens
- Read user claims
- Create or locate user
- Create auth provider/account records
- Create session cookie
- Redirect into workspace
π Database Records
Successful OIDC login creates:
users
Primary application user.
workspaces
Default workspace for the user.
workspace_members
Workspace ownership membership.
auth_providers
OIDC provider metadata for the workspace.
auth_accounts
Provider-linked external identity record.
π Security Notes
Kurrier uses:
- PKCE
- State validation
- HttpOnly session cookies
- Verified Google email requirement
- Signed JWT session tokens
Sensitive provider tokens are never logged in production.
β Adding More Providers
Additional providers can be added by implementing another OIDC route pair.
Examples:
/api/auth/oidc/github
/api/auth/oidc/microsoft
/api/auth/oidc/keycloakMost providers only require:
- Discovery URL
- Client ID
- Client Secret
- Redirect URI
- Scope configuration
The rest of the flow remains identical.
π References
- OpenID Connect: https://openid.net/connect/
- OAuth 2.0 PKCE: https://oauth.net/2/pkce/
- openid-client: https://github.com/panva/openid-client