Overview
Thesso sub-client manages OIDC and SAML 2.0 enterprise connections,
domain-based enforcement, JIT provisioning, and sessions. It also exposes the
current LDAP direct-bind preview; that preview is not a general LDAP directory
integration and has the limitations documented below.
Enterprise SSO Connections
sso.createConnection()
Create a new SSO identity provider connection. You can create multiple connections for different domains or providers.SAML example
Parameters
string
required
A human-readable name for this connection (e.g.
"Okta Production").'oidc' | 'saml' | 'ldap'
required
The SSO protocol. Use
"oidc" for OpenID Connect, "saml" for SAML 2.0, or
"ldap" for the current LDAP direct-bind preview.string
The OIDC issuer URL. Required when
protocol is "oidc".string
OAuth 2.0 client ID from your identity provider. Required when
protocol is "oidc".string
OAuth 2.0 client secret from your identity provider. Required when
protocol is "oidc".string
The SAML metadata URL. Required when
protocol is "saml".string
The SAML ACS URL where the IdP posts assertions. Required when
protocol is "saml".string
The SAML service provider entity ID. Required when
protocol is "saml".string[]
Email domains to associate with this connection. Users with matching email domains are automatically routed to this IdP.
boolean
Enable just-in-time user provisioning. When
true, users are automatically created on first login. Defaults to false.string
The default role assigned to JIT-provisioned users (e.g.
"member", "admin").Record<string, string>
Custom attribute mapping for SAML assertions. Maps Grantex fields to IdP attribute names.
Response: SsoConnection
string
Unique connection identifier (e.g.
sso_conn_01HX...).string
The connection display name.
'oidc' | 'saml' | 'ldap'
The SSO protocol.
'active' | 'inactive' | 'error'
Current connection status.
string[]
Associated email domains.
boolean
Whether JIT provisioning is enabled.
string
ISO 8601 creation timestamp.
string
ISO 8601 last-updated timestamp.
The
clientSecret is never returned in responses. It is stored securely on the server.sso.listConnections()
List all SSO connections for your organization.Response: SsoConnectionList
SsoConnection[]
Array of SSO connection objects.
sso.getConnection()
Retrieve a single SSO connection by ID.Parameters
string
required
The connection ID to retrieve.
Response
Returns anSsoConnection object.
sso.updateConnection()
Update an existing SSO connection.Parameters
string
required
The connection ID to update.
string
Updated display name.
string[]
Updated list of associated email domains.
boolean
Enable or disable JIT provisioning.
string
Updated default role for JIT-provisioned users.
Record<string, string>
Updated SAML attribute mapping.
Response
Returns the updatedSsoConnection object.
sso.deleteConnection()
Delete an SSO connection. Users associated with this connection will no longer be able to log in via SSO.Parameters
string
required
The connection ID to delete.
Response
Returnsvoid.
sso.testConnection()
Test an SSO connection to verify that the IdP configuration is correct and reachable.Parameters
string
required
The connection ID to test.
Response: SsoTestResult
boolean
Whether the connection test passed.
string
Human-readable result message.
number
IdP response time in milliseconds.
Enforcement
sso.setEnforcement()
Enforce SSO login for your organization. When enabled, all members must authenticate through an SSO connection.Parameters
boolean
required
Whether SSO login is enforced for all organization members.
string[]
Roles exempt from SSO enforcement (e.g.
["owner"]). Exempt users can still log in with API keys.Response: SsoEnforcement
boolean
Whether SSO enforcement is active.
string[]
Roles that are exempt from the enforcement policy.
Session Management
sso.listSessions()
List active SSO sessions for your organization.Response: SsoSessionList
SsoSession[]
Array of active SSO session objects.
SsoSession contains:
string
Session identifier.
string
The user’s email address.
string
The SSO connection used for this session.
string
Display name of the SSO connection.
string
ISO 8601 session creation timestamp.
string
ISO 8601 session expiration timestamp.
sso.revokeSession()
Revoke an active SSO session, forcing the user to re-authenticate.Parameters
string
required
The session ID to revoke.
Response
Returnsvoid.
Enterprise Login Flow
sso.getLoginUrl() (enterprise)
Get the SSO authorization URL for a user based on their email domain. The domain is matched against configured connections to route the user to the correct IdP.Parameters
string
required
The email domain to match against configured SSO connections (e.g.
"mycompany.com").string
Override the redirect URI for this login request.
Response: SsoLoginResponse
string
The full authorization URL. Redirect the user here.
string
The matched SSO connection ID.
'oidc' | 'saml' | 'ldap'
The protocol of the matched connection.
sso.handleOidcCallback()
Handle the callback from an OIDC identity provider. Exchanges the authorization code for user information and provisions the user if JIT is enabled.Parameters
string
required
The authorization code from the OIDC callback.
string
required
The state parameter from the callback (used for CSRF protection).
Response: SsoCallbackResponse
string | null
The user’s email address from the IdP.
string | null
The user’s display name from the IdP.
string | null
The user’s subject identifier from the IdP.
string
The Grantex developer ID that the user has been mapped to.
string
The SSO connection that handled this authentication.
boolean
Whether the user was just-in-time provisioned during this login.
sso.handleSamlCallback()
Handle the callback from a SAML 2.0 identity provider. Validates the SAML assertion and provisions the user if JIT is enabled.Parameters
string
required
The base64-encoded SAML response from the IdP.
string
The RelayState parameter from the SAML callback.
Response
Returns the sameSsoCallbackResponse as handleOidcCallback().
sso.handleLdapCallback()
Authenticate a user with the LDAP direct-bind preview. Unlike OIDC and SAML, credentials are submitted directly. The built-in client binds a service account, constructs a user DN fromldapSearchFilter plus ldapSearchBase, and binds that
DN with the submitted password. It does not search entries, read attributes, or
retrieve group memberships.
Parameters
string
required
The username interpolated into the configured LDAP filter to construct the
user DN. The built-in preview does not perform a directory search.
string
required
The user’s LDAP password for bind authentication.
string
required
The SSO connection ID for the LDAP directory.
string
required
The organization/developer ID that owns the LDAP connection.
Response
ReturnsSsoCallbackResult. With the built-in LDAP client, groups is empty,
name and email are null, and mappedScopes therefore contains only
configured default scopes.
LDAP credentials are never stored by Grantex. They are used only for the bind
operations and discarded after authentication. LDAP search, attribute
retrieval, group lookup/mapping, and broad provider compatibility are not
supported by the built-in preview client.
Full Enterprise SSO Flow Example
Legacy Single-Config Methods
The following methods manage a single OIDC configuration per organization. They are retained for backward compatibility. For new integrations, use the enterprise connection methods above which support multiple IdPs, SAML, and domain-based routing.
sso.createConfig()
Create or update the OIDC SSO configuration for your organization.Parameters
string
required
The OIDC issuer URL (e.g.
https://accounts.google.com).string
required
OAuth 2.0 client ID from your identity provider.
string
required
OAuth 2.0 client secret from your identity provider.
string
required
The callback URL that your IdP redirects to after authentication.
Response: SsoConfig
string
The OIDC issuer URL.
string
The OAuth 2.0 client ID.
string
The configured callback URL.
string
ISO 8601 creation timestamp.
string
ISO 8601 last-updated timestamp.
The
clientSecret is never returned in responses. It is stored securely on the server.sso.getConfig()
Retrieve the current SSO configuration (without the client secret).Response
Returns anSsoConfig object.
sso.deleteConfig()
Remove the SSO configuration. After deletion, SSO login is disabled for the organization.Response
Returnsvoid.
sso.getLoginUrl() (legacy)
Get the OIDC authorization URL to redirect the user to for SSO login.Parameters
string
required
The developer ID of the organization initiating the SSO login.
Response: SsoLoginResponse
string
The full OIDC authorization URL. Redirect the user here.
sso.handleCallback()
Exchange the OIDC authorization code for user information after the identity provider redirects back.Parameters
string
required
The authorization code from the IdP callback.
string
required
The state parameter from the IdP callback (used for CSRF protection).
Response: SsoCallbackResponse
string | null
The user’s email address from the IdP.
string | null
The user’s display name from the IdP.
string | null
The user’s subject identifier from the IdP.
string
The Grantex developer ID that the user has been mapped to.