Skip to content

Commit f73362a

Browse files
vits-hugsVitor Hugo Homem Marzarottoerikbocks
authored
Fix saml bug unable to login (#10868)
* Fix check * Adds configuration for behaviour, when SAML SSO is disabled for a user * set default configuration value to false and rename it to enable.login.with.disabled.saml --------- Co-authored-by: Vitor Hugo Homem Marzarotto <vitor.marzarotto@scclouds.com.br> Co-authored-by: erikbocks <erik.bock@outlook.com>
1 parent 5bb5af4 commit f73362a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

plugins/user-authenticators/saml2/src/main/java/org/apache/cloudstack/saml/SAML2AuthManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public interface SAML2AuthManager extends PluggableAPIAuthenticator, PluggableSe
8282
ConfigKey<Boolean> SAMLRequirePasswordLogin = new ConfigKey<Boolean>("Advanced", Boolean.class, "saml2.require.password", "true",
8383
"When enabled SAML2 will validate that the SAML login was performed with a password. If disabled, other forms of authentication are allowed (two-factor, certificate, etc) on the SAML Authentication Provider", true);
8484

85+
ConfigKey<Boolean> EnableLoginAfterSAMLDisable = new ConfigKey<>("Advanced", Boolean.class, "enable.login.with.disabled.saml", "false", "When enabled, if SAML SSO is disabled, enables user to login with user and password, otherwise a user with SAML SSO disabled cannot login", true);
86+
87+
8588

8689
SAMLProviderMetadata getSPMetadata();
8790
SAMLProviderMetadata getIdPMetadata(String entityId);

plugins/user-authenticators/saml2/src/main/java/org/apache/cloudstack/saml/SAML2AuthManagerImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,13 @@ public boolean authorizeUser(Long userId, String entityId, boolean enable) {
451451
user.setExternalEntity(entityId);
452452
user.setSource(User.Source.SAML2);
453453
} else {
454+
boolean enableLoginAfterSAMLDisable = SAML2AuthManager.EnableLoginAfterSAMLDisable.value();
454455
if (user.getSource().equals(User.Source.SAML2)) {
455-
user.setSource(User.Source.SAML2DISABLED);
456+
if(enableLoginAfterSAMLDisable) {
457+
user.setSource(User.Source.UNKNOWN);
458+
} else {
459+
user.setSource(User.Source.SAML2DISABLED);
460+
}
456461
} else {
457462
return false;
458463
}
@@ -541,6 +546,6 @@ public ConfigKey<?>[] getConfigKeys() {
541546
SAMLCloudStackRedirectionUrl, SAMLUserAttributeName,
542547
SAMLIdentityProviderMetadataURL, SAMLDefaultIdentityProviderId,
543548
SAMLSignatureAlgorithm, SAMLAppendDomainSuffix, SAMLTimeout, SAMLCheckSignature,
544-
SAMLForceAuthn, SAMLUserSessionKeyPathAttribute, SAMLRequirePasswordLogin};
549+
SAMLForceAuthn, SAMLUserSessionKeyPathAttribute, SAMLRequirePasswordLogin, EnableLoginAfterSAMLDisable};
545550
}
546551
}

0 commit comments

Comments
 (0)