Skip to content

M8F-90 - Move Super-Admin Role & super-Admin User from Tenant Realms to Master Realm (Keycloak)#75

Merged
andrepestana-aot merged 7 commits intoAOT-Technologies:mainfrom
andrepestana-aot:feature/M8F-90-move-super-admin-role-super-admin-user-from-tenant-realms-to-master-realm-keycloak
Mar 13, 2026
Merged

M8F-90 - Move Super-Admin Role & super-Admin User from Tenant Realms to Master Realm (Keycloak)#75
andrepestana-aot merged 7 commits intoAOT-Technologies:mainfrom
andrepestana-aot:feature/M8F-90-move-super-admin-role-super-admin-user-from-tenant-realms-to-master-realm-keycloak

Conversation

@andrepestana-aot
Copy link
Collaborator

@andrepestana-aot andrepestana-aot commented Mar 12, 2026

JIRA Ticket

https://aottech.atlassian.net/browse/M8F-90

Description

This PR moves the global super-admin out of tenant realms and into the Keycloak master realm, and updates the M8Flow auth flow so global tenant administration works without requiring a tenant-scoped realm or tenant context.

image image

What changed

  • Removed super-admin role/user creation from tenant realm provisioning.
  • Ensured super-admin exists only in the Keycloak master realm.
  • Ensured the master realm also has a browser-login client for M8Flow (spiffworkflow-backend) instead of relying on tenant realm clients.
  • Added/updated local Keycloak bootstrap so the master realm client, role, and user are provisioned automatically in Docker/local development.

Backend auth and tenant-context changes

  • Added support for a master auth configuration even when it is not explicitly present in .env, so master login can be resolved on demand.
  • Updated authentication identifier resolution so global tenant-management requests can use the master realm correctly.
  • Updated login_return handling so the Keycloak master callback is not treated as a tenant-scoped login.
  • Updated refresh-token persistence so master-realm users do not try to store master as an m8flow_tenant foreign key.
  • Exempted global/non-tenant auth endpoints such as /permissions-check from tenant-context enforcement where appropriate.
  • Fixed backend auth cookie handling for IP-based frontend URLs by avoiding invalid cookie Domain values like 192.168.1.105:8001.

Frontend changes

  • Added a Global admin sign in path from the tenant-selection page.
  • Prevented multitenant routing from forcing a global admin back through tenant selection after login.
  • Fixed login redirect URL handling for relative paths.
  • Improved stale tenant handling so old tenant selections do not trap users in broken login flows.

Config / docs

  • Updated sample config and Keycloak setup documentation to reflect the new master-realm super-admin model.
  • Clarified tenant-context exemption naming in code (TENANT_CONTEXT_EXEMPT_PATH_PREFIXES).

Result

super-admin is global and exists only in Keycloak master.
Tenant realms no longer create or contain super-admin.
Global admins can log in through the master realm and manage tenants without tenant-scoped auth.
Tenant-specific admin behavior remains unchanged.

Type

  • Feature
  • Bug fix
  • Documentation
  • Other

Changes

  • Backend
  • Frontend
  • Documentation

Testing

  • Added/updated focused unit coverage for:
    • master auth config injection
    • master login callback handling
    • refresh-token storage for master logins
    • cookie handling for IP-based frontend URLs
    • tenant-context exemption for /permissions-check

Related Issues

Closes #

@andrepestana-aot andrepestana-aot self-assigned this Mar 12, 2026
@andrepestana-aot andrepestana-aot marked this pull request as ready for review March 12, 2026 01:30
Copy link
Collaborator

@auslin-aot auslin-aot left a comment

Choose a reason for hiding this comment

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

Avoid changes in the spiffworkflow-backend & spiffworkflow-frontend folders

Copy link
Collaborator

@auslin-aot auslin-aot left a comment

Choose a reason for hiding this comment

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

Please resolve conflicts

…-super-admin-role-super-admin-user-from-tenant-realms-to-master-realm-keycloak
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
21 Security Hotspots
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@andrepestana-aot andrepestana-aot merged commit 1563170 into AOT-Technologies:main Mar 13, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants