Service Portal redirect to SSO (ADFS)

na93
Mega Expert

Hi All,

I've been researching SSO/Redirects but haven't been able to come up with a solution to my problem unfortunately.

What I am looking to do is if a user navigates to test.service-now.com/sp they are redirected to our IDP (SSO) and then after authentication they are then passed back to the Service Portal. I only want this to happen for /sp not anything else.

I'm guessing the script include for the SPEntryPage will need modified. Has anyone does this before or has any examples of what I'd be looking to change on the script include?

Any help/pointers would be greatly appreciated. 

Thanks,
Nabeel

1 ACCEPTED SOLUTION

Add a login page to your portal and on the login page, you need to add a widget which handles the redirection.

Server-side script of widget

(function() {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */
	data.failed = false;
	data.success = false;
	
	
	
	data.is_logged_in = gs.getSession().isLoggedIn();
	
	
	if (data.is_logged_in)
		data.success = true;
	if (!data.is_logged_in)
		data.failed = true;
	
	data.user_start_page = gs.getSession().getProperty("starting_page");
	data.default_idp = gs.getProperty("glide.authenticate.sso.redirect.idp");	
	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 code

function($scope, $window) {
	/* widget controller */
	var c = this;
	c.failed = $scope.data.failed;
	c.success = $scope.data.success;
	
	var LoginRedirect = function() {
		if (c.success) {
			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() {
				var url = "/sp&glide_sso_id="+c.data.default_idp;
				$window.location.href = url; 
			   console.log('user was not logged in AND redirect succeeded');
			   return;
			});
		}
	};
	
	LoginRedirect();
}

 

find_real_file.png

View solution in original post

8 REPLIES 8

Cameron Boote
Tera Guru

We have the sys property - glide.entry.first.page.script set to new SPEntryPage().getFirstPageURL() to fix SSO to our Service Portal.  

Hi Cameron,

Thanks but what I want is our users to navigate directly to /sp and for it to do the IDP redirect then and only on /sp. 

Are you providing your users with an ADFS URL of sorts?

Add a login page to your portal and on the login page, you need to add a widget which handles the redirection.

Server-side script of widget

(function() {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */
	data.failed = false;
	data.success = false;
	
	
	
	data.is_logged_in = gs.getSession().isLoggedIn();
	
	
	if (data.is_logged_in)
		data.success = true;
	if (!data.is_logged_in)
		data.failed = true;
	
	data.user_start_page = gs.getSession().getProperty("starting_page");
	data.default_idp = gs.getProperty("glide.authenticate.sso.redirect.idp");	
	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 code

function($scope, $window) {
	/* widget controller */
	var c = this;
	c.failed = $scope.data.failed;
	c.success = $scope.data.success;
	
	var LoginRedirect = function() {
		if (c.success) {
			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() {
				var url = "/sp&glide_sso_id="+c.data.default_idp;
				$window.location.href = url; 
			   console.log('user was not logged in AND redirect succeeded');
			   return;
			});
		}
	};
	
	LoginRedirect();
}

 

find_real_file.png

Thank you very much! I will give this a try shortly 🙂