The following steps will provide a manageable solution for simpleSAMLphp in a composer project.
Copy ScriptHandler.php
file into scripts/simplesamlphp/
folder of your project (I'm using drupal-composer project)
Add class to the classmap
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php",
"scripts/simplesamlphp/ScriptHandler.php"
],
"files": ["load.environment.php"]
},
Add setup script to post-install/update-cmd
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
"DrupalProject\\simplesamlphp\\ScriptHandler::setupSimpleSAMLphp"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
"DrupalProject\\simplesamlphp\\ScriptHandler::setupSimpleSAMLphp"
]
This can be done a few ways. I'm assuming you are running drupal/core:>=8.8.1
and using cweagans/composer-patches
but basically what we are doing is patching core in the most basic ways. This may change in the future but for now this is the best way. In 8.8.0+ the .htaccess is scaffolded every time so changes are overwritten.
I've included a prebuilt patch for 8.8.1+ below. If you need to make your own follow the instructions in 3a then come back here.
Copy the htaccess.patch
file into a scaffold-modifications
folder. This is per #3095214-3. Then wire it up in composer-patches.
"patches": {
"drupal/core":{
"Htaccess Modifications": "scaffold-modifications/htaccess.patch",
}
}
- Clone the drupal project somewhere
git clone [email protected]:project/drupal.git
. - Checkout a tag that matches whatever version you are running
git checkout 8.8.1
. - Edit the htaccess (notice the lack of a leading .)
vim core/assets/scaffold/htaccess
. - Find
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
. - Directly after that add:
# Allow access to simplesaml paths
RewriteCond %{REQUEST_URI} !^/simplesaml
- Create a patch using
git diff htaccess > htaccess.patch
.
Later on a symlink will be created. Add /web/simplesaml
to your .gitignore file, so it doesn't get tracked.
Fire off composer dump-autoload && composer install && composer update --lock
.
This will get the script loaded and drupal/core patched. You MUST complete this step before trying to install simpleSAMLphp.
This can also be done multiple ways. You can require the simplesamlphp project directly, so you have more control over the version, or require a drupal module that requires it. Pick your method:
composer require 'simplesamlphp/simplesamlphp:1.18.4'
OR
composer require 'drupal/simplesamlphp_auth:^3.2'
After installation, you will have two new files in config/simplesamlphp/
, config.php
and authsources.php
.
- Commit both of these files to git.
- Modify them as needed for your configuration
- Run the script again to copy the new files into simpleSAML
composer run-script post-update-cmd
.
Each time you run composer install
or composer update
, the script copies the configs from config/simplesamlphp
into the simpleSAMLphp application. This will keep your installation up-to-date as well as help you when making changes.
Have Fun!
Known Issues:
- You cannot work with this locally, you must be on a live domain with SSL configured.
- The htaccess patch will have no effect if your server is using Nginx. See the simpleSAMLphp documentation for this. No alias is needed as we are doing a symlink.
Sources: