Login strategies
Let identities sign in with SAML single sign-on, and users with Google, GitHub, Facebook, Okta, Auth0 or any custom OAuth 2.0 provider.
Strategies add external login methods:
| Type | For | Providers |
|---|---|---|
saml | Identities | Any SAML 2.0 identity provider |
oauth | Users | google, github, facebook, okta, auth0 or custom |
Manage strategies in Access Management → Strategies or with /passport/strategy (passport:strategy:* actions).

OAuth for users
Create a strategy
For the built-in providers, provide your OAuth application's credentials:
curl -X POST https://api.example.com/api/passport/strategy \
-H "Authorization: IDENTITY <token>" -H "Content-Type: application/json" \
-d '{
"type": "oauth",
"icon": "login",
"options": {"idp": "google", "client_id": "<client id>", "client_secret": "<client secret>"}
}'okta and auth0 also need domain, the domain of your tenant.
In your provider's console, register this redirect URI:
<public-url>/passport/user/strategy/<strategyId>/completeLogin flow
The login is completed by the API, so your client only needs the strategy id:
Get the provider URL
Terminalcurl https://api.example.com/api/passport/user/strategy/<strategyId>/urlJSON{"url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&state=...", "state": "f3b1..."}Wait for the result and send the user to the provider
Start a login request with the
state, then openurlin a popup or a new tab. The login request stays open until the user finishes, for up to 60 seconds:JavaScriptconst {url, state} = await fetch(`${API}/passport/user/strategy/${strategyId}/url`).then(r => r.json()); const pending = fetch(`${API}/passport/login`, { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({state}) }).then(r => r.json()); window.open(url, "_blank"); const {token} = await pending;Use the token
The response is a normal user login:
{"scheme": "USER", "token": "..."}.
The first login creates the user. Its username is taken from the provider's response (upn, id, name_id or email), and its signUpStrategy records the strategy.
Custom OAuth providers
Describe each step of the OAuth flow:
{
"type": "oauth",
"name": "my-sso",
"title": "Company SSO",
"options": {
"idp": "custom",
"code": {
"base_url": "https://sso.example.com/oauth/authorize",
"params": {"client_id": "<client id>", "response_type": "code", "scope": "openid email"},
"method": "get"
},
"access_token": {
"base_url": "https://sso.example.com/oauth/token",
"params": {"client_id": "<client id>", "client_secret": "<client secret>", "grant_type": "authorization_code"},
"method": "post"
},
"identifier": {
"base_url": "https://sso.example.com/oauth/userinfo",
"method": "get"
},
"attributes": {"email": "email", "name": "name"}
}
}| Field | Description |
|---|---|
code | Where users authorize. Spica adds redirect_uri and state. |
access_token | Where the code is exchanged for an access token. |
identifier | Where user information is fetched with the access token. |
attributes | Maps user attributes to top-level fields of the user information response. They are stored, encrypted, on the user. |
Each step accepts base_url, params, headers and method (get or post).
SAML for identities
SAML lets your team sign in to the panel with your company's identity provider.
{
"type": "saml",
"name": "okta-saml",
"title": "Sign in with Okta",
"icon": "login",
"options": {
"ip": {
"login_url": "https://example.okta.com/app/.../sso/saml",
"logout_url": "https://example.okta.com/login/signout",
"certificate": "-----BEGIN CERTIFICATE-----..."
}
}
}| Field | Description |
|---|---|
options.ip.login_url | Required. The identity provider's SSO URL. |
options.ip.certificate | Required. The identity provider's signing certificate. |
options.ip.logout_url | Optional logout URL. |
options.sp | Optional service provider certificate and private_key. When left out, Spica creates a self-signed certificate valid for --passport-saml-certificate-ttl seconds. |
Configure your identity provider with Spica's service provider metadata:
<public-url>/passport/identity/strategy/<name>/metadataand the assertion consumer URL:
<public-url>/passport/identity/strategy/<strategyId>/completeThe panel shows SAML strategies on its login page. Programmatically, the flow mirrors OAuth: GET /passport/identity/strategy/<id>/url, then POST /passport/identify with {"state": ...}.