Service Portal How to land on requested URL after SSO

nthumma
Giga Guru

Below are some of the highlights of our Environment

1) We have 2 IDPs for multi-provider SSO.

2) One is for external users and another one is to handle internal users.

3) We don't have glide.entry.first.page.script enabled ( We don't want to enable this property)

4) $sp in public pages is true ( If we make this false external users portal is not working)

5) We are in Helsinki.

my requirement is when internal users access any internal portal link like 'mydomaindev.service-now.com/ip?id=p_form&table=incident&nav=my_request&sys_id=d6803f8413ecc7002ee7dd828144b0ec' , I want them to authenticate using SSO and redirect them to requested URL.

Now my issue is after SSO authentication users are being redirected to mydomaindev.service-now.com/nav_to.do?uri/ip?id=p_form&table=incident&nav=my_request&sys_id=d6803f8413ecc7002ee7dd828144b0ec'.

Please observe nav_to.do in above   URL, there is no nav_to.do in actual user requested URL.

any thoughts on how I can redirect users to actual requested URL?

Below is my code I am using on login widget.

Server Script:

(function() {

/* populate the 'data' object */

/* e.g., data.table = $sp.getValue('table'); */

data.failed = false;

data.success = false;

//var util = new GlideSPUtil();

data.is_logged_in = gs.getSession().isLoggedIn();

if (data.is_logged_in)

data.success = true;

if (!data.is_logged_in)

data.failed = true;

//data.pageURI = util.getPageUri();

data.user_start_page = gs.getSession().getProperty("starting_page");

if (input && input.action === "set_sso_destination") {

var gs_nav_to = gs.getSession().getProperty("nav_to");

gs.getSession().putProperty("nav_to", null);

     

if (!gs.getSession().getProperty("starting_page"))

gs.getSession().putProperty("starting_page", null);

return;

}

})();

Client controller:

function($scope, $window) {

/* widget controller */

var c = this;

c.failed = $scope.data.failed;

c.success = $scope.data.success;

var LoginRedirect = function() {

if (c.success == true) {

console.log('user is logged in');

return;

}

if (c.failed){

c.server.get({

action: "set_sso_destination",

pageURI: c.data.user_start_page

}).then(function() {

$window.location = "/login_with_sso.do?glide_sso_id=fe226ca013c5fa002ee7dd828144b03e?RelayState="+c.data.user_start_page;

});

}

};

LoginRedirect();

}

7 REPLIES 7

julian_day17
Tera Contributor

Okta provide a free identity tool that may also help this process for external users sn access


PriyaRanji
Tera Guru

Hi,

 

I m facing the similar kind of issues. How can we redirect to the login page (sso), however I tried in same way, and I don't have the properties which you have mentioned in the script.

 

Please help me !!!

mig
Mega Guru

Hi,

just in case others are looking for a solution regarding SSO not redirecting to SP once a session has been opened:

 

A solution that helped me can be found here: (in my case the RelayState sent by our IsP has been ignored by our instance)

 

https://community.servicenow.com/community?id=community_question&sys_id=dd104b21db98dbc01dcaf3231f961960   

look for the answer by Mukul Mann  (he is my hero of the day):

In-order to activate this fix, please add/enable the following system property

System Property name: glide.authenticate.honor.relaystate.for.loggedin.sessions
System Property type: true|false
System Property value: true

Once the property is active, then you will not get redirected to homepage of ServiceNow which is Navpage.do as per SSO configurations. It will always redirect to the RelayState URL.

Kind regards

Mig