SSO Integration
Gatewyse supports enterprise SSO via OpenID Connect (OIDC) and SAML 2.0. When SSO is enabled for a tenant, users authenticate through your identity provider (IdP) and are automatically provisioned in the gateway.
Prerequisites
- Admin access to Gatewyse
- An identity provider that supports OIDC or SAML (e.g., Okta, Azure AD, Google Workspace)
Supported SSO Providers
The gateway recognizes these provider types in the tenant SSO configuration:
oidc— Generic OpenID Connectgoogle— Google Workspace (uses OIDC)microsoft— Microsoft Entra ID / Azure AD (uses OIDC)okta— Okta (uses OIDC)saml— Generic SAML 2.0
All OIDC-type providers follow the same code path; the provider name is used for display purposes.
Option A — OIDC Configuration
Step 1 — Set Environment Variables
Configure the following environment variables on the gateway server:
# Base URL for SSO callbacks (must be reachable by the IdP)SSO_CALLBACK_BASE_URL=https://gateway.example.com
# Admin dashboard URL (used for post-login redirects)ADMIN_URL=https://admin.example.comIn production, SSO_CALLBACK_BASE_URL must always be set to prevent Host header injection.
Step 2 — Register the Application in Your IdP
In your identity provider (e.g., Okta):
- Create a new OIDC application (Web type).
- Set the Sign-in redirect URI to:
https://gateway.example.com/api/auth/sso/callback - Set the Sign-out redirect URI to:
https://admin.example.com/login - Note the Client ID, Client Secret, and Issuer URL.
- Ensure the application grants
openid,email, andprofilescopes.
Step 3 — Configure the Tenant
In the admin dashboard, navigate to Settings for your tenant and enable SSO:
- Set SSO Provider to
oidc(orokta,google,microsoft). - Enter the Issuer URL — for Okta this looks like
https://your-org.okta.com. - Enter the Client ID and Client Secret from the IdP application.
- Optionally override Scopes (default:
openid email profile). - Toggle SSO Enabled to on.
- Save.
Step 4 — Test the Login Flow
- Open the admin dashboard login page.
- Click Sign in with SSO and enter your tenant slug.
- The gateway redirects to
GET /api/auth/sso/:tenantSlug/initiate, which builds the OIDC authorization URL and redirects to your IdP. - Authenticate at the IdP.
- The IdP redirects back to
GET /api/auth/sso/callbackwith an authorization code. - The gateway exchanges the code for tokens, extracts the user profile (email, name), and auto-provisions the user if they do not exist.
- JWT tokens are set as HttpOnly cookies, and you are redirected to the dashboard.
Option B — SAML Configuration
Step 1 — Set Environment Variables
Same as OIDC: set SSO_CALLBACK_BASE_URL and ADMIN_URL.
Step 2 — Register the Application in Your IdP
In your SAML IdP (e.g., Okta or Azure AD):
- Create a new SAML 2.0 application.
- Set the ACS (Assertion Consumer Service) URL to:
https://gateway.example.com/api/auth/sso/saml/acs - Set the Entity ID / Issuer to a unique identifier, for example
ai-gateway-prod. - Configure attribute mappings for
email,firstName,lastName. - Download or copy the IdP Certificate (X.509 PEM format).
- Note the SSO URL (IdP entry point).
Step 3 — Configure the Tenant
- Set SSO Provider to
saml. - Enter the Entry Point — the IdP’s SSO URL.
- Enter the Issuer — the Entity ID you configured.
- Paste the Certificate (PEM format, without BEGIN/END headers).
- Toggle SSO Enabled to on.
- Save.
Step 4 — Test the Login Flow
- Click Sign in with SSO on the login page.
- The gateway redirects to
GET /api/auth/sso/:tenantSlug/initiate, which builds a SAML AuthnRequest and redirects to your IdP. - Authenticate at the IdP.
- The IdP POSTs the SAML assertion to
POST /api/auth/sso/saml/acs. - The gateway validates the signed assertion, extracts the user profile, and auto-provisions the user.
- JWT tokens are set as HttpOnly cookies, and you are redirected to the dashboard.
User Auto-Provisioning
When a user authenticates via SSO for the first time:
- A new user record is created with the
usersystem role. - The user’s email, first name, and last name are populated from the IdP profile.
- An
ssoProviderIdis stored (e.g.,oidc:sub-idorsaml:nameID) for future login matching. - Subsequent logins update the
lastLogintimestamp.
Security Considerations
- SSO state is stored in Redis with a 10-minute TTL and is deleted after retrieval to prevent replay attacks.
- SAML assertions are validated with
wantAssertionsSigned: true. - Tokens are transmitted via HttpOnly cookies, never in URL parameters.
- In development mode, insecure OIDC requests are permitted for local testing; in production this is disabled.
Next Steps
- Configure role mapping from IdP groups to gateway roles
- Set up Budget Management for SSO-provisioned users
- Review SSO login events in the Audit Logs dashboard