๐ OIDC SSO Setup Guide (Azure AD / Entra ID)
This guide walks through the complete setup of Single Sign-On (SSO) for X-AutoMate using Microsoft Entra ID (Azure AD) as the Identity Provider (IdP) via OpenID Connect (OIDC).
Throughout this guide, <your-backend-url> is the public URL of your X-AutoMate backend (for example https://devxautomate.bos.no) and <your-frontend-url> is the public URL users open in the browser. Always use the real deployment URLs โ never localhost.
โ๏ธ 1. Azure AD App Registrationโ
-
Go to Azure Portal โ Microsoft Entra ID โ Add โ App Registration โ New Registration.
-
Configure:
- Name:
x-automate(orx-automate-dev) - Supported account types: Single Tenant (or Multi-Tenant)
- Redirect URI:
- Platform: Web
- URI:
https://<your-backend-url>/main/api_v2/login/sso/callback
Include the/mainprefixThe backend API is served under the
/mainbase path. A redirect URI without it (https://<your-backend-url>/api_v2/login/sso/callback) will not work โ Azure will redirect to a path that does not exist and the login will fail. - Name:
-
Save:
- ๐ Client ID
- ๐ข Tenant ID
-
Create a Client Secret under Manage โ Certificates & Secrets (we'll need
Secret IDvalue forAZURE_AD_CLIENT_SECRETenv).
๐ซ Enable ID Tokensโ
Enable ID Tokens under Manage โ Authentication โ Settings โ Implicit Grant and Hybrid Flows.
๐ฅ 2. App Roles Setupโ
On Manage โ App roles โ Create app role
Display name, Value, Description Role values follow:
{project}_{role} (lower case project name and role with underscore separation)
Available roles:
admintesterdq_admindq_testertest_admin
Examples:
default_admindefault_testerdefault_dq_admindefault_dq_testerdefault_test_adminmyproject_testeretc
For Allowed member types field select Both (Users/Groups + Applications)
The {role} part of the Azure app role value is matched against the project role name in
X-AutoMate exactly, and the comparison is case-sensitive. Use the same spelling and the same
case on both sides:
- Azure value
default_adminโ projectdefault, roleadminโ X-AutoMate must have an OIDC project role named exactlyadminโ notAdmin, and not a synonym such asadministrator.
See ProjectRole Mapping for how to create the matching roles.
๐ค Assign Usersโ
On Enterprise Applications:
- Manage โ All applications
- Select the app you created at App registration step
- Manage โ Users and Groups โ Add User/Group โ Assign App Roles (select user and assign role)
The email address of the X-AutoMate user must be identical to the email address of the account in Entra ID. Users are matched by email when they log in through SSO, so a mismatch (a different domain, an alias, or a typo) means the login will not resolve to the expected user.
โ๏ธ 3. Environment Variablesโ
SSO_ENABLED=True
AZURE_AD_TENANT_ID=<tenant-id>
AZURE_AD_CLIENT_ID=<client-id>
AZURE_AD_CLIENT_SECRET=<client-secret>
AZURE_AD_REDIRECT_URI=https://<your-backend-url>/main/api_v2/login/sso/callback
AZURE_AD_AUTHORITY=https://login.microsoftonline.com
FRONTEND_BASE_URL=https://<your-frontend-url>
AZURE_AD_REDIRECT_URI must be the backend URL of the deployment you are configuring and must be
identical to the redirect URI registered in Azure (step 1), including the /main prefix.
FRONTEND_BASE_URL is where the backend sends the browser back to after the SSO callback,
including when the login fails. If it is not set it falls back to localhost, so a failed login
redirects to an address the user's browser cannot reach โ the login appears to end in a bare 302
with no indication of what went wrong. Always set it explicitly.
๐งฉ Role Claim Patternโ
Default:
^(?P<project>[^_]+)_(?P<role>.+)$
๐๏ธ 4. ProjectRole Mappingโ
Every Azure App Role must have a matching ProjectRole entry with source OIDC.
A newly created project โ including the default project โ has no OIDC project roles. Until an
administrator creates them, every SSO login fails because the role from Azure has nothing to match
against in the project. Create the OIDC roles before the first SSO login.
Create one entry per Azure app role, using the {role} part of the Azure value verbatim
(lower case, exactly as it appears in Azure):
{
"project_role_name":"admin",
"project_role_source":"OIDC"
}
So an Azure app role with value default_admin requires the project default to have an OIDC
project role named admin. Because the match is case-sensitive, a role named Admin or
administrator will not match default_admin.
๐ 5. SSO Login Flowโ
- Frontend calls
/api_v2/login/sso/authorize - User authenticates with Azure AD
- Azure redirects to callback
- Backend validates token
- User is auto-provisioned
- Roles are synchronized
- ID token is returned
๐งช SSO Test Pageโ
Available at:
https://<your-backend-url>/sso-test
Features:
- ๐ Login testing
- ๐ View claims
- ๐งฉ View parsed roles
- ๐ ๏ธ API testing
๐จ Troubleshootingโ
โ SSO is not enabledโ
Verify:
SSO_ENABLED=True
โ Login ends in a 302 with no error messageโ
FRONTEND_BASE_URL is not set, so the backend redirects errors to localhost instead of your
frontend. Set it to your frontend URL and retry โ the actual error will then be shown:
FRONTEND_BASE_URL=https://<your-frontend-url>
โ Signature verification failedโ
Use the id_token instead of access_token.
โ Redirect fails after authenticating with Azureโ
Verify the redirect URI includes the /main prefix and is identical in Azure and in
AZURE_AD_REDIRECT_URI:
https://<your-backend-url>/main/api_v2/login/sso/callback
โ A user with this email already existsโ
The email address returned by Entra ID already belongs to a local (username/password) X-AutoMate account, and SSO does not currently link an existing local account to an SSO identity. Either remove the local account before the first SSO login, or use a different email address for the SSO user.
โ User has no project accessโ
Verify:
- Azure App Role assignment
- Matching ProjectRole entry exists in the project with source
OIDC(these are not created by default โ see ProjectRole Mapping) - The role name matches the Azure value exactly, including case (
default_adminโadmin) - The user's email in X-AutoMate matches the email in Entra ID
- Correct claim pattern
โ Roles not appearingโ
Verify:
- App Roles exist
- App Roles are enabled
- User is assigned to the role