Skip to content

Configure OIDC SSO Login as an Administrator (Keycloak Example)

This document describes how to configure an OIDC SSO Provider in SwanLab, as well as the callback address and field mapping required on the IdP side.

1. Feature Introduction

OIDC (OpenID Connect) is a standard protocol that adds an identity layer on top of OAuth2. SwanLab obtains the authorization endpoint, Token endpoint, and JWKS through Issuer Discovery. After completing the authorization code flow, SwanLab validates the ID Token and maps the third-party user from the ID Token claims.

Account policy:

  • First-time OIDC login automatically creates and binds a SwanLab account.
  • Bound users log in directly after authentication succeeds.

2. Procedure

  1. In the SwanLab administrator control panel, click to create OIDC.

  1. Fill in the basic configuration.
FieldRequiredDescription
NameYesUnique Provider identifier. Up to 25 characters. Only letters, digits, underscores, and hyphens are allowed
Display nameYesName shown on the login button. Up to 100 characters

  1. Fill in the OIDC configuration.
FieldRequiredDescription
Client IDYesClient ID configured on the IdP. It is usually manually entered when configuring the IdP
Client SecretYesOAuth2 Client Secret assigned to SwanLab by the IdP. It is usually generated by the IdP and must be obtained from the IdP
Authorization URLYesOIDC Issuer URL. SwanLab performs Discovery based on this address. Note that this is not a specific API endpoint
ScopesNoSpace-separated authorization scopes. Defaults to openid profile when left empty, but manual configuration is recommended

For "Authorization URL", you only need to enter the OIDC Issuer URL. Unlike OAuth2, it does not need to point to a specific path, because OIDC defines route discovery in the standard protocol. If your enterprise IdP configuration does not comply with the standard, adjust it on the IdP side.

  1. Fill in user mapping.
FieldRequiredDescription
User ID fieldYesField name corresponding to the third-party unique user ID
Username fieldYesField name corresponding to the third-party username. It is used as the default username during automatic account creation
Recommended unique user ID fieldRecommended username field
subpreferred_username, name

  1. Fill in the display configuration.

We recommend using an online link for the Icon URL.

  1. Enable the IdP.

After creation, you can view existing IdPs in the list. After enabling one, you can test and use it:

  1. View it in the login list.

3. IdP-side Configuration

Configure the Redirect URI in the IdP OIDC application:

text
https://<SwanLab external access address>/api/auth/sso/oidc/callback/<Provider name>

Ensure that this address exactly matches the address generated by SwanLab, including protocol, domain, port, subpath, and Provider name.

Example:

text
https://swanlab.example.com/api/auth/sso/oidc/callback/arui-oidc

We recommend enabling Authorization Code Flow and ensuring that an ID Token is returned.

The following uses Keycloak as an example:

The Client Secret is usually generated by the IdP. Copy it and fill it in the SwanLab configuration:

SwanLab caches IdP information for OIDC/SAML2 in the backend. If information on the IdP side changes, SwanLab may not synchronize the updates immediately. You can refresh the cache by modifying any field in the corresponding SwanLab configuration.