Overview
Nexus Access Vault uses Zitadel as its identity provider, implementing a secure OIDC (OpenID Connect) authentication flow with PKCE (Proof Key for Code Exchange). This guide walks you through the complete setup process.Prerequisites
Before you begin, ensure you have:- A Zitadel instance running (e.g.,
https://manager.kappa4.com) - Administrative access to your Zitadel console
- Access to your Nexus Access Vault database
- Netbird VPN configured (if using internal network mode)
Step 1: Create OIDC Application in Zitadel
Configure the Application
- Log in to your Zitadel console at
https://manager.kappa4.com - Navigate to your project
- Click Applications > New Application
- Configure the following settings:
- Select: Web
- Authentication Method: PKCE (Public Client)
Configure Required Scopes
Ensure the following scopes are enabled for your application:| Scope | Purpose |
|---|---|
openid | Required for OIDC authentication |
profile | Retrieves user’s name and profile info |
email | Retrieves user’s email address |
urn:zitadel:iam:org:project:id:zitadel:aud | Includes organization and role claims |
Step 2: Configure Role Claims
To enable role-based access control:- In your Zitadel project, navigate to Roles
-
Create the following roles:
adminoradministrator- Full system accessorg_admin- Organization administrationsupportorhelpdesk- Support accessuserormember- Standard user access
-
Ensure roles are included in ID tokens:
- Go to Project Settings > Token Settings
- Enable Include roles in ID token
- Enable Include organization info in claims
Step 3: Create Service Account (Optional)
For automatic group synchronization, create a service account with Management API access:- Navigate to Service Users > New Service User
- Create a service account (e.g.,
nexus-sync-service) - Grant the following permissions:
- Generate a Personal Access Token (PAT):
- Go to the service account details
- Click Personal Access Tokens > New
- Copy the token immediately (it won’t be shown again)
Step 4: Configure Environment Variables
Add the following to your.env file:
The
VITE_NETWORK_MODE setting restricts access to internal network only when set to "internal". This requires users to be connected to your Netbird VPN.Step 5: Database Configuration
Insert the Zitadel configuration into your Supabase database:Step 6: Test the Connection
Verify your configuration is working:Netbird Network Configuration (Optional)
If you want to restrict access to the internal Netbird network:Install Netbird on Server
Get Internal IP
Configure Firewall
Security Considerations
PKCE Implementation
The portal uses PKCE (Proof Key for Code Exchange) to prevent authorization code interception:- Code Verifier: A cryptographically random 32-byte string
- Code Challenge: SHA-256 hash of the code verifier
- Challenge Method: Always
S256(SHA-256)
src/hooks/useZitadelSSO.ts:33-49:
State Parameter Protection
The state parameter prevents CSRF attacks during the OAuth flow:Troubleshooting
Authentication Fails
Symptoms: User sees “Authentication failed” error Solutions:- Verify the client ID matches exactly
- Check redirect URI includes correct protocol and port
- Ensure Zitadel issuer URL is accessible
- Check browser console for detailed error messages
Groups Not Syncing
Symptoms: User logs in but has no permissions Solutions:- Verify service account token has
org.grant.readpermission - Check edge function logs:
supabase functions logs zitadel-api - Ensure user has roles assigned in Zitadel project
- Verify
sync_groupsis set totruein database configuration
PKCE Errors
Symptoms: “Invalid code verifier” error Solutions:- Ensure Zitadel application is configured for PKCE
- Verify code challenge method is set to
S256 - Check that sessionStorage/localStorage is available in browser
- Clear browser storage and try again