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

nthumma
Giga Guru

I was able to resolve my issue by changing line 18 in the clinet controller to below.



var url = "/sp&glide_sso_id=fe226ca013c5fa002ee7dd828144b03e";


$window.location.href = url;


coreyledbetter
Tera Contributor

Are your users clicking on use external login?   What HTML are you using on your widget?


In my scenario users not clicking on any link,   I have this code on the login widget tied to my portal so anybody visiting that portal if not logged in it will take care of authentication and then redirect to requested URL.



In your case, you can hyperlink portals like below with different portals.



href="/sp1&glide_sso_id=fe226ca013c5fa002ee7dd828144b03e"


href="/sp2&glide_sso_id={this should be different idp based on your portal}"


I don't use a login widget as we have a HTML widget setup that allows users to click on their particular IDP to login.   Trying to figure out how to incorporate what you did into my HTML....Would solve my issue for sure!