Overview
Zitadel SSO provides:- Secure OIDC flow with PKCE (Proof Key for Code Exchange)
- Multi-provider support (self-hosted and cloud)
- Automatic role extraction from Zitadel claims
- External IdP integration (Google, etc.)
- Centralized user management
Supported Providers
NeoSC supports two Zitadel configurations:Provider 1: Self-Hosted (On-Premise)
- Callback:
https://neosc-vdi-preview.preview.emergentagent.com/auth/callback - Post Logout:
https://neosc-vdi-preview.preview.emergentagent.com
Provider 2: Zitadel Cloud
- Callback:
https://neosc-vdi-preview.preview.emergentagent.com/auth/callback - Post Logout:
https://neosc-vdi-preview.preview.emergentagent.com
OIDC Authentication Flow
User Initiates Login
User clicks SSO button in the NeoSC interface. Frontend generates:
- PKCE code verifier (random string)
- Code challenge (SHA-256 hash of verifier)
- State parameter for CSRF protection
verifier, provider, authority, client_idUser Authenticates
User authenticates with Zitadel using:
- Email/Password (both providers)
- Google SSO (cloud provider)
- Custom IdP (on-premise provider)
Backend Exchanges Code
Backend calls Zitadel token endpoint:Receives:
access_token, id_token, refresh_tokenToken Exchange Endpoint
Backend endpoint to exchange authorization code for tokens (avoids CORS issues): Location:backend/server.py:335
SSO Login Endpoint
Creates or updates user and generates NeoSC session token: Location:backend/server.py:228
Role Extraction
NeoSC automatically extracts roles from Zitadel claims:Role Claim Format
Role Determination Logic
Location:backend/server.py:245
- Role contains “admin” (any case)
- Role equals “administrator”
- Role equals “owner”
- Group contains “admin”
Frontend Configuration
Zitadel Config File
Location:frontend/src/config/zitadel.js
Zitadel Configuration
Application Setup in Zitadel
Create Application
In Zitadel console, create a new application:
- Application Type: User Agent (Public Client - SPA) or Web
- Name: “NeoSC” or your preferred name
Environment Variables
Backend (.env):Testing SSO
Create Test User
Create a user in Zitadel with appropriate roles:
- For admin access: assign “admin” or “neosc” role
- For user access: no special role needed
Test Login Flow
- Navigate to login page
- Click SSO button (“NeoSC SAP SSO” or “Secure Connect”)
- Authenticate with Zitadel
- Verify redirect to NeoSC dashboard
Security Considerations
PKCE Required
PKCE Required
Always use PKCE (S256) for the authorization code flow. Never use implicit flow or authorization code without PKCE for public clients.
State Parameter
State Parameter
Always include and validate the state parameter to prevent CSRF attacks.
Redirect URI Validation
Redirect URI Validation
Zitadel strictly validates redirect URIs. Ensure exact match including protocol, domain, and path.
Token Storage
Token Storage
Store Zitadel tokens securely. The backend handles token exchange to prevent token exposure to the client.
Role Claim Security
Role Claim Security
Always validate and sanitize role claims from the identity provider before assigning application permissions.
Troubleshooting
Redirect URI Mismatch
Redirect URI Mismatch
Error:
redirect_uri_mismatchSolution: Verify the redirect URI in your code exactly matches the URI configured in Zitadel (including trailing slashes).Invalid Code Verifier
Invalid Code Verifier
Error:
invalid_grant or invalid_code_verifierSolution: Ensure the code verifier is correctly stored in sessionStorage and sent to the backend. Verify PKCE is enabled in Zitadel.Missing Roles
Missing Roles
Error: User has no roles in NeoSCSolution:
- Verify roles are assigned in Zitadel project
- Check scope includes
urn:zitadel:iam:org:projects:roles - Inspect ID token claims for role data
CORS Errors
CORS Errors
Error: CORS policy blocking token exchangeSolution: Use the backend
/api/auth/token-exchange endpoint instead of calling Zitadel directly from the frontend.Next Steps
MFA Configuration
Configure multi-factor authentication
Local Authentication
Set up local JWT authentication
API Reference
View authentication API endpoints
User Management
Manage users and roles