Skip to content

feat: seed Enterprise SSO (SAML) login IDP in auth_providers (OHE-4193) - #1445

Merged
tofarr merged 2 commits into
mainfrom
feat/seed-saml-enterprise-sso-idp-migration
Nov 18, 2026
Merged

tofarr merged 2 commits into
mainfrom
feat/seed-saml-enterprise-sso-idp-migration

Conversation

@tofarr

@tofarr tofarr commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

I tested this on shared-2 - I set up an SAML idp in replicated and then deployed the new version and saw the values copied.

AGENT:


Why

Migration 189 seeds auth_providers login rows for GitHub/GitLab/Bitbucket so the OAuth v2 login page keeps the buttons the legacy login page had. The legacy page also showed an Enterprise SSO button when ENABLE_ENTERPRISE_SSO is set (the Replicated "Enterprise SSO (SAML)" option), but nothing seeds a row for it, so those installs lose the SAML button once OAuth v2 login is on. John Mason and Alona asked for this.

Summary

  • New migration 218_seed_enterprise_sso_login_idp.py, modelled on 189. When ENABLE_ENTERPRISE_SSO is true/1 and KEYCLOAK_CLIENT_ID is set, it seeds one is_idp OAuthProviderDetails row (provider_type='enterprise_sso') that reuses the Keycloak client and appends kc_idp_hint=enterprise_sso to the authorization URL. The chart's keycloak-config init container already creates that Keycloak SAML identity provider.
  • The row is inserted with enabled = true explicitly. Migration 196 made the column default to false, so omitting it (as 189 could) would hide the button.
  • Idempotent on the kc_idp_hint=enterprise_sso marker rather than provider_type, so an admin-added direct OIDC enterprise_sso row neither blocks nor gets removed. Downgrade deletes only the hinted row.
  • No legacy_keycloak_type: its validator only allows git providers, and there is no git token behind an SSO login. is_sso_provider already excludes rows with client_id == KEYCLOAK_CLIENT_ID, so licensing is unaffected.
  • Title is ENTERPRISE_SSO_DISPLAY_NAME, falling back to Company SSO (the Replicated default). Icon and colour are a generic shield and indigo, as there is no legacy button to copy.

Issue Number

Linear OHE-4193

How to Test

uv run pytest tests/unit/test_migration_218_seed_enterprise_sso_login_idp.py tests/unit/test_migration_graph.py (needs Docker). The new tests run real Alembic up/down against PostgreSQL and cover: true/1/TRUE, disabled values, missing Keycloak client, idempotency, coexistence with a direct OIDC row, secret encryption round-trip through AuthProvider, and downgrade. 22 tests pass together with the 189 migration tests; pre-commit passes. Not tested against a real Keycloak/Replicated install.

Video/Screenshots

I had this config in replicated...
image

When the cluster was updated, this became a config in Auth providers:

image

It is an OAuth provider - because it just connects to keycloak. The login flow works as previously...

Screen.Recording.2026-11-18.at.2.01.13.PM.mov

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • ENTERPRISE_SSO_DISPLAY_NAME is currently only set on the keycloak-config init container in OpenHands-Cloud's deployment.yaml, not on migrate-db. Until the chart also puts it in openhands.env, the row is titled Company SSO; admins can rename it. That follow-up is a chart change in OpenHands-Cloud.
  • A migration runs once, so toggling Enterprise SSO off later in Replicated will not disable this row. An admin can disable it, or a follow-up can reconcile at startup.
  • Applies to deployments that already run with OAuth v2 login; where the flag is off, the row is unused.

This PR was created by an AI agent (OpenHands) on behalf of Tim O'Farrell.

@tofarr can click here to continue refining the PR


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-ee785b1

Adds migration 218, modelled on 189, which seeds a Keycloak-routed login IDP
row (kc_idp_hint=enterprise_sso) when ENABLE_ENTERPRISE_SSO is set.

Resolves OHE-4193

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains migrations. Please synchronize before merging to prevent conflicts.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  migrations/versions
  218_seed_enterprise_sso_login_idp.py 72-90, 99-114, 133, 150-159, 181-182
Project Total  

This report was generated by python-coverage-comment-action

@tofarr tofarr changed the title Seed Enterprise SSO (SAML) login IDP in auth_providers Seed Enterprise SSO (SAML) login IDP in auth_providers (OHE-4193) Nov 18, 2026
@tofarr tofarr changed the title Seed Enterprise SSO (SAML) login IDP in auth_providers (OHE-4193) fix: Seed Enterprise SSO (SAML) login IDP in auth_providers (OHE-4193) Nov 18, 2026
@github-actions github-actions Bot added the type: fix A bug fix label Nov 18, 2026
@tofarr tofarr changed the title fix: Seed Enterprise SSO (SAML) login IDP in auth_providers (OHE-4193) feat: seed Enterprise SSO (SAML) login IDP in auth_providers Nov 18, 2026
@github-actions github-actions Bot added type: feat A new feature and removed type: fix A bug fix labels Nov 18, 2026
@tofarr
tofarr marked this pull request as ready for review November 18, 2026 14:02
@tofarr tofarr changed the title feat: seed Enterprise SSO (SAML) login IDP in auth_providers feat: seed Enterprise SSO (SAML) login IDP in auth_providers (OHE-4193) Nov 18, 2026

@hieptl hieptl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙏

@tofarr
tofarr enabled auto-merge (squash) November 18, 2026 14:07
@tofarr
tofarr merged commit 68bbbcf into main Nov 18, 2026
33 checks passed
@tofarr
tofarr deleted the feat/seed-saml-enterprise-sso-idp-migration branch November 18, 2026 14:13
@openhands-release-bot openhands-release-bot Bot added the released: 1.95.0 Shipped in 1.95.0 label Nov 19, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.95.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.95.0 Shipped in 1.95.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants