Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Multi-Provider SSO authentication - How to address the limitation for the SAML login request to use HTTP-POST - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • Multi-Provider SSO authentication - How to address the limitation for the SAML login request to use HTTP-POST
KB0662211

Multi-Provider SSO authentication - How to address the limitation for the SAML login request to use HTTP-POST


4020 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Description

Some IdPs only support HTTP-POST SAML login requests. Currently ServiceNow does not offer any available settings for a SAML login request to use HTTP-POST.

 

Steps to Reproduce

Some Identity Providers require an HTTP-POST login request. The baseline version of the multi-provider SSO plugin does not support HTTP-POST.

 

Workaround

This issue has been identified as a future product enhancement. The Installation Exit scripts below compose the 3-steps workaround approved by SN development. Please note this was originally based on the Helsinki code base, and should always be tested on a sub-production instance prior to deploy the change into production.

 

1. Modify the Script Include 'SAML2_update1' adding the methods below just after the "getSAMLAssertion" method:


getAuthnRequestFormString : function(isTestConn) {
var AuthnRequestMarshaller = Packages.org.opensaml.saml2.core.impl.AuthnRequestMarshaller;
var samlOptions = null;
if (isTestConn) {
samlOptions = {
forceAuthn: true
}
}

var authnRequest = this.createAuthnRequestWithOptions(samlOptions);

var signAuthn = this.ssoHelper.getProperty("glide.authenticate.sso.saml2.require_signed_authnrequest", "require_signed_authnrequest", false);
if(this.isTrue(signAuthn)) {
this.signSAMLObject(authnRequest);
}

var arm = new AuthnRequestMarshaller();
var elem = arm.marshall(authnRequest);

return SAML2_update1.getEncodedSAMLRequest(elem, false, false);
}

generateAuthnRequestForm: function(request,isTestConn) {
try {
var idpAuthnURL = this.ssoHelper.getProperty("glide.authenticate.sso.saml2.idp_authnrequest_url", "idp_authnrequest_url");

var authReqStr = this.getAuthnRequestFormString(isTestConn);
var origRelayState = this.generateRelayState(request, isTestConn);
// always use serviceUrl as relayState, it will lookup the real relayState using "SAML_RelayState" as the key.
// failed login does not respond a relayState, so we must put the states into session for test corrections.
if (isTestConn)
request.getSession().setAttribute("Test_SAML_RelayState", origRelayState);
else
request.getSession().setAttribute("SAML_RelayState", origRelayState);

var formStr = this.createSAMLRequestPostForm(idpAuthnURL, authReqStr, origRelayState);

var httpSession = request.getSession();
httpSession.setAttribute("glide.saml2.session_request_id", this.getLastGeneratedRequestID());
this.logDebug("Setting glide.saml2.http.post.session_request_id in session to support SAML request with http post");
httpSession.setAttribute("glide.saml2.http.post.session_request_id", this.getLastGeneratedRequestID());

//Add this request id to request id array in the session

var requestIDArr = httpSession.getAttribute("glide.saml2.session_request_id_arr");
if(!requestIDArr){
requestIDArr = [];
}
requestIDArr.push(this.getLastGeneratedRequestID());
httpSession.setAttribute("glide.saml2.session_request_id_arr", requestIDArr);

return formStr;
} catch (e) {
if (e instanceof Packages.java.lang.Throwable){
var stackTrace = GlideLog.getStackTrace(e);
this.logError(stackTrace);
}
else{
this.logError(e.name + ": " + e.message);
}
return null;
}
}


2. Modify the Script Include 'MultiSSO_SAML2_Update1' replacing the existing code that uses the http redirect binding from:

var redirectURL = this.SAML2.generateAuthnRequestRedirectURL(request, false);
if (GlideStringUtil.nil(redirectURL))
return "failed_missing_requirement";

To:

// Refresh login request
if(!samlResponseObject && !relayState) {
this.ssoHelper.debug("Logging in saml using HTTP POST");
var formStr = this.SAML2.generateAuthnRequestForm(request, false);
response.setContentType("text/html");
response.getWriter().write(formStr);
var redirectURL = "true"; // trick so it does not fail
SNC.SecurityEventSender.sendSAMLRedirectSentEventData("", "multisso=true,idpsysid=" + this.propertiesGR.getUniqueValue());
return redirectURL;
}


3: Modify the Script Include 'MultiSSO_SAML2_Update1' replacing the existing code from:

var inResponseTo = httpSession.getAttribute("glide.saml2.session_request_id");

To:

var inResponseTo = httpSession.getAttribute("glide.saml2.session_request_id");

if(GlideStringUtil.nil(inResponseTo)) {
this.logDebug("Getting inResponseTo from new attribute for http post SAML request.");
inResponseTo = httpSession.getAttribute("glide.saml2.http.post.session_request_id");
}



Related Problem: PRB656080

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.