petercawdron
Kilo Guru

Multi-factor authentication is a good way to ensure you know the identity of your users as they not only need a userID and password they also need access to their mobile phone (or tablet), giving you a high level of confidence that they are who they say they are.

find_real_file.png

The problem is... by default, this page redirects to regular ServiceNow not to the portal. So this is an article showing how to fix that. 

There are two ways of solving this dilemma. If you want your Google multi-factor authentication to go directly to the service portal, both of these will work. My preference is the first one, but for people that don't want to change a core UI Page (which will then NEVER be upgraded) the second option might be better. 

Option 1: Add a redirect to the UI Page

Open the UI Page called google_auth_setup_page add add the following line to the processing script.

gs.setRedirect("/sp");

If you want to go to some other portal or if you need some logic to redirect to various portals, this is where you should add it.

find_real_file.png

That's it. That's all you need to do.

Option 2: Use the old CMS redirects

If you have an older version of ServiceNow you may still have the CMS system lingering somewhere in the background. Newer customers won't have this option, but anyone that adopted ServiceNow prior to 2018 should have this enabled (but unused).

The advantage of this approach is if the UI Page is ever updated, you'll get that update. The disadvantage is it's a little convoluted and the user may see a few pages flicker in the background (but only on the first time they use the system)

In essence, the problem is the mfa pages are part of the old content management system (CMS) and so want to redirect there. The workaround I've come up with is to set up a dummy CMS portal that redirects to the service portal.

Step 1: Set up an old style CSM portal

Set up an old style CMS portal to handle the redirect

find_real_file.png

This can be really sparse (to help with performance). You can use almost any name for the URL suffix, I went with redirecting so if the user sees this flickering in the URL they'll understand something deliberate is happening.

Save and click on Edit Page

Step 2: Add dynamic content

Click on Add Content and select *New Dynamic Content as this will allow us to add a script that redirects immediately to the service portal in a Jelly XML script.

find_real_file.png

Create a new dynamic content block with the following code.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<script>
		if(top.location.href.indexOf('content')==-1) top.location.href='/sp'
	</script>
</j:jelly>

You'll notice there's a little logic to only run this when we're not in the content editor (or else it's impossible to ever remove this or alter any other CMS pages)

Now we can set up our multi-factor authentication criteria

Step 3: set up MFA

Create a new role called requires_mfa. All the users you want to use MFA should be part of a group that has this role. Then add that to your Multi-factor Criteria. This will force all users in that particular group to sign up for MFA.

find_real_file.png

Step 4: Login rule to redirect

Finally, we tie it all together with a CMS login rule to redirect users to the service portal. Simply create a new rule (with the lowest execution order) to push users with this role over to our portal redirect and... voila, your MFA should now take users directly to the service portal

find_real_file.png

gs.getUser().hasRole('requires_mfa');

My preference is option 1.

Have fun.

Comments
quiksilver
Mega Guru

Hello Peter,

 

Great Article, 

Quick Question , How do you handle login to Service Portal ? Are you using login.do ? or are you using Portal login page (instance.service-now.com/sp) We have recently activated MFA and found that using the portal login, MFA is not working.  Was wondering if you experience the same or have a different solution.

 

Thanks in advance

 Quik

ah16
Mega Expert

Thanks Peter for the article. I'm not able to find the " google_auth_setup_page" page in UI pages. Can you please provide the link to the UI page?

ah16
Mega Expert

I got it. They renamed the page to multi-factor auth starting Orlando.

petercawdron
Kilo Guru

Sorry for not responding sooner... this solution is only applicable to the regular login page. To get it to work with the portal might take a little trial & error.

I'd use the google_auth_setup_page as a template to build a portal login widget. Copy the existing widget and then look to replicating the process in google_auth_setup_page. The server side script is going to be identical to the processing script above, and you may even be able to reuse some of the rendering elements. 

petercawdron
Kilo Guru

Make sure you have the MFA plugin in ServiceNow (Integration - Multifactor Authentication) activated. Then you should see this UI page

ah16
Mega Expert

Since Orlando, they changed the page to multi factor page. The problem I'm having is I'm not able to redirect after MFA logging.

 

But after following you're article, I was able to redirect to custom page during the initial setup.

aisha78799_as
Tera Contributor

Hi Petercawdron,

Could you please help me on below issue,

MFA is enabled but when I click on "configure multi-factor Authentication" from

"user_profile" on CSM Portal.

it is redirecting me to native UI instead of "configure MFA" and it is working fine when I open the same from native UI profile.find_real_file.png

SN developer3
Tera Expert

Hi @ah16 and @petercawdron 

This page is read only policy protected.
I did "insert and stay" but the duplicated file also is read only protected.
Do you know how can we make it editable?

Thanks

Version history
Last update:
‎12-08-2019 05:01 PM
Updated by: