mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
case insensitive match on organization identity provider domain
Closes #40253 Signed-off-by: ryan-morris <ryan@devenvy.com>
This commit is contained in:
parent
a62a2c4414
commit
cf8c837125
@ -259,10 +259,10 @@ public class OrganizationAuthenticator extends IdentityProviderAuthenticator {
|
||||
return false;
|
||||
}
|
||||
|
||||
// first look for an IDP that matches exactly the specified domain
|
||||
// first look for an IDP that matches exactly the specified domain (case-insensitive)
|
||||
IdentityProviderModel idp = organization.getIdentityProviders()
|
||||
.filter(broker -> IdentityProviderRedirectMode.EMAIL_MATCH.isSet(broker) &&
|
||||
domain.equals(broker.getConfig().get(OrganizationModel.ORGANIZATION_DOMAIN_ATTRIBUTE))).findFirst().orElse(null);
|
||||
domain.equalsIgnoreCase(broker.getConfig().get(OrganizationModel.ORGANIZATION_DOMAIN_ATTRIBUTE))).findFirst().orElse(null);
|
||||
|
||||
if (idp != null) {
|
||||
// redirect the user using the broker that matches the specified domain
|
||||
|
||||
@ -475,6 +475,30 @@ public abstract class AbstractBrokerSelfRegistrationTest extends AbstractOrganiz
|
||||
assertEquals(bc.getIDPAlias(), federatedIdentities.get(0).getIdentityProvider());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedirectToIdentityProviderAssociatedWithOrganizationDomainCaseInsensitive() {
|
||||
OrganizationResource organization = testRealm().organizations().get(createOrganization().getId());
|
||||
IdentityProviderRepresentation idp = organization.identityProviders().get(bc.getIDPAlias()).toRepresentation();
|
||||
idp.getConfig().put(OrganizationModel.ORGANIZATION_DOMAIN_ATTRIBUTE, "neworg.org");
|
||||
testRealm().identityProviders().get(bc.getIDPAlias()).update(idp);
|
||||
idp.setAlias("second-idp");
|
||||
idp.setInternalId(null);
|
||||
idp.getConfig().remove(OrganizationModel.ORGANIZATION_DOMAIN_ATTRIBUTE);
|
||||
testRealm().identityProviders().create(idp).close();
|
||||
getCleanup().addCleanup(testRealm().identityProviders().get("second-idp")::remove);
|
||||
organization.identityProviders().addIdentityProvider(idp.getAlias()).close();
|
||||
|
||||
openIdentityFirstLoginPage(bc.getUserEmail().toUpperCase(), true, idp.getAlias(), false, false);
|
||||
|
||||
loginOrgIdp(bc.getUserEmail().toUpperCase(), bc.getUserEmail().toUpperCase(),true, true);
|
||||
|
||||
assertIsMember(bc.getUserEmail().toUpperCase(), organization);
|
||||
UserRepresentation user = testRealm().users().search(bc.getUserEmail().toUpperCase()).get(0);
|
||||
List<FederatedIdentityRepresentation> federatedIdentities = testRealm().users().get(user.getId()).getFederatedIdentity();
|
||||
assertEquals(1, federatedIdentities.size());
|
||||
assertEquals(bc.getIDPAlias(), federatedIdentities.get(0).getIdentityProvider());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedirectToIdentityProviderAssociatedWithOrganizationDomainUsingAnyMatch() {
|
||||
OrganizationResource organization = testRealm().organizations().get(createOrganization().getId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user