You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SAML2 authentication with MS Azure AD intermittently fails with error AADSTS7500529 #5548
Enabled SAML plugin and configured it to authenticate against Azure AD.
STEPS TO REPRODUCE
SAML authentication fails intermittently depending on the SAML request ID that is generated. Depending on your luck, you might get a random request ID that begins with something between A-Z. In such cases, the authentication request goes through as expected. On the chance that the generated number begins with 0-9, the authentication request fails with an error similar to:
AADSTS7500529: The value '692rv91k6dgmdas33vr3b2keahr4lqjv' is not a valid SAML ID. The ID must not begin with a number.
As per Azure AD's documentation, an acceptable request ID must not start with a number.
The CloudStack implementation generates the random ID string with the following method in SAMLUtils and has no ability to prefix the SAML ID string as recommended by Azure AD's documentation.
100 public class SAMLUtils {
101 public static final Logger s_logger = Logger.getLogger(SAMLUtils.class);
102
103 public static String generateSecureRandomId() {
104 return new BigInteger(160, new SecureRandom()).toString(32);
105 }
EXPECTED RESULTS
Successful authentication with SAML and Azure AD.
ACTUAL RESULTS
Intermittent authentication failure with SAML and Azure AD.
Yes, the limitation is on Microsoft's side where the SAML request ID cannot start with a digit. While this isn't strictly a bug in CloudStack, it also means that Azure AD isn't completely supported with the current implementation. The documentation does suggest prepending the request ID with a string such as 'id'.
Would an appropriate 'fix' be to add an optional prefix as a global setting to CoudStack which will then be prepended to the generated request IDs? Or is there a better solution that you can think of?
I'm currently setting up a build environment for CloudStack so I can hopefully try a few things. Thanks!
@kohrar was this done for testing/learning sake or are you trying to integrate CloudStack SAML based SSO with Azure AD? I suppose if this is a requirement, we can look into generating random string IDs that start with an alphabet (a-zA-Z).
I'm still testing out and assessing CloudStack but I'd like to use CloudStack in our University research environment to allow some of our researchers to spin up VMs as needed. As such, we'd like to leverage our existing SSO infrastructure which is currently hosted on Azure AD.
I've got a build environment set up and modified the code to prepend "id" to the random request ID. I can confirm that works as a fix and it's indeed the starting digits in the request IDs that are the issue.
Would you be against the idea of having something like a "saml2.sp.prepend" config key that an admin could specify in global settings?
Activity
yadvr commentedon Oct 5, 2021
Thanks for reporting @kohrar - the current SAML auth plugin is only tested against Shibboleth and keycloak, I've heard MS AD as well. I quickly checked some forums and https://docs.microsoft.com/en-us/azure/active-directory/develop/single-sign-on-saml-protocol and it seems a limitation of Microsoft's SAML spec/implementation only (not a bug in CloudStack or opensaml library).
kohrar commentedon Oct 5, 2021
Yes, the limitation is on Microsoft's side where the SAML request ID cannot start with a digit. While this isn't strictly a bug in CloudStack, it also means that Azure AD isn't completely supported with the current implementation. The documentation does suggest prepending the request ID with a string such as 'id'.
Would an appropriate 'fix' be to add an optional prefix as a global setting to CoudStack which will then be prepended to the generated request IDs? Or is there a better solution that you can think of?
I'm currently setting up a build environment for CloudStack so I can hopefully try a few things. Thanks!
yadvr commentedon Oct 6, 2021
@kohrar was this done for testing/learning sake or are you trying to integrate CloudStack SAML based SSO with Azure AD? I suppose if this is a requirement, we can look into generating random string IDs that start with an alphabet (a-zA-Z).
kohrar commentedon Oct 6, 2021
I'm still testing out and assessing CloudStack but I'd like to use CloudStack in our University research environment to allow some of our researchers to spin up VMs as needed. As such, we'd like to leverage our existing SSO infrastructure which is currently hosted on Azure AD.
I've got a build environment set up and modified the code to prepend "id" to the random request ID. I can confirm that works as a fix and it's indeed the starting digits in the request IDs that are the issue.
Would you be against the idea of having something like a "saml2.sp.prepend" config key that an admin could specify in global settings?
yadvr commentedon Oct 11, 2021
@kohrar yes that might work, or even changing the default random string generator to generate first character as an alphabet than number.