SAML (Security Assertion Markup Language) Configuration
=======================================================
.. attention::
It is important to make sure ``registration.require.email.activation`` is
set to false in Application Configuration. If email activation is enabled
users will never be able to log in.
LibreBooking SAML Introduction
------------------------------
LibreBooking comes with multiple Single Sign On plugins out of the box.
There are many benefits to SSO over standard authentication. For
administrators, having a single point of account credential and access
administration is very valuable. If someone leaves the organization they
don’t have to deactivate accounts in multiple systems. For your normal
user, the benefit is not having to register and remember yet another set
of application credentials.
In this post we’ll cover how to set up SSO with SAML. Most SSO
configurations for LibreBooking are pretty straightforward – you just
update the configuration options for the plugin. But SAML is different.
SAML requires a 3rd party application called
`SimpleSAMLphp `__
to be running on the same server as LibreBooking.
Install SimpleSAMLphp
---------------------
Our first step is to download the latest version of
`SimpleSAMLphp `__
and install it on your web server. I recommend installing it outside
your publicly visible directories and set up a subdomain pointing to the
www directory. For example, if you install it to
``/home/username/simplesamlphp`` and you have LibreBooking running out
of ``/home/username/public\_html/librebooking``, then you’d create a
subdomain such as ``saml.librebooking.xpto`` pointing to
``/home/username/simplesamlphp/www``. The reason we do this is because
the only files which need to be publicly visible in SimpleSAMLphp are
located in the www directory. Exposing more than that opens unnecessary
security holes.
Configure SimpleSAMLphp
-----------------------
SimpleSAMLphp has a lot of configuration options. If you’re like me and
far from an expert in SAML, it’s overwhelming. Luckily, since
LibreBooking is a Service Provider it doesn’t need anything special.
I’ll go through each of the settings that need to be updated
individually.
.. note::
At the time of writing this post, the latest version of SimpleSAMLphp was
1.18.5. It’s possible that the names of the options will change in future
versions.
Copy ``/home/username/simplesamlphp/config/config.php.dist`` to
``/home/username/simplesamlphp/config/config.php``
Open up ``/home/username/simplesamlphp/config/config.php`` with a text
editor.
``baseurlpath`` - Set this to the full path of the SimpleSAMLphp WWW
directory. If you followed the above advice and created a subdomain,
this should be something like ``https://saml.yourdomain.com``
``technicalcontact_email`` - Your email address (or anyone responsible
for managing SSO integrations)
``secretsalt`` - Set this to any secure, random value.
``auth.adminpassword`` - Set this to any secure, random value, you will
use this to access the admin page of the web UI for SimpleSAML.
``trusted.url.domains`` - This should be set to an array of domains that
will participate in the SSO handshake. I use
``array('saml.librebooking.com', 'librebooking.com')``
``session.cookie.domain`` - This should be set to the wildcard subdomain
of your primary domain. For example, I use ``.librebooking.com``
``session.cookie.secure`` - This should be set to true, assuming all
traffic is sent over https.
``store.type`` - Set this to ``sql``. This ensures that PHP sessions
from LibreBooking and sessions from SimpleSAMLphp do not conflict.
``store.sql.dsn`` - This should be set to a writable location for the
sqlite database. You **must** have SQLite support in PHP enabled for
this to work. Alternatively, you can set up any PDO supported database
to store session data. Since I use SQLite, I have this set to something
like ``sqlite:/home/username/tmp/sqlitedatabase.sq3``
Exchange Metadata
-----------------
Now that we have the configuration set, we’ll need to exchange metadata.
The first thing to do is get the metadata XML from the Identity Provider
that you’re integrating with. For example in Azure apps you can find
this under Manage -> Single sign-on -> SAML Certificates -> Federation
Metadata XML
SimpleSAMLphp has a handy metadata XML conversion tool, which we’ll use
to finish up our configuration.
- Open the admin page from the subdomain for SimpleSAMLphp in a browser
(https://saml.librebooking.com/admin was what I used).
- You’ll be prompted to enter the *auth.adminpassword* that you set in
your config.php
- Click on the *Federation* tab
- then the *XML to SimpleSAMLphp metadata converter* link.
- Paste in the XML or, if you have it saved to a file, upload it.
- SimpleSAMLphp will output at least one PHP version of that metadata.
- For each one of those, create a file with that name plus ``.php`` in
the folder ``/home/username/simplesamlphp/metadata``. The file should
contain ``