How to get SSAD
Fragment block
in decrypting you hard drive (you do use
Single Sign on with Active Directory in Drupal 8
Denial
As in most open source communities, in the Drupal community there is a healthy distrust against closed source software like Windows. On the other hand, in many large organisations closed source applications are embraced because of the feeling that lives among decision makers that is good to have a large commercial partner that is responsible for maintaining and extending
business critical applications.
So, like it or not, there are situations where our open source application wil have to connect to some closed source application and one of the situations I personal y encounter most often, is the situation where user accounts are stored in an Active Directory and the users must be able
to login to the website using there Active Directory account.
Anger
Although anger certainly is a stage I have to go through in any software development project, I really think it is an emotion one should not spent to much energy on. If anger is something you are into, take a yoga class, or take a good long run. It helps.
Bargaining
So back to useful information. There are a number of things that must be taken care of before we can start to connect to Active Directory.
First of al , you should be able to connect to the Active Directory server. This may seem like stating the obvious, but in almost al projects I have done in which the website has to connect to Active Directory server (or any other external database system for that matter), there comes the moment at which you ask a sysadmin for the access details and the answer wil be something like "No way an external developer like you gets any access to our internal data servers".
And, and this is free of any irony or sarcasm: of course she is absolutely right! Services likes this most of the time contain tons of personal data which you do not want to share with any external party, even in situations where this would be legal. So this real y is where the bargaining starts: you wil have to have someway of connecting to the AD-server to realize the single sign on service, and so you have to be prepared to make some sacrifices and/or compromises like developing through a (more or less stable) VPN-connection, physical y be present at the clients office etc...
When this is handled, we can start to do that in which we do excel: diving in to code and getting things to work.
Forst step is to get SimpleSAML. The latest version can be downloaded from the SimpleSAML site, but in our Drupal 8 projects we use Composer to maintain modules and dependencies. So to include the simplesamlphp_auth-module in our project we use:
> composer require drupal/simplesamlphp_auth
This module has a dependency on the SimpleSAML library defined in its own composer.json:
"require": {
"simplesamlphp/simplesamlphp": "~1.14.11"
}
The directory structure we are using is the following:
Project root
|- config (configuation directory)
|- docroot (website directory)
|- Documentation
|- private_files
|- settings
|- utility
|- vendor (Composer directory)
Which means that the SimpleSAML library and the dependency SAML2 are downloaded to
vendor/simplesamlphp
This of course only installs the default code and settings and the question is how do we configure SimpleSAML. We can not simply add or edit the config in vendor/simplesamlphp/simplesamlphp
because that directory can be overwritten after a composer install or composer update (and, in our setup, is not even included in the git-repository) .
The solution implemented by the SimpleSAML developers is using the vhost-config of the website to tel SImpleSAML where the configuration is stored. So if the website on which we want to SimpleSAML is 'ad-example.org', edit the vhost, which on my system can be done with:
> vim /etc/apache2/sites-available/ad-example.org.conf
And in the vhost-configuration include the fol owing setting (this assumes the project root is located at /var/www/ad-example):
SetEnv SIMPLESAMLPHP_CONFIG_DIR /var/www/ad-example/config/simplesamlphp
And while we are at it, an alias to the SimpleSAML environment should also be included in the vhost-configuration:
Alias /simplesaml /var/www/ad-example/vendor/simplesamlphp/simplesamlphp/www
<Directory /var/www/ad-example/vendor/simplesamlphp/simplesamlphp/www>
<IfModule !mod_authz_core.c>
# For Apache 2.2:
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
# For Apache 2.4:
Require all granted </IfModule>
</Directory>
Basicall y this says: the directory '/var/www/ad-example/vendor/simplesamlphp/simplesamlphp/www' is accessible from 'http://ad-example.org/simplesaml'
Now SimpleSAML knows its configuration is located at /var/www/ad-example/config/simplesamlphp. This directory contains all the config for the modules used in SimpleSAML, see the config template in the vendor directory:
vendor/simplesamlphp/simplesamlphp/config-templates`
Which contains the following files:
- acl.php
- authmemcookie.php
- authsources.php
- cas-ldap.php
- config.php
- config-login-auto.php
- config-login-feide.php
- ldap.php
- ldapmulti.php
- translation.php
- 'technicalcontact_name'
- 'technicalcontact_email'
- 'timezone'
- 'baseurlpath' => path to the SimpleSAML pages
- 'certdir' => directory in which SimpleSAML stores its certificates. For safety reasons it is advisable to locate this outside the website-docroot.
- 'datadir' => directory in which SimpleSAML stores its other date. For safety reasons it is advisable to locate this outside the website-docroot.
- 'loggingdir' => directory in which SImpleSAML stores it logs.
- 'templatedir' => directory in which SimpleSAML stores the HTML-templates is uses for its own pages. We wil get back to this later.