<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Integration &#8211; privacyID3A</title>
	<atom:link href="https://www.privacyidea.org/tag/integration/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.privacyidea.org</link>
	<description>flexible, Open Source Multi Factor Authentication (2FA)</description>
	<lastBuildDate>Tue, 24 Mar 2020 18:00:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.privacyidea.org/wp-content/uploads/2016/06/cropped-only-logo-white-background-32x32.png</url>
	<title>Integration &#8211; privacyID3A</title>
	<link>https://www.privacyidea.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Versatile 2FA Single Sign-On with Keycloak and privacyIDEA</title>
		<link>https://www.privacyidea.org/versatile-2fa-single-sign-on-with-keycloak-and-privacyidea/</link>
					<comments>https://www.privacyidea.org/versatile-2fa-single-sign-on-with-keycloak-and-privacyidea/#comments</comments>
		
		<dc:creator><![CDATA[Henning Hollermann]]></dc:creator>
		<pubDate>Tue, 24 Mar 2020 17:53:00 +0000</pubDate>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[2FA]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[keycloak]]></category>
		<category><![CDATA[kolab]]></category>
		<category><![CDATA[OpenID Connect]]></category>
		<category><![CDATA[privacyIDEA]]></category>
		<category><![CDATA[Roundcubemail]]></category>
		<category><![CDATA[SSO]]></category>
		<guid isPermaLink="false">https://www.privacyidea.org/?p=1772</guid>

					<description><![CDATA[The integration of privacyIDEA with Keycloak to provide a solid basis to secure your applications with a second factor in a single sign-on (SSO) environment. For maximum flexibility, the system relies on standard protocols such as SAML or OpenID Connect (OIDC). This article shows exemplarily the integration of Keykcloak, privacyIDEA and Kolab.]]></description>
										<content:encoded><![CDATA[
<p>In a <a href="https://netknights.it/en/single-sign-on-with-privacyidea/">previous article</a>, we wrote about benefits and risks of single sign-on (SSO) in enterprise environments and how a solid 2-factor-authentication solution as provided by privacyIDEA helps reduce risks. In this article we will demonstrate how to setup a SSO system with <a href="https://www.keycloak.org/">Keycloak</a> and <a href="https://netknights.it/en/produkte/privacyidea/">privacyIDEA</a>. As an example application we integrate the <a href="https://kolabsystems.com/">Kolab Groupware Server</a> and setup the Roundcubemail webmailer to authenticate with OpenID Connect (OIDC) and a second factor managed by privacyIDEA. Other popular collaboration platforms such as <a href="https://www.tine20.com/en/">Tine 2.0</a> or <a href="https://www.open-xchange.com/">Open-Xchange</a> and many other applications will also work with Keycloak and privacyIDEA as long as they support at least one standard SSO protocol.</p>



<div class="wp-block-image is-style-default"><figure class="aligncenter size-large is-resized"><img decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/03/network-987x1024.png" alt="" class="wp-image-1932" width="600" srcset="https://www.privacyidea.org/wp-content/uploads/2020/03/network-987x1024.png 987w, https://www.privacyidea.org/wp-content/uploads/2020/03/network-289x300.png 289w, https://www.privacyidea.org/wp-content/uploads/2020/03/network-768x797.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/03/network.png 1100w" sizes="(max-width: 987px) 100vw, 987px" /></figure></div>



<p>First, we setup three machines with Ubuntu Server 18.04 and provide similar /etc/hosts files to each of them. For a proper setup, Kolab requires a fully qualified domain name. We choose <code>kolab.netknights.it</code>.</p>



<pre class="wp-block-preformatted has-small-font-size">127.0.0.1      localhost
127.0.1.1      kolab
192.168.56.200 kolab.netknights.it    kolab
192.168.56.201 pi.netknights.it       pi
192.168.56.202 keycloak.netknights.it keycloak</pre>



<p>To put the system into action, one would have to configure DNS and NAT  properly so that the server is reachable from the internet. DNS record  of type A, AAAA and MX are crucial to do this. You may read about this  requirement in the Kolab docs &#8220;<a href="https://docs.kolab.org/installation-guide/preparing-the-system.html">preparing the system</a>&#8220;. For this proof of concept we will not use any logical volumes nor discuss firewall setups or SSL transport layer security.</p>



<p>After updating the initial Ubuntu Server systems, we install privacyIDEA, Keycloak and Kolab following their general installing instructions. We start with Kolab, since in this scenario, we would like to attach the ds-389 LDAP directory delivered by Kolab to our backend, i.e. Keycloak and privacyIDEA.</p>



<h3 class="wp-block-heading">Kolab 16 Installation</h3>



<p>The primary OS supported by Kolab is CentOS, which is also supported by privacyIDEA. However, there are also Kolab and privacyIDEA packages available for Ubuntu 18.04. We will use these for our setup. The install instructions can be found at <a href="https://docs.kolab.org/installation-guide/ubuntu-18.04.html">docs.kolab.org</a>. We summarize them here for convenience</p>



<pre class="wp-block-preformatted has-small-font-size"># Add repositories for apt to /etc/sources/ 
~$ echo 'deb http://obs.kolabsys.com/repositories/Kolab:/16/Ubuntu_18.04/ ./ deb-src http://obs.kolabsys.com/repositories/Kolab:/16/Ubuntu_18.04/ ./' \ 
| tee /etc/apt/sources.list.d/kolab.list 
# Add signing key 
~$ wget -q -O- https://ssl.kolabsys.com/community.asc | apt-key add - 
~$ echo -e 'Package: *\nPin: origin obs.kolabsys.com\nPin-Priority: 501' \ 
| tee /etc/apt/preferences.d/kolab 
~$ apt-get update
~$ apt-get install kolab</pre>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img fetchpriority="high" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/01-install-kolab-terminal-1.png" alt="" class="wp-image-1784" width="733" height="194" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/01-install-kolab-terminal-1.png 733w, https://www.privacyidea.org/wp-content/uploads/2020/02/01-install-kolab-terminal-1-300x79.png 300w" sizes="(max-width: 733px) 100vw, 733px" /></figure></div>



<p>We let the postfix SMTP service be configured as &#8220;Internet with smarthost&#8221;. Outbound email will be relayed to another (trusted) mail server, e.g. the one of your ISP. Inbound mail will reach postfix on port 25 if your DNS records are configured correctly. After installation the configuration script is called via</p>



<pre class="wp-block-preformatted has-small-font-size">~$ setup-kolab</pre>



<p>It will ask for some information and several passwords. The password for the directory manager will be used to first login, so remember it. Also passwords for a the cyrus-imapd administrator, a kolab-service user, the mysql database root user and several database passwords are needed. Note, that all of them are stored in the /etc/kolab/kolab.conf file and only very few are needed for interactive logins.</p>



<p>Kolab comes without a predefined admin user. Only the directory admin is defined which should not be used for user administration. So we login as &#8220;cn=Directory Manager&#8221; and define a new admin user. In our default setup, the UID is generated from the surname (check the &#8220;System&#8221; tab), so we choose <code>kolab-admin</code> to differentiate from <code>pi-admin</code> and <code>keycloak-admin</code> later.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/03-kolab-webadmin-login-ssl.png" alt="" class="wp-image-1786" width="524" height="361" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/03-kolab-webadmin-login-ssl.png 627w, https://www.privacyidea.org/wp-content/uploads/2020/02/03-kolab-webadmin-login-ssl-300x207.png 300w" sizes="(max-width: 524px) 100vw, 524px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-add-user-1.png" alt="" class="wp-image-1788" width="534" height="513" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-add-user-1.png 534w, https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-add-user-1-300x288.png 300w" sizes="(max-width: 534px) 100vw, 534px" /></figure></div>



<p>On the System tab we set the predefined <code>kolab-admin</code> role for the user to grant him access for user management. Also set a password.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-add-user-2.png" alt="" class="wp-image-1789" width="529" height="390" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-add-user-2.png 529w, https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-add-user-2-300x221.png 300w" sizes="auto, (max-width: 529px) 100vw, 529px" /></figure></div>



<p>Hit submit to complete the process. Next add another ordinary user to test the second factor login later on. We call this user <code>test-user</code>.</p>



<h3 class="wp-block-heading">privacyIDEA 3.x Installation</h3>



<p>Now, we setup privacyIDEA. Install instructions for the most recent version can be found at <a href="https://privacyidea.readthedocs.io/en/latest/">readthedocs.privacyidea.io</a>. We install the <a href="https://privacyidea.readthedocs.io/en/latest/installation/ubuntu.html#installing-privacyidea-3-0-or-higher">official Ubuntu packages</a>, specifically the <code>privacyidea-apache2</code> package. The installation only takes few minutes. After creating the admin user, here called <code>pi-admin</code>, with</p>



<pre class="wp-block-preformatted has-small-font-size">~$ pi-manage admin add pi-admin -e pi-admin@localhost</pre>



<p>we login to the UI. privacyIDEA needs to access the LDAP directory provided by Kolab, so we create an LDAP resolver and use the Kolab service account created above via &#8220;Config-&gt;Users-&gt;New ldapresolver&#8221;. The dn and password for the kolab-service account can be checked in the file /etc/kolab/kolab.conf. We use the OpenLDAP preset given by privacyIDEA but change the UID type to &#8220;dn&#8221;. The resolver test buttons help to avoid typos and to check the connection. For the test, we leave TLS to be configured later.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/ldap-resolver-2-829x1024.png" alt="" class="wp-image-1794" width="829" height="1024" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/ldap-resolver-2-829x1024.png 829w, https://www.privacyidea.org/wp-content/uploads/2020/02/ldap-resolver-2-243x300.png 243w, https://www.privacyidea.org/wp-content/uploads/2020/02/ldap-resolver-2-768x948.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/ldap-resolver-2.png 1149w" sizes="auto, (max-width: 829px) 100vw, 829px" /></figure></div>



<p>The resolver is added to a new realm <code>kolab_realm</code> at &#8220;Config-&gt;Realms-&gt;Create Realm&#8221;.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1019" height="133" src="https://www.privacyidea.org/wp-content/uploads/2020/02/create-realm.png" alt="" class="wp-image-1796" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/create-realm.png 1019w, https://www.privacyidea.org/wp-content/uploads/2020/02/create-realm-300x39.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/create-realm-768x100.png 768w" sizes="auto, (max-width: 1019px) 100vw, 1019px" /></figure></div>



<p></p>



<p>You should now be able to see the users within privacyIDEA.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/users.png" alt="" class="wp-image-1803" width="478" height="274" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/users.png 637w, https://www.privacyidea.org/wp-content/uploads/2020/02/users-300x172.png 300w" sizes="auto, (max-width: 478px) 100vw, 478px" /></figure></div>



<p>We will enroll an HOTP token for <code>test-user</code> with the <a href="https://netknights.it/en/produkte/privacyidea-authenticator-app/">privacyIDEA App</a>, available from Google Play Store. You may alternatively use the Google Authenticator. Install the app and proceed with the enrollment as given below. The privacyIDEA UI auto-completes the username as you type. The generated QR code must be scanned with the App to complete the enrollment.</p>



<figure class="wp-block-gallery columns-3 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/enroll.png"><img loading="lazy" decoding="async" width="851" height="807" src="https://www.privacyidea.org/wp-content/uploads/2020/02/enroll.png" alt="" data-id="1797" class="wp-image-1797" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/enroll.png 851w, https://www.privacyidea.org/wp-content/uploads/2020/02/enroll-300x284.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/enroll-768x728.png 768w" sizes="auto, (max-width: 851px) 100vw, 851px" /></a><figcaption class="blocks-gallery-item__caption">Enroll a new OTP token&#8230;</figcaption></figure></li><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/enroll2-1-1024x376.png"><img loading="lazy" decoding="async" width="1024" height="376" src="https://www.privacyidea.org/wp-content/uploads/2020/02/enroll2-1-1024x376.png" alt="" data-id="1859" data-link="https://www.privacyidea.org/?attachment_id=1859" class="wp-image-1859" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/enroll2-1-1024x376.png 1024w, https://www.privacyidea.org/wp-content/uploads/2020/02/enroll2-1-300x110.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/enroll2-1-768x282.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/enroll2-1.png 1119w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption class="blocks-gallery-item__caption">&#8230;with the privacyIDEA app.</figcaption></figure></li><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/token-1.jpg"><img loading="lazy" decoding="async" width="870" height="1024" src="https://www.privacyidea.org/wp-content/uploads/2020/02/token-1-870x1024.jpg" alt="" data-id="1860" data-full-url="https://www.privacyidea.org/wp-content/uploads/2020/02/token-1.jpg" data-link="https://www.privacyidea.org/?attachment_id=1860" class="wp-image-1860" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/token-1-870x1024.jpg 870w, https://www.privacyidea.org/wp-content/uploads/2020/02/token-1-255x300.jpg 255w, https://www.privacyidea.org/wp-content/uploads/2020/02/token-1-768x904.jpg 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/token-1.jpg 872w" sizes="auto, (max-width: 870px) 100vw, 870px" /></a><figcaption class="blocks-gallery-item__caption">The token is assigned to &#8220;test-user&#8221;.</figcaption></figure></li></ul></figure>



<p>The OTP token is now assigned to the user <code>test-user</code> and the privacyIDEA app on your phone should display a six-digits OTP code.</p>



<p>To issue trigger challenges asking for an OTP key on user login, privacyIDEA needs an authorization. Since we do not want our pi-admin password to flow through the wire all the time, we create another, unpriviledged admin user on the privacyIDEA terminal.</p>



<pre class="wp-block-preformatted has-small-font-size">~$ pi-manage admin add trigger-admin -e trigger-admin@localhost</pre>



<p>The trigger-admin needs a superuser policy to restrict the access. In &#8220;Config-&gt;Policies&#8221;, first create a default superuser policy using the &#8220;superuser&#8221; template. Add only the pi-admin to the <code>admin</code> field. Then add another policy without template. Name it <code>trigger_admin</code>, select the scope <code>admin</code>, add the action <code>triggerchallenge</code> and add the created trigger-admin to the <code>admin</code> field. Now, we have two admin users. pi-admin has the default superuser access and trigger-admin has only very limited access allowing to trigger the challenge.</p>



<p>As privacyIDEA is now up and running, we proceed with the Keycloak server, which will act as the central element in the SSO environment.</p>



<h3 class="wp-block-heading">Keycloak 9 Installation</h3>



<p>Start the Keycloak installation by downloading the Keycloak standalone server from <a href="https://www.keycloak.org/downloads.html">keycloak.org</a>. General install information is found in the <a href="https://www.keycloak.org/docs/latest/getting_started/">&#8220;getting started&#8221; guide</a>. A detailed guide how to integrate Keycloak with systemd on Ubuntu Server 18.04 LTS is found <a href="https:&#x2f;&#x2f;&#x6d;&#x65;&#100;&#105;um&#46;&#x63;&#x6f;&#x6d;&#x2f;&#64;&#104;asn&#x61;&#x74;&#x2e;&#x73;&#97;&#101;&#101;d/setup-keycloak-server-on-ubuntu-18-04-ed8c7c79a2d9">here</a>. The necessary steps are summarized below.</p>



<pre class="wp-block-preformatted has-small-font-size">~$ sudo apt-get update
~$ sudo apt-get install default-jre-headless
# Install Keycloak 9
~$ mkdir -p /opt/keycloak /etc/keycloak
~$ wget https://downloads.jboss.org/keycloak/9.0.0/keycloak-9.0.0.tar.gz
~$ tar -xvzf keycloak-9.0.0.tar.gz
~$ mv keycloak-9.0.0.tar.gz /opt/keycloak
# Add keycloak user
~$ groupadd keycloak
~$ useradd -r -g keycloak -d /opt/keycloak -s /sbin/nologin keycloak
~$ chown -R keycloak: /opt/keycloak
~$ chmod o+x /opt/keycloak/bin/
# Place config file
~$ cp /opt/keycloak/docs/contrib/scripts/systemd/wildfly.conf /etc/keycloak/keycloak.conf
# Setup systemd files
~$ sed 's/wildfly/keycloak/' /opt/keycloak/docs/contrib/scripts/systemd/launch.sh \
| tee /opt/keycloak/bin/launch.sh
~$ chown keycloak: /opt/keycloak/bin/launch.sh
~$ sed 's/wildfly/keycloak/g' /opt/keycloak/docs/contrib/scripts/systemd/wildfly.service \
| tee /etc/systemd/system/keycloak.service
# Enable and start the daemon
~$ systemctl daemon-reload
~$ systemctl enable keycloak
~$ systemctl start keycloak
~$ systemctl status keycloak
# Add admin user
~$ /opt/keycloak/bin/add-user-keycloak.sh -r master -u <strong>keycloak-admin</strong> -p <strong>&lt;password&gt;</strong> 
~$ systemctl restart keycloak</pre>



<p>Now you should be greeted by Keycloak at http://192.168.56.202:8080. Login with your created <code>keycloak-admin</code> user. As Keycloak should validate the user logins it has to have access to the user store. In &#8220;User Federation&#8221;, add an LDAP provider with the following settings. The kolab-service account is used as an unpriviledged bind and again we disable TLS for the test setup.</p>



<div class="wp-block-image"><figure class="alignleft size-full is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-ldap-setup-2.png" alt="" class="wp-image-1824" width="874" height="1625" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-ldap-setup-2.png 1089w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-ldap-setup-2-161x300.png 161w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-ldap-setup-2-551x1024.png 551w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-ldap-setup-2-768x1428.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-ldap-setup-2-826x1536.png 826w" sizes="auto, (max-width: 874px) 100vw, 874px" /></figure></div>



<p>Hit &#8220;Synchronize all users&#8221; to pull the users from LDAP to Keycloak. You may enable the periodic sync to keep the Keycloak user store up-to-date.</p>



<p><strong>Important: </strong>The keycloak-admin should not be required to provide a second factor to prevent locking the configuration while testing. For this purpose, define a <code>no2fa</code> group in &#8220;Groups&#8221; and add the keycloak-admin to that group in &#8220;Users&#8221;.</p>



<p>Next, privacyIDEA is integrated with Keycloak. Following our earlier article on the integration of <a href="https://community.privacyidea.org/t/how-to-use-keycloak-with-privacyidea/1132">Django with Keycloak and privacyIDEA</a>, we download the two files <a href="https://github.com/privacyidea/keycloak-provider/releases/download/v0.3/PrivacyIDEA-Provider.jar">PrivacyIDEA-Provider.jar</a> and <a href="https://github.com/privacyidea/keycloak-provider/releases/download/v0.3/privacyIDEA.ftl">privacyIDEA.ftl</a> of the most recent release of the <a href="https://github.com/privacyidea/keycloak-provider">privacyIDEA keycloak-provider</a> and install it to Keycloak.</p>



<pre class="wp-block-preformatted has-small-font-size">~$ wget https://github.com/privacyidea/keycloak-provider/releases/download/v0.3/PrivacyIDEA-Provider.jar
~$ wget https://github.com/privacyidea/keycloak-provider/releases/download/v0.3/privacyIDEA.ftl
~$ cp PrivacyIDEA-Provider.jar /opt/keycloak/standalone/deployment/
~$ cp privacyIDEA.ftl /opt/keycloak/themes/base/login/</pre>



<p>In Keycloak, the authentication is managed in so called &#8220;Authentication Flows&#8221;. Copy the default browser-based flow below and rename it to PrivacyIDEA.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-browser-1024x341.png" alt="" class="wp-image-1808" width="768" height="256" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-browser-1024x341.png 1024w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-browser-300x100.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-browser-768x255.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-browser.png 1362w" sizes="auto, (max-width: 768px) 100vw, 768px" /></figure>



<p>Add an execution to &#8220;PrivacyIDEA Forms&#8221; and choose the installed plugin called PrivacyIDEA from the list.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution-button.png" alt="" class="wp-image-1810" width="760" height="96" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution-button.png 1013w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution-button-300x38.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution-button-768x97.png 768w" sizes="auto, (max-width: 760px) 100vw, 760px" /></figure>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution.png" alt="" class="wp-image-1809" width="516" height="142" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution.png 688w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-flow-add-execution-300x82.png 300w" sizes="auto, (max-width: 516px) 100vw, 516px" /></figure>



<p>Delete the unnecessary items in the flow (or set them to disabled), so that only &#8220;PrivacyIDEA Forms&#8221; and &#8220;Cookie&#8221; remain. The authentication flow should now look like this:</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-final-1024x280.png" alt="" class="wp-image-1813" width="768" height="210" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-final-1024x280.png 1024w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-final-300x82.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-final-768x210.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-final.png 1132w" sizes="auto, (max-width: 768px) 100vw, 768px" /></figure>



<p>We set PrivacyIDEA to REQUIRED here, which means that additionally to username and password, the second factor is required for all users. We have to configure the plugin to reach our privacyIDEA server at https://192.168.56.202. We disable SSL-verification for the self-signed certificate here, which you must not do in a productive environment. Members of the <code>no2fa</code> group, defined above will not be asked for their second factor. For issuing the trigger challenge a service account is needed. We use the <code>trigger-admin</code> account created in privacyIDEA earlier.<br></p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-config-button.png" alt="" class="wp-image-1812" width="603" height="74" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-config-button.png 804w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-config-button-300x37.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-authentication-privacyidea-config-button-768x94.png 768w" sizes="auto, (max-width: 603px) 100vw, 603px" /></figure>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-privacyidea-settings3.png" alt="" class="wp-image-1829" width="617" height="497" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-privacyidea-settings3.png 822w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-privacyidea-settings3-300x242.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-privacyidea-settings3-768x619.png 768w" sizes="auto, (max-width: 617px) 100vw, 617px" /></figure>



<p>Set the edited authentication flow as default browser flow in &#8220;Bindings&#8221;.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/binding.png" alt="" class="wp-image-1821" width="608" height="283" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/binding.png 811w, https://www.privacyidea.org/wp-content/uploads/2020/02/binding-300x139.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/binding-768x357.png 768w" sizes="auto, (max-width: 608px) 100vw, 608px" /></figure>



<p>So privacyIDEA is now configured to challenge the second factor for every user. The last step is to enable OpenID Connect logins in roundcubemail.</p>



<h3 class="wp-block-heading">Installation of the Kolab SSO plugin</h3>



<p>For the OIDC, Kolab provides the <code>kolab_sso</code> plugin for Roundcubemail which is available on git.kolab.org. Clone the repository and copy the plugin to the Roundcubemail directory to install it.</p>



<pre class="wp-block-preformatted has-small-font-size">~$ git clone https://git.kolab.org/diffusion/RPK/roundcubemail-plugins-kolab.git
~$ cp -r roundcubemail-plugins-kolab/plugins/kolab_sso/ /usr/share/roundcubemail/plugins/</pre>



<p>Place the default configuration file.</p>



<pre class="wp-block-preformatted has-small-font-size">~$ cp /usr/share/roundcubemail/plugins/kolab_sso/config.inc.php.dist /etc/roundcubemail/kolab_sso.inc.php</pre>



<p>Apache should redirect <code>host.roundcube/sso</code> to <code>host.roundcube/?_task=login&amp;_action=sso</code>, since keycloak does not support parameters in urls. It will display &#8220;Invalid parameter: redirect_uri&#8221;. Add the redirect as follows to /etc/apache2/sites-enabled/roundcubemail.conf.</p>



<pre class="wp-block-preformatted has-small-font-size">RewriteEngine On
RewriteCond %{REQUEST_URI} ^/roundcubemail
RewriteRule "^sso" "/roundcubemail/?_task=login&amp;_action=sso" [L,QSA]</pre>



<p>We proceed on the Keycloak machine and add Roundcubemail as a new OpenID Connect client as given below.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="834" height="1024" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-settings-834x1024.png" alt="" class="wp-image-1817" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-settings-834x1024.png 834w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-settings-244x300.png 244w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-settings-768x943.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-settings.png 1100w" sizes="auto, (max-width: 834px) 100vw, 834px" /></figure>



<p>Save the form to access the &#8220;Credentials&#8221; tab. We will soon need the generated secret again.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-credentials.png" alt="" class="wp-image-1818" width="804" height="187" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-credentials.png 804w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-credentials-300x70.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-roundcubemail-client-credentials-768x179.png 768w" sizes="auto, (max-width: 804px) 100vw, 804px" /></figure>



<p>The kolab_sso plugin needs the certificate of the Keycloak server during the OpenID Connect authentication process. It is available from the Keycloak management console in the &#8220;Realm Settings&#8221;.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="253" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-realm-certificate2-1024x253.png" alt="" class="wp-image-1831" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-realm-certificate2-1024x253.png 1024w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-realm-certificate2-300x74.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-realm-certificate2-768x190.png 768w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-realm-certificate2.png 1176w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Add the key and the client secret alongside the <code>token_uri</code> and <code>auth_uri</code> to the <code>kolab_sso.inc.php</code> configuration file. Make sure that the public key copied from keycloak is properly formatted. The IMAP, SMTP and LDAP credentials in the top part of the file are required for accessing the mailbox, sending emails and accessing the server addressbooks. Configure them accordingly.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="915" height="679" src="https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-kolab_sso-plugin-config-keycloak.png" alt="" class="wp-image-1807" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-kolab_sso-plugin-config-keycloak.png 915w, https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-kolab_sso-plugin-config-keycloak-300x223.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/kolab-kolab_sso-plugin-config-keycloak-768x570.png 768w" sizes="auto, (max-width: 915px) 100vw, 915px" /></figure></div>



<p>After successfully testing the ordinary password login with Roundcubemail at http://192.168.56.200/roundcubemail, you may disable the password login to allow only OpenID Connect by setting</p>



<pre class="wp-block-preformatted has-small-font-size"> $config['kolab_sso_disable_login'] = true;</pre>



<p>in <code>kolab_sso.inc.php</code>.</p>



<h3 class="wp-block-heading">Test the login</h3>



<p>We are now ready to test the OpenID Connect  login at Roundcubemail. Navigate once again to http://192.168.56.200/roundcubemail to test the login. You may monitor some log files during the process.</p>



<pre class="wp-block-preformatted has-small-font-size">/var/log/privacyidea/privacyidea.log
/var/log/roundcubemail/*
/opt/keycloak/standalone/log/*</pre>



<figure class="wp-block-gallery alignwide columns-4 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login.png"><img loading="lazy" decoding="async" width="453" height="287" src="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login.png" alt="" data-id="1840" data-link="https://www.privacyidea.org/?attachment_id=1840" class="wp-image-1840" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login.png 453w, https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login-300x190.png 300w" sizes="auto, (max-width: 453px) 100vw, 453px" /></a><figcaption class="blocks-gallery-item__caption">The Roundcubemail kolab_sso login&#8230;</figcaption></figure></li><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login.png"><img loading="lazy" decoding="async" width="577" height="514" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login.png" alt="" data-id="1836" data-link="https://www.privacyidea.org/?attachment_id=1836" class="wp-image-1836" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login.png 577w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login-300x267.png 300w" sizes="auto, (max-width: 577px) 100vw, 577px" /></a><figcaption class="blocks-gallery-item__caption">gets redirected to Keycloak.</figcaption></figure></li><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login_2FA.png"><img loading="lazy" decoding="async" width="525" height="305" src="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login_2FA.png" alt="" data-id="1837" data-link="https://www.privacyidea.org/?attachment_id=1837" class="wp-image-1837" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login_2FA.png 525w, https://www.privacyidea.org/wp-content/uploads/2020/02/keycloak-oidc_login_2FA-300x174.png 300w" sizes="auto, (max-width: 525px) 100vw, 525px" /></a><figcaption class="blocks-gallery-item__caption">After typing the password, the user is prompted to provide a second factor&#8230;</figcaption></figure></li><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/privacyIDEA_Authenticator.png"><img loading="lazy" decoding="async" width="540" height="327" src="https://www.privacyidea.org/wp-content/uploads/2020/02/privacyIDEA_Authenticator.png" alt="" data-id="1838" data-link="https://www.privacyidea.org/?attachment_id=1838" class="wp-image-1838" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/privacyIDEA_Authenticator.png 540w, https://www.privacyidea.org/wp-content/uploads/2020/02/privacyIDEA_Authenticator-300x182.png 300w" sizes="auto, (max-width: 540px) 100vw, 540px" /></a><figcaption class="blocks-gallery-item__caption">&#8230;which we get in this case from the OTP token in the privacyIDEA app.</figcaption></figure></li><li class="blocks-gallery-item"><figure><a href="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login_mailbox-1.png"><img loading="lazy" decoding="async" width="902" height="460" src="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login_mailbox-1.png" alt="" data-id="1842" data-full-url="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login_mailbox-1.png" data-link="https://www.privacyidea.org/?attachment_id=1842" class="wp-image-1842" srcset="https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login_mailbox-1.png 902w, https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login_mailbox-1-300x153.png 300w, https://www.privacyidea.org/wp-content/uploads/2020/02/roundcubemail-login_mailbox-1-768x392.png 768w" sizes="auto, (max-width: 902px) 100vw, 902px" /></a><figcaption class="blocks-gallery-item__caption">The correct OTP gets us directly to Roundcubemail webmail.</figcaption></figure></li></ul></figure>



<h3 class="wp-block-heading">Conclusion</h3>



<p>We demonstrated the integration of privacyIDEA with Keycloak to provide a solid basis to secure your applications with a second factor in a single sign-on (SSO) environment. For maximum flexibility, the system relies on standard protocols such as SAML or OpenID Connect (OIDC). The privacyIDEA keycloak-provider is designed to perfectly fit the two components together, uniting the rich identity management capabilities of Keycloak and the powerful multi factor management of privacyIDEA.</p>



<p>We chose the Roundcubemail webmailer of the Kolab Collaboration Server as an example application. The kolab_sso plugin provided the necessary interface to connect via OIDC to easily enhance security by adding a second factor managed by privacyIDEA. The setup of other popular open collaboration platforms such as <a href="https://www.tine20.com/en/">Tine 2.0</a> or <a href="https://www.open-xchange.com/">Open-Xchange</a> work similarly.</p>



<p>Including additional applications in this setup is very easy as long as they support at least one SSO protocol. These applications do not even to be hosted on your own servers. Nowadays, most cloud-based applications offer both, the possibility to use an external identity provider and to use OIDC. Thus, you can also use remote services with your own user base, defining access-rules to fit your needs.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.privacyidea.org/versatile-2fa-single-sign-on-with-keycloak-and-privacyidea/feed/</wfw:commentRss>
			<slash:comments>13</slash:comments>
		
		
			</item>
		<item>
		<title>Two Factor Authentication everywhere &#8211; This time at the Ohio Linuxfest</title>
		<link>https://www.privacyidea.org/two-factor-authentication-everywhere-this-time-at-the-ohio-linuxfest/</link>
		
		<dc:creator><![CDATA[Cornelius Kölbel]]></dc:creator>
		<pubDate>Sat, 26 Oct 2019 10:50:26 +0000</pubDate>
				<category><![CDATA[events]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[talk]]></category>
		<guid isPermaLink="false">https://www.privacyidea.org/?p=1644</guid>

					<description><![CDATA[privacyIDEA will be at the Ohio Linuxfest 2019. Learn how to add 2FA to your preferred application.]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-image"><figure class="aligncenter is-resized"><img loading="lazy" decoding="async" src="https://www.privacyidea.org/wp-content/uploads/2019/10/columbus-ohio-1024x556.jpg" alt="" class="wp-image-1645" width="510" height="277" srcset="https://www.privacyidea.org/wp-content/uploads/2019/10/columbus-ohio-1024x556.jpg 1024w, https://www.privacyidea.org/wp-content/uploads/2019/10/columbus-ohio-300x163.jpg 300w, https://www.privacyidea.org/wp-content/uploads/2019/10/columbus-ohio-768x417.jpg 768w, https://www.privacyidea.org/wp-content/uploads/2019/10/columbus-ohio.jpg 1280w" sizes="auto, (max-width: 510px) 100vw, 510px" /><figcaption>Columbus skyline, Ohio</figcaption></figure></div>



<p>privacyIDEA is the Open Source Two Factor solution that runs at a central location in your network and can work as the 2FA instance for all your applications. privacyIDEA provides plugins for several <a href="https://www.privacyidea.org/applications/">applications directly</a> (like WordPress, ownCloud, TYPO3, django, contao&#8230;) but also has plugins to serve standart authentication protocols like PAM, RADIUS, SAML2 and OpenID Connect.</p>



<p>You have the chance to use privacyIDEA everywhere &#8211; with every application.</p>



<p>Cornelius will give a talk about how privacyIDEA can be integrated with your preferred application at the <a rel="noreferrer noopener" aria-label="Ohio Linuxfest in Columbus, Ohio (opens in a new tab)" href="https://ohiolinux.org/speakers/#corneliuskoelbel" target="_blank">Ohio Linuxfest in Columbus, Ohio</a>. Your preferred application can be either connected via the before mentioned protocols or via the <a rel="noreferrer noopener" aria-label="privacyIDEA REST API (opens in a new tab)" href="https://privacyidea.readthedocs.io/en/latest/modules/api/validate.html" target="_blank">privacyIDEA REST API</a>. In this talk you can learn, how this can be achieve to use a secure login with your own or preferred application.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Add two factor authentication to your web application</title>
		<link>https://www.privacyidea.org/add-two-factor-authentication-web-application/</link>
		
		<dc:creator><![CDATA[Cornelius Kölbel]]></dc:creator>
		<pubDate>Sun, 15 Jan 2017 12:46:05 +0000</pubDate>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[login]]></category>
		<guid isPermaLink="false">https://www.privacyidea.org/?p=1127</guid>

					<description><![CDATA[This blog article describes, how you can add two factor authentication to your web application using the authentication system privacyIDEA. Two factor authentication has been added this way to ownCloud/Nextcloud, OTRS, dokuwiki, WordPress, TYPO3, Django, Kopano (Zarafa) and SimpleSAMLphp. See the plugin section of the privacyIDEA online documentation. Two different concepts There are basically two [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/01/code-1839406_1280.jpg"><img loading="lazy" decoding="async" class="size-medium wp-image-1138 alignleft" src="https://www.privacyidea.org/wp-content/uploads/2017/01/code-1839406_1280-300x200.jpg" alt="" width="300" height="200" srcset="https://www.privacyidea.org/wp-content/uploads/2017/01/code-1839406_1280-300x200.jpg 300w, https://www.privacyidea.org/wp-content/uploads/2017/01/code-1839406_1280-768x512.jpg 768w, https://www.privacyidea.org/wp-content/uploads/2017/01/code-1839406_1280-1024x683.jpg 1024w, https://www.privacyidea.org/wp-content/uploads/2017/01/code-1839406_1280.jpg 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a>This blog article describes, how you can add two factor authentication to your web application using the authentication system privacyIDEA.</p>
<p>Two factor authentication has been added this way to ownCloud/Nextcloud, OTRS, dokuwiki, WordPress, TYPO3, Django, Kopano (Zarafa) and SimpleSAMLphp. See the <a href="http://privacyidea.readthedocs.io/en/latest/application_plugins/index.html" target="_blank">plugin section of the privacyIDEA online documentation</a>.</p>
<h2>Two different concepts</h2>
<p>There are basically two ways for the user to provide a second factor during authentication. The first one is to completely replace the authentication of your webapplication. In this case your application delegates the complete authentication process to privacyIDEA. This is implemented e.g. in the <a href="https://github.com/privacyidea/privacyidea/tree/master/authmodules/OTRS" target="_blank">OTRS plugin</a> and the <a href="https://github.com/privacyidea/wordpress-strong-authentication" target="_blank">WordPress plugin</a>. In this case the plugin will take care of the first <em>and</em> second factor. And in certain cases it will also take care of the WebUI Login Screen.</p>
<p>The other possiblity is that your application uses its normal password based authentication, but after the user has successfully authenticated with his usual username and the application password, your application decides, not to immediately allow access, but hand over the authentication to the 2FA plugin, which will take care of quering the second factor. This is implemented in the <a href="https://github.com/NetKnights-GmbH/privacyidea-owncloud-app" target="_blank">privacyIDEA ownCloud App</a>.</p>
<p>In addition we already published some <a href="https://github.com/privacyidea/AuthModuleRequirements" target="_blank">basic requirements for <em>modular</em> two factor authentication</a> in a web application.</p>
<h3>Hand complete authentication process to the 2FA plugin</h3>
<p>Your application should allow to register or configure a 3rd party module or class. This class would have to provide a method like <em>authenticate_user</em> for verifying the users input. The easiest way would be, that such a plugin does not even has to change or bring its own login screen. In such simple case, the authentication method <em>authenticate_user</em> would simple receive the credentials, that were entered at your applications default login screen. It then would return True or False or maybe raise an exception.</p>
<p>The privacyIDEA plugin for your webapplication would use this username and this password to issue a call to the privacyIDEA REST API. The plugin would call the <a href="http://privacyidea.readthedocs.io/en/latest/modules/api/validate.html#post--validate-check" target="_blank">/validate/check</a> endpoint with <em>username</em> and <em>password</em> as parameters and simply evaluate the JSON response.</p>
<p>Managing users, returning user attributes or listing users would be out of scope of such an authentication plugin. Authorization would be out of scope, just as it is with the Unix PAM stack.</p>
<h4>Example OTRS</h4>
<p>An example implementation of the complete authentication replacement is the OTRS plugin for privacyIDEA.</p>
<p>In this case the administrator can configure in OTRS which Perl module should be used for authenticating the user. <strong>Note</strong>: Not for verifying if the user exists and not for fetching attributes like given name or email address of the user.</p>
<p>The Perl module has to provide a function <em>Auth</em>, which takes a dictionary/hash with the keys <em>User</em> and <em>Pw</em>. If the credentials were verified successfully this function returns the Username of the user, otherwise an empty string.</p>
<p><a href="https://github.com/privacyidea/privacyidea/blob/master/authmodules/OTRS/privacyIDEA-4_0.pm#L86" target="_blank">See the implementation at github</a>.</p>
<p>In this case, privacyIDEA takes care of verifying two factors. The user has entered a knowledge and a One Time Password (2nd factor: possession) into the password field. privacyIDEA knows how to verify the static password (knowledge) and the OTP value.</p>
<h4>Example WordPress</h4>
<p>The WordPress plugin works the same. It does not modify the login screen, as this is not necessary. The user enters his static password and his one time password in the password field. The WordPress plugin registers or overwrites the function <a href="https://github.com/privacyidea/wordpress-strong-authentication/blob/master/strong-authentication.php#L236" target="_blank">wp_authenticate</a>, which takes the credentials that were entered by the user. WordPress relies on the return value of this function, which again is either a WordPress User object or null.</p>
<p>Within this function of the plugin, the credentials are verified against the configured privacyIDEA server. In this case this is done using <a href="https://github.com/privacyidea/wordpress-strong-authentication/blob/master/strong-authentication.php#L63" target="_blank">curl</a>.</p>
<p><strong>Note</strong>: All authentication requests are forwarded to privacyIDEA. WordPress does not know if the user has a second factor or not. It does not know, which kind of second factor a user has. This is all handled by privacyIDEA. This way the plugin can be kept rather light weight.</p>
<h3>Only hand second factor to the 2FA plugin</h3>
<p>Instead of passing the complete authentication process to the 3rd party plugin, you can also design your authentication framework this way, that your application still verifies the static user password and request an additional authentication on top.</p>
<p>This can be interesting, if your application needs to know the user password, since it is used to contact email servers or encrypt data.</p>
<p>Your application will verify the password as before. But in addition it will pass the controll the the 2FA plugin</p>
<h4>Example ownCloud</h4>
<p>The ownCloud 2FA Framework is implemented this way.</p>
<p>In the first step the user has to authenticate against ownCloud with the ownCloud password.</p>
<p><figure id="attachment_1134" aria-describedby="caption-attachment-1134" style="width: 300px" class="wp-caption alignnone"><a href="https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-first-factor.png"><img loading="lazy" decoding="async" class="wp-image-1134 size-medium" src="https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-first-factor-300x264.png" width="300" height="264" srcset="https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-first-factor-300x264.png 300w, https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-first-factor.png 524w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-1134" class="wp-caption-text">User authenticates with his normal ownCloud password.</figcaption></figure></p>
<p>If the user entered the correct password, which is still verified by ownCloud, the web application (ownCloud) calls the 2FA plugin to ask for the second factor.</p>
<p><figure id="attachment_1135" aria-describedby="caption-attachment-1135" style="width: 297px" class="wp-caption alignnone"><a href="https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-second-factor.png"><img loading="lazy" decoding="async" class="wp-image-1135 size-medium" src="https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-second-factor-297x300.png" width="297" height="300" srcset="https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-second-factor-297x300.png 297w, https://www.privacyidea.org/wp-content/uploads/2017/01/owncloud-second-factor.png 481w" sizes="auto, (max-width: 297px) 100vw, 297px" /></a><figcaption id="caption-attachment-1135" class="wp-caption-text">If the user entered the correct static ownCloud password, he is asked for the second factor.</figcaption></figure></p>
<p>The ownCloud 2FA framework requires the plugin to register a Class that is <a href="https://github.com/NetKnights-GmbH/privacyidea-owncloud-app/blob/master/twofactor_privacyidea/lib/Provider/TwoFactorPrivacyIDEAProvider.php#L34" target="_blank">derived from a certain 2FA base class</a>. This way the web application (ownCloud) knows, if two factor authentication can be used for the user, who is already authenticated in the first step.</p>
<p>The 2FA framework then asks the plugin/class to <a href="https://github.com/NetKnights-GmbH/privacyidea-owncloud-app/blob/master/twofactor_privacyidea/lib/Provider/TwoFactorPrivacyIDEAProvider.php#L81" target="_blank">provide a template for the 2nd step of the Login UI</a>. Finally the 2FA framework calls a <a href="https://github.com/NetKnights-GmbH/privacyidea-owncloud-app/blob/master/twofactor_privacyidea/lib/Provider/TwoFactorPrivacyIDEAProvider.php#L93" target="_blank">class method in the plugin to verify the 2nd factor</a>.</p>
<p>This good thing about it is, that ownCloud can know the user&#8217;s password and thus use the user&#8217;s for encryption and sending emails. The drawback of this design is, that the authentication workflow might be a bit more complicated, exspecially if it comes to special scenarios like challenge response authentication.</p>
<h2>Special case for Challenge Response token like SMS and Email</h2>
<p>Although <a href="https://netknights.it/en/lasting-two-factor-authentication-with-privacyidea/" target="_blank">NIST recommended to not use SMS for two factor authentication</a> it is still an attractive and easy way. In addition privacyIDEA can run any combination of authentication devices. Some users may use Yubikeys, others Google Authenticators, some users use key fob tokens and another group could use SMS.</p>
<p>But privacyIDEA needs additional information to trigger an SMS. Not everybody can trigger the sending of an SMS, otherwise the user would get spammed with SMS on his mobile phone.</p>
<p>There are two ways to trigger and SMS:</p>
<ol>
<li>The user authenticates with his OTP PIN (static password). privacyIDEA realizes, that this is the correct password for an SMS token and will send the SMS.</li>
<li>An administrative or system account requests the sending of an SMS for this specific user.</li>
</ol>
<p>In both cases the 2FA framework of your application has to provide the possibility to issue a REST request before the user authenticats. Because this first REST request will send the user the code, which he then can use to finally authenticate.</p>
<p>Most applications do not allow this easily today.</p>
<p>There is a beta implementation for the ownCloud 2FA framework, which is not that perfect. The <a href="https://github.com/NetKnights-GmbH/privacyidea-owncloud-app/blob/challenge-response/twofactor_privacyidea/lib/Provider/TwoFactorPrivacyIDEAProvider.php#L149" target="_blank">SMS is triggered when the Login UI is rendered</a>. This has the side effect that the SMS is triggered again, if the user entered a wrong OTP value, since the UI is rendered again.</p>
<p>When designing the authentication framework of your web applications, you could have such corner cases in mind.</p>
<h2>Now it is your turn!</h2>
<p>If you want to add 2FA to your web application, please contact us in our <a href="https://groups.google.com/forum/#!forum/privacyidea" target="_blank">Google Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
