<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.nief.org/index.php?action=history&amp;feed=atom&amp;title=Multifactor_Authentication_in_Shibboleth_2.N</id>
	<title>Multifactor Authentication in Shibboleth 2.N - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.nief.org/index.php?action=history&amp;feed=atom&amp;title=Multifactor_Authentication_in_Shibboleth_2.N"/>
	<link rel="alternate" type="text/html" href="https://wiki.nief.org/index.php?title=Multifactor_Authentication_in_Shibboleth_2.N&amp;action=history"/>
	<updated>2026-06-21T09:18:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://wiki.nief.org/index.php?title=Multifactor_Authentication_in_Shibboleth_2.N&amp;diff=43&amp;oldid=prev</id>
		<title>Jeff.Krug: Created page with &quot;One option for enabling multi-factor authentication for Shibboleth is to use the [https://wiki.shibboleth.net/confluence/display/SHIB2/Multi-Context+Broker Multi-Context Broke...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.nief.org/index.php?title=Multifactor_Authentication_in_Shibboleth_2.N&amp;diff=43&amp;oldid=prev"/>
		<updated>2019-01-22T20:20:29Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;One option for enabling multi-factor authentication for Shibboleth is to use the [https://wiki.shibboleth.net/confluence/display/SHIB2/Multi-Context+Broker Multi-Context Broke...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;One option for enabling multi-factor authentication for Shibboleth is to use the [https://wiki.shibboleth.net/confluence/display/SHIB2/Multi-Context+Broker Multi-Context Broker].  This framework offers an excellent&lt;br /&gt;
way to develop different style of 2nd factor modules for Shibboleth.&lt;br /&gt;
&lt;br /&gt;
==Second Factor E-mail==&lt;br /&gt;
GTRI has created one such packaging where the 2nd factor is based on the user&amp;#039;s e-mail address, where a code is e-mailed to the user&amp;#039;s registered e-mail address and then they type in the code.  This 2nd factor verification  may be cached for some amount of time as determined by the configuration.  This MCB package may be downloaded: [[File:Secondfactorbyemail.zip]].&lt;br /&gt;
===Second Factor Source Code===&lt;br /&gt;
This e-mail second factor is in a repository derived from the MCB on github: [https://github.com/gtkrug/Shibboleth-Multi-Context-Broker GTRI Customized MCB].  The following installation instructions refer specifically to the zipfile.&lt;br /&gt;
===Installation Instructions===&lt;br /&gt;
1. Create a directory in your Shibboleth install directory called templates.  Copy each of the *.vm files into this directory.&lt;br /&gt;
&lt;br /&gt;
2. Copy the velocity.properties file and the two xml files into your Shibboleth conf directory /opt/shib-idp/conf&lt;br /&gt;
&lt;br /&gt;
3. Copy the jar file into the Tomcat deployed directory, {tomcat}/webapps/{idp-directory}/WEB-INF/lib&lt;br /&gt;
&lt;br /&gt;
4. Update the web.xml file in the Tomcat deployed directory, {tomcat}/webapps/{idp-directory}/WEB-INF/web.xml&lt;br /&gt;
Find the line that looks like this (usually around line 10-15):&lt;br /&gt;
   &amp;lt;param-value&amp;gt;file:/opt/shib-idp/conf/internal.xml; file:/opt/shib-idp/conf/service.xml; &amp;lt;/param-value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update it to include the mcb-spring.xml file that you copied into this same directory in step 2:&lt;br /&gt;
   &amp;lt;param-value&amp;gt;file:/opt/shib-idp/conf/internal.xml; file:/opt/shib-idp/conf/service.xml; file:/opt/shib-idp/conf/mcb-spring.xml;&amp;lt;/param-value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally add the servlet definition for the MCB to the file :&lt;br /&gt;
    &amp;lt;!-- Servlet for MCB Authentication --&amp;gt;&lt;br /&gt;
    &amp;lt;servlet&amp;gt;&lt;br /&gt;
        &amp;lt;servlet-name&amp;gt;MCBLoginServlet&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
        &amp;lt;servlet-class&amp;gt;edu.internet2.middleware.assurance.mcb.authn.provider.MCBLoginServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
        &amp;lt;load-on-startup&amp;gt;3&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
    &amp;lt;/servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-mapping&amp;gt;&lt;br /&gt;
        &amp;lt;servlet-name&amp;gt;MCBLoginServlet&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
        &amp;lt;url-pattern&amp;gt;/Authn/MCB&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;
    &amp;lt;/servlet-mapping&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The multi-context broker works by authenticating a user and then it resolves the user&amp;#039;s attributes to determine if an additional factor is required. We have to add attribute information to the attribute-resolver.xml to cause the 2nd factor requirement to trigger.  To do this add the following to the attribute-resolver.xml.  &lt;br /&gt;
&lt;br /&gt;
Define an attribute:&lt;br /&gt;
    &amp;lt;resolver:AttributeDefinition id=&amp;quot;AuthnValues&amp;quot; xsi:type=&amp;quot;Simple&amp;quot; xmlns=&amp;quot;urn:mace:shibboleth:2.0:resolver:ad&amp;quot;&lt;br /&gt;
        sourceAttributeID=&amp;quot;authnvalues&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;resolver:Dependency ref=&amp;quot;staticAttributes&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/resolver:AttributeDefinition&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above simply resolves it statically which is fine if all users will use the same 2nd factor.  In that case also add the new attribute to the static attribute data conntector within this file.  The value(s) specified are matched against the data within &amp;#039;&amp;#039;&amp;#039;multi-context-broker.xml&amp;#039;&amp;#039;&amp;#039; and must match:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;resolver:DataConnector id=&amp;quot;staticAttributes&amp;quot; xsi:type=&amp;quot;Static&amp;quot; xmlns=&amp;quot;urn:mace:shibboleth:2.0:resolver:dc&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Attribute id=&amp;quot;authnvalues&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;Value&amp;gt;urn:oasis:names:tc:SAML:2.0:ac:classes:EmailTwoFactor&amp;lt;/Value&amp;gt;&lt;br /&gt;
        &amp;lt;/Attribute&amp;gt;&lt;br /&gt;
    &amp;lt;/resolver:DataConnector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Configure the EmailTwoFactor submodule.  To do this edit the mcb-spring.xml file.  The main section that must be configured is the &amp;#039;&amp;#039;&amp;#039;mcb.emailcode&amp;#039;&amp;#039;&amp;#039; bean (parameters 1-5 should be set, the first should be correct unless the file was renamed):&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;bean id=&amp;quot;mcb.emailcode&amp;quot; class=&amp;quot;edu.internet2.middleware.assurance.mcb.authn.provider.EmailCodeSubmodule&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;constructor-arg index=&amp;quot;0&amp;quot; value=&amp;quot;emailcode.vm&amp;quot; /&amp;gt;  The name of the velocity template used to display the email code input page.&lt;br /&gt;
        &amp;lt;constructor-arg index=&amp;quot;1&amp;quot; value=&amp;quot;60&amp;quot; /&amp;gt; Days that the entered code remains valid&lt;br /&gt;
        &amp;lt;constructor-arg index=&amp;quot;2&amp;quot; value=&amp;quot;EmailAddress&amp;quot; /&amp;gt; Attribute Id that contains the user&amp;#039;s Email Address (Attribute Id from attribute-resolver.xml)&lt;br /&gt;
        &amp;lt;constructor-arg index=&amp;quot;3&amp;quot; value=&amp;quot;localhost&amp;quot; /&amp;gt; Hostname of mail server&lt;br /&gt;
        &amp;lt;constructor-arg index=&amp;quot;4&amp;quot; value=&amp;quot;nobody@nohost.com&amp;quot; /&amp;gt; Email Address that codes are shown as From&lt;br /&gt;
        &amp;lt;constructor-arg index=&amp;quot;5&amp;quot; value=&amp;quot;asdkfj&amp;quot; /&amp;gt; A random string to insure cookies set by this login module cannot be hacked.  Please change it from the default!&lt;br /&gt;
    &amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally verify that all of the paths in this file are correct.  There will be multiple references to the other XML configuration files.&lt;br /&gt;
&lt;br /&gt;
7. Customize the multi-context-broker.xml.  This may not be needed as the&lt;br /&gt;
delivered version should prompt for username/password and then require an&lt;br /&gt;
e-mail code 2nd factor.  This file allows a good bit of orchestration of other&lt;br /&gt;
multi-factor methodologies.&lt;br /&gt;
&lt;br /&gt;
8. Add logging for the MCB by editing the logger.xml file and add:&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;logger name=&amp;quot;edu.internet2.middleware.assurance.mcb&amp;quot; level=&amp;quot;DEBUG&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. Edit the velocity.properties file.  At a minimum the template loader path will need to be set:&lt;br /&gt;
   file.resource.loader.path&lt;br /&gt;
&lt;br /&gt;
10. Edit the Shibboleth handler.xml file to set the MCB as the single loginhandler.  First update the namespaces and schema locations at the top of the file:&lt;br /&gt;
  &amp;lt;ph:ProfileHandlerGroup xmlns:ph=&amp;quot;urn:mace:shibboleth:2.0:idp:profile-handler&amp;quot;&lt;br /&gt;
                        xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
                        &amp;#039;&amp;#039;&amp;#039;xmlns:mcb=&amp;quot;edu:internet2:middleware:assurance:mcb&amp;quot;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
                        xsi:schemaLocation=&amp;quot;urn:mace:shibboleth:2.0:idp:profile-handler&lt;br /&gt;
                                            classpath:/schema/shibboleth-2.0-idp-profile-handler.xsd&lt;br /&gt;
                                            &amp;#039;&amp;#039;&amp;#039;edu:internet2:middleware:assurance:mcb classpath:/schema/mcb-login-handler.xsd&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Then add the MCB as a login handler:&lt;br /&gt;
  &amp;lt;ph:LoginHandler xsi:type=&amp;quot;mcb:MultiContextBroker&amp;quot; authenticationDuration=&amp;quot;PT4H0M0.000S&amp;quot; previousSession=&amp;quot;true&amp;quot;&lt;br /&gt;
    depends-on=&amp;quot;mcb.Configuration&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ph:AuthenticationMethod&amp;gt;urn:oasis:names:tc:SAML:2.0:ac:classes:Password&amp;lt;/ph:AuthenticationMethod&amp;gt;&lt;br /&gt;
    &amp;lt;ph:AuthenticationMethod&amp;gt;urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport&amp;lt;/ph:AuthenticationMethod&amp;gt;&lt;br /&gt;
    &amp;lt;ph:AuthenticationMethod&amp;gt;urn:oasis:names:tc:SAML:2.0:ac:classes:PreviousSession&amp;lt;/ph:AuthenticationMethod&amp;gt;&lt;br /&gt;
    &amp;lt;ph:AuthenticationMethod&amp;gt;urn:oasis:names:tc:SAML:2.0:ac:classes:EmailTwoFactor&amp;lt;/ph:AuthenticationMethod&amp;gt;&lt;br /&gt;
  &amp;lt;/ph:LoginHandler&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. If your system is currently using JAAS to do username/password login,you will need to update the login.config file for use by the MCB.  Specifically &amp;#039;&amp;#039;&amp;#039;ShibUserPassAuth&amp;#039;&amp;#039;&amp;#039; will need to be replaced with &amp;#039;&amp;#039;&amp;#039;MCBUserPassAuth&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
12. Customize &amp;#039;&amp;#039;&amp;#039;{idp-home}/template/jaaslogin.vm&amp;#039;&amp;#039;&amp;#039;. This is just an HTML file that is processed by the Velocity engine doing minor substitutions and variable resolution.&lt;br /&gt;
&lt;br /&gt;
13. Customize &amp;#039;&amp;#039;&amp;#039;{idp-home}/template/emailcode.vm&amp;#039;&amp;#039;&amp;#039;. This is just an HTML file that is processed by the Velocity engine doing minor substitutions and variable resolution.&lt;/div&gt;</summary>
		<author><name>Jeff.Krug</name></author>
	</entry>
</feed>