SSO Settings

Azure Government Cloud Entra ID (Azure AD) single sign-on configuration with OIDC Authorization Code flow, PKCE, MFA enforcement, and role mapping.

Overview

Federal and enterprise customers require SSO integration with their identity provider. The ThreatOps SSO module implements OIDC Authorization Code flow with PKCE targeting Azure Government Cloud (login.microsoftonline.us). This is critical for FedRAMP compliance, as it ensures centralized identity governance, MFA enforcement via the amr claim, and Just-In-Time (JIT) user provisioning. The SSO Settings page allows administrators to view configuration, test connectivity, manage allowed email domains, and map Azure AD groups to ThreatOps roles.

What Was Proposed

What's Built Complete

Architecture

OIDC Authentication Flow

The SSO flow begins when the frontend redirects to /api/v1/sso/auth/login. The backend generates a PKCE code verifier/challenge and nonce, then redirects to Azure Gov Cloud's authorization endpoint. After user authentication and MFA, Azure returns an authorization code to /api/v1/sso/auth/callback. The backend exchanges the code for tokens, validates the ID token against JWKS, checks MFA status, provisions the user via JIT, and issues a local JWT session token.

1. Browser -> /api/v1/sso/auth/login
2. API generates PKCE (code_verifier + S256 challenge) + state + nonce
3. Redirect -> login.microsoftonline.us/{tenant}/oauth2/v2.0/authorize
4. User authenticates + MFA at Azure Gov Cloud
5. Azure redirects -> /api/v1/sso/auth/callback?code=...&state=...
6. API exchanges code for tokens (POST to token_endpoint with code_verifier)
7. Validate ID token: RS256 signature, issuer, audience, exp, nbf, nonce
8. Check amr claim for MFA completion
9. JIT provision/update user in local DB
10. Map Azure AD groups/roles to ThreatOps roles
11. Issue local JWT with permissions
12. Redirect to frontend /auth/callback?token=...&mfa=true

Routing

Frontend Route
/sso-settings
API Prefix
/api/v1/sso

Prerequisites

Data Model

SSO Settings Response

FieldTypeDescription
sso_enabledbooleanWhether SSO is active
gov_cloudbooleanAzure Government Cloud mode
tenant_idstringAzure AD tenant ID
client_idstringApp registration client ID
allowed_domainsstring[]Allowed email domains for SSO login
role_mappingsdictAzure AD group name -> ThreatOps role

Role Mapping Defaults

Azure AD GroupThreatOps Role
ThreatOps-SuperAdminssuper_admin
ThreatOps-Adminsadmin
ThreatOps-Analystsanalyst
ThreatOps-Viewersviewer
ReportViewerscustomer_viewer
(External tenant)customer_viewer (auto)
(Global Admin wid)super_admin (auto)

API Endpoints

MethodEndpointDescription
GET/auth/loginInitiate SSO login (redirect to Azure)
GET/auth/callbackHandle OIDC callback, exchange code, provision user
POST/auth/tokenProgrammatic code exchange (API-based flow)
GET/auth/logoutFederated logout from Azure AD
GET/auth/metadataSSO/OIDC metadata for frontend
GET/auth/statusCheck current SSO session status
GET/settingsGet SSO settings (admin only)
POST/settings/role-mappingsUpdate role mappings (admin only)
GET/connection-testTest Azure Gov Cloud connectivity

UI Description

The page header shows "SSO Settings" with two status badges: "Azure Gov Cloud" (blue) and "FedRAMP High" (green).

SSO Configuration Card

Displays Enabled/Disabled status badge, Azure Tenant ID, Client ID, Authority (login.microsoftonline.us), and Cloud Environment in a 2-column grid with monospace font for IDs.

Connection Test Card

A "Test Connection" orange button triggers an OIDC discovery endpoint check. Results show connected/failed status with issuer information or error details.

Allowed Email Domains

An input field with "Add" button allows adding new domains. Existing domains appear in a list with trash icons for removal. Empty state says "No domain restrictions configured."

Role Mappings

A form to add new group-to-role mappings (input + role selector + Add button). Existing mappings appear in a table with group name, color-coded role badge (purple=super_admin, orange=admin, blue=analyst, grey=viewer), and delete button. A "Save Mappings" orange button persists changes.

Recent SSO Login Attempts

A table showing email, timestamp, success/failed badge, MFA verification status, and error details for recent login attempts.

Source Files

ComponentPath
API Routerplatform/api/app/routers/sso.py
SSO Serviceplatform/api/app/services/sso_service.py
Frontend Pageplatform/frontend/src/app/sso-settings/page.tsx