Skip to content

Support subdomain matching for Organizations in IdP redirect logic #40026

Description

@siddi0812

Description

When using the Organizations feature in Keycloak 26.2.2, domain-based redirection to the correct Identity Provider (IdP) only works if the email domain matches exactly the configured domain in the organization settings.

This leads to problems in real-world scenarios where users log in with email addresses that include subdomains (e.g. user@sub.example.com) while the organization is configured for example.com. The domain lookup fails and Keycloak either shows a login error or throws a NullPointerException.

Support for subdomain matching (e.g. *.example.com) or suffix-based resolution (e.g. endsWith("onmicrosoft.com")) is currently not available.

Discussion

No response

Motivation

Subdomain matching would improve usability and make the Organizations feature suitable for:

Microsoft 365 tenants that use subdomains like tenant.onmicrosoft.com
Multi-tenant environments where customers use shared top-level domains
Cases where departments or subsidiaries have their own subdomain
Avoiding hard-to-maintain lists of every possible subdomain

This would also reduce login failures and improve user experience in diverse enterprise environments.

Details

A potential solution could include:

Supporting wildcards in organization domain configuration (*.example.com)
Adding a fallback mechanism for partial matches (e.g., endsWith())
Allowing a checkbox in the UI to disable automatic domain-to-organization resolution for generic domains like gmail.com
We’re happy to contribute ideas or testing support if this feature is considered for a future release.

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

Metadata

Metadata

Assignees

Labels

kind/enhancementrelease/26.7.0

Fields

Value

None yet

Effort

None yet

Votes

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions