Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit edc99ed

Browse files
dooleymattgrasmash
authored andcommitted
BLT-481: BLT/SimpleSAMLphp Integration (#478)
* Adds simplesaml files and tasks to blt. * Updates simplesaml phing task and blt settings. * Fixes symlink from docroot to library. * Cleans up simplesamlphp.xml targets. * Adds a simplesamlphp-setup.md readme file. * Moves simplesaml files to scripts dir. * Updates path to library in simplesamlphp.settings.php. * Updates the config init task to include the Acquia snippet. * Renames the htaccess target, adds comments. * Renames init complete target. * Fixes incorrect target name in complete message. * Adds readme to mkdocs.yml, removes property from project.yml. * Fixes incorrect checks of the simplesamlphp property. * Adds high level checks of SimpleSAMLphp installation to BltDoctorCommand. * Updates BltDoctorCommand to remove some cruft.
1 parent ed55654 commit edc99ed

File tree

10 files changed

+433
-1
lines changed

10 files changed

+433
-1
lines changed

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pages:
4141
- Release process: 'readme/release-process.md'
4242
- Release notes: 'scripts/release-notes/README.md'
4343
- Setting up continuous integration: 'readme/ci.md'
44+
- Setting up SSO with SimpleSAMLphp: 'readme/simplesamlphp-setup.md'
4445
- Open source contribution: 'readme/os-contribution.md'
4546
- Troubleshooting & Support: 'readme/support.md'
4647
- Extending / Overriding BLT: 'readme/extending-blt.md'

phing/build.xml

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
<!-- Contains Drupal VM tasks. -->
6969
<import file="${phing.dir}/tasks/vm.xml"/>
7070

71+
<!-- Contains Drupal SimpleSAMLphp tasks. -->
72+
<import file="${phing.dir}/tasks/simplesamlphp.xml"/>
73+
7174
<!-- Disable targets defined in the disable-targets array in project.yml. -->
7275
<!-- This must be executed after all targets are defined. -->
7376
<disabletargets file="${repo.root}/project.yml" property="disable-targets"/>

phing/tasks/deploy.xml

+8
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
<phingcall target="target-hook:invoke">
7878
<property name="hook-name" value="post-deploy-build"/>
7979
</phingcall>
80+
81+
<available property="simplesamlphp" file="${blt.root}/settings/simplesamlphp.settings.php"/>
82+
<if>
83+
<equals arg1="${simplesamlphp}" arg2="true"/>
84+
<then>
85+
<phingcall target="simplesamlphp:deploy:config"/>
86+
</then>
87+
</if>
8088
</target>
8189

8290
<target name="deploy:commit" hidden="true">

phing/tasks/setup.xml

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@
6363
<target name="setup:build" description="Generates all required files for a full build. E.g., (re)builds docroot, etc."
6464
depends="setup:git-hooks, setup:drupal:settings, setup:behat, setup:composer:install, frontend">
6565

66+
<available property="simplesamlphp" file="${blt.root}/settings/simplesamlphp.settings.php"/>
67+
<if>
68+
<equals arg1="${simplesamlphp}" arg2="true"/>
69+
<then>
70+
<phingcall target="simplesamlphp:build:config"/>
71+
</then>
72+
</if>
73+
6674
<phingcall target="target-hook:invoke">
6775
<property name="hook-name" value="post-setup-build"/>
6876
</phingcall>

phing/tasks/simplesamlphp.xml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<project name="simplesamlphp" default="simplesamlphp:init">
2+
3+
<target name="simplesamlphp:init" description="Initializes SimpleSAMLphp for project.">
4+
5+
<!-- Adds simplesamlphp_auth as a dependency. -->
6+
<available property="simplesamlphp" file="${blt.root}/settings/simplesamlphp.settings.php"/>
7+
8+
<if>
9+
<not><equals arg1="${simplesamlphp}" arg2="true"/></not>
10+
<then>
11+
<phingcall target="simplesamlphp:lib:init"/>
12+
13+
<!-- Copies the configuration templates from the library to a simplesamlphp directory located in the project root. -->
14+
<phingcall target="simplesamlphp:config:init"/>
15+
16+
<!-- Copies a settings file used by the simplesamlphp_auth module to blt's settings dir. -->
17+
<phingcall target="simplesamlphp:settings"/>
18+
19+
<!-- Creates a symlink from the docroot to the web accessible library dir. -->
20+
<echo>Creating a symbolic link from ${docroot}/simplesaml to web accessible directory in the simplesamlphp library</echo>
21+
<symlink target="../vendor/simplesamlphp/simplesamlphp/www/" link="${docroot}/simplesaml" overwrite="true" />
22+
23+
<!-- Outputs a message to edit the new config files. -->
24+
<phingcall target="simplesamlphp:init:complete"/>
25+
</then>
26+
<else>
27+
<echo>SimpleSAMLphp has already been initialized by BLT.</echo>
28+
</else>
29+
</if>
30+
</target>
31+
32+
<!-- Adds simplesamlphp_auth as a dependency. -->
33+
<target name="simplesamlphp:lib:init" hidden="true">
34+
<echo>Adding SimpleSAMLphp Auth module as a dependency.</echo>
35+
<exec dir="${repo.root}" command="composer require drupal/simplesamlphp_auth:8.3.x-dev#283994f" logoutput="true" checkreturn="true" passthru="true" level="info"/>
36+
</target>
37+
38+
<!-- Copies the configuration templates from the library to a simplesamlphp directory located in the project root. -->
39+
<target name="simplesamlphp:config:init" hidden="true">
40+
<echo>Copying config files to ${repo.root}/simplesamlphp/config.</echo>
41+
<copy todir="${repo.root}/simplesamlphp/config" overwrite="false">
42+
<filelist dir="${repo.root}/vendor/simplesamlphp/simplesamlphp/config-templates" files="authsources.php, config.php"/>
43+
</copy>
44+
<exec dir="${repo.root}/simplesamlphp/config" command="curl https://gist.githubusercontent.com/acquialibrary/8059715/raw/a6dc376bfb5068a2c7fe01be315d13bd47d4c10b/9191_config.php > acquia_config.php" passthru="true"/>
45+
<append destFile="${repo.root}/simplesamlphp/config/config.php" file="${repo.root}/simplesamlphp/config/acquia_config.php">
46+
<filterchain>
47+
<replaceregexp>
48+
<regexp pattern=".*php\n" replace="" ignoreCase="true"/>
49+
</replaceregexp>
50+
</filterchain>
51+
</append>
52+
<echo>Copying config files to ${repo.root}/simplesamlphp/metadata.</echo>
53+
<copy todir="${repo.root}/simplesamlphp/metadata" file="${repo.root}/vendor/simplesamlphp/simplesamlphp/metadata-templates/saml20-idp-remote.php" overwrite="false"/>
54+
</target>
55+
56+
<!-- Copies a settings file used by simplesamlphp_auth to blt settings dir. -->
57+
<target name="simplesamlphp:settings" hidden="true">
58+
<echo>Adding a simplesamlphp.settings.php file.</echo>
59+
<copy file="${blt.root}/scripts/simplesamlphp/simplesamlphp.settings.php" tofile="${blt.root}/settings/simplesamlphp.settings.php" overwrite="false"/>
60+
</target>
61+
62+
<!-- Copies customized config files into the library on deployments. -->
63+
<target name="simplesamlphp:deploy:config" description="Copies config template files to the appropriate place in simplesamlphp library." hidden="true">
64+
<echo>Copying config files to the appropriate place in simplesamlphp library in the deploy artifact.</echo>
65+
<copy todir="${repo.root}/deploy/vendor/simplesamlphp/simplesamlphp" overwrite="true">
66+
<fileset dir="${repo.root}/simplesamlphp/" />
67+
</copy>
68+
<copy file="${blt.root}/scripts/simplesamlphp/gitignore.txt" tofile="${repo.root}/deploy/vendor/simplesamlphp/simplesamlphp/.gitignore" overwrite="true"/>
69+
</target>
70+
71+
<!-- Copies customized config files into the library on builds. -->
72+
<target name="simplesamlphp:build:config" description="Copies config template files to the appropriate place in simplesamlphp library.">
73+
<echo>Copying config files to the appropriate place in simplesamlphp library.</echo>
74+
<copy todir="${repo.root}/vendor/simplesamlphp/simplesamlphp" overwrite="true">
75+
<fileset dir="${repo.root}/simplesamlphp/" />
76+
</copy>
77+
<copy file="${blt.root}/scripts/simplesamlphp/gitignore.txt" tofile="${repo.root}/vendor/simplesamlphp/simplesamlphp/.gitignore" overwrite="true"/>
78+
</target>
79+
80+
<!-- Outputs a message to edit the new config files. -->
81+
<target name="simplesamlphp:init:complete" hidden="true">
82+
<echo>
83+
84+
85+
============================================================================
86+
To complete the setup you must manually modify several files.
87+
============================================================================
88+
89+
* ${docroot}/.htaccess
90+
* ${repo.root}/simplesamlphp/config/config.php
91+
* ${repo.root}/simplesamlphp/config/authsources.php
92+
* ${repo.root}/simplesamlphp/metadata/saml20-idp-remote.php
93+
94+
95+
After editting these files execute the following command to copy the
96+
modified files to the correct location in the SimpleSAMLphp library
97+
98+
'blt simplesamlphp:build:config'
99+
100+
============================================================================
101+
See simplesamlphp-setup.md for details on how to modify the files.
102+
============================================================================
103+
104+
105+
</echo>
106+
</target>
107+
108+
</project>

readme/simplesamlphp-setup.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SimpleSAMLphp Setup
2+
3+
To configure SimpleSAMLphp, perform the following steps after initially setting up BLT:
4+
5+
1. Execute `blt simplesamlphp:init`. This will perform the initial setup tasks including:
6+
* Adds the simplesamlphp_auth module as a project dependency.
7+
* Copies congigruation files to `${project.root}/simplesamlphp`
8+
* Adds a simplesamlphp property to project.yml
9+
* Creates a symbolic link in the docroot to the web accessible directory of the simplesamlphp library.
10+
* Adds a settings.php file to the project's default settings directory.
11+
12+
1. Edit `docroot/.htaccess` to include the following 2 lines. Note: the only 2 lines that need to be added are the lines marked with "+" signs.
13+
14+
# Copy and adapt this rule to directly execute PHP files in contributed or
15+
# custom modules or to run another PHP application in the same directory.
16+
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
17+
+ # Allow access to simplesaml paths
18+
+ RewriteCond %{REQUEST_URI} !^/simplesaml
19+
# Deny access to any other PHP files that do not match the rules above.
20+
RewriteRule "^.+/.*\.php$" - [F]
21+
22+
1. Edit `${project.root}/simplesamlphp/config/config.php`
23+
* This file has been pre-populated with a code snippet recommended for Acquia Cloud Environments. You will need to edit the `$config` array for your local environment.
24+
* Update your database name in `$ah_options`
25+
26+
$ah_options = array(
27+
'database_name' => '[DATABASE-NAME]',
28+
'session_store' => array(
29+
'prod' => 'memcache', // This can be either `memcache` or `database`
30+
'test' => 'memcache', // This can be either `memcache` or `database`
31+
'dev' => 'database', // This can be either `memcache` or `database`
32+
),
33+
);
34+
* Update the following values int the `$config` array
35+
36+
37+
$config['technicalcontact_name'] = "Technical Contact Name";
38+
$config['technicalcontact_email'] = "[email protected]";
39+
$config['secretsalt'] = '[YOUR-SECERET-SALT]';
40+
$config['auth.adminpassword'] = '[ADMIN-PASSWORD]';
41+
42+
1. Edit `${project.root}/simplesamlphp/config/authsources.php`
43+
1. Edit `${project.root}/simplesamlphp/metadata/saml20-idp-remote.php`
44+
1. Execute `blt simplesamlphp:config:build` to copy these configuration files to the SimpleSAMLphp library.
45+
1. Commit the changes.
46+

scripts/simplesamlphp/gitignore.txt

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
.gitignore
2+
log
3+
4+
!config/.gitkeep
5+
!metadata/.gitkeep
6+
7+
# https://www.gitignore.io/api/osx,windows,linux,netbeans,sublimetext,composer,phpstorm,vagrant
8+
# Created by https://www.gitignore.io
9+
10+
# Created by https://www.gitignore.io
11+
12+
### OSX ###
13+
.DS_Store
14+
.AppleDouble
15+
.LSOverride
16+
17+
# Icon must end with two \r
18+
Icon
19+
20+
21+
# Thumbnails
22+
._*
23+
24+
# Files that might appear in the root of a volume
25+
.DocumentRevisions-V100
26+
.fseventsd
27+
.Spotlight-V100
28+
.TemporaryItems
29+
.Trashes
30+
.VolumeIcon.icns
31+
32+
# Directories potentially created on remote AFP share
33+
.AppleDB
34+
.AppleDesktop
35+
Network Trash Folder
36+
Temporary Items
37+
.apdisk
38+
39+
40+
### Windows ###
41+
# Windows image file caches
42+
Thumbs.db
43+
ehthumbs.db
44+
45+
# Folder config file
46+
Desktop.ini
47+
48+
# Recycle Bin used on file shares
49+
$RECYCLE.BIN/
50+
51+
# Windows Installer files
52+
*.cab
53+
*.msi
54+
*.msm
55+
*.msp
56+
57+
# Windows shortcuts
58+
*.lnk
59+
60+
61+
### Linux ###
62+
*~
63+
64+
# KDE directory preferences
65+
.directory
66+
67+
# Linux trash folder which might appear on any partition or disk
68+
.Trash-*
69+
70+
### Eclipse ###
71+
.project
72+
73+
### NetBeans ###
74+
nbproject/private/
75+
build/
76+
nbbuild/
77+
dist/
78+
nbdist/
79+
nbactions.xml
80+
nb-configuration.xml
81+
.nb-gradle/
82+
83+
84+
### SublimeText ###
85+
# cache files for sublime text
86+
*.tmlanguage.cache
87+
*.tmPreferences.cache
88+
*.stTheme.cache
89+
90+
# workspace files are user-specific
91+
*.sublime-workspace
92+
93+
# project files should be checked into the repository, unless a significant
94+
# proportion of contributors will probably not be using SublimeText
95+
# *.sublime-project
96+
97+
# sftp configuration file
98+
sftp-config.json
99+
100+
101+
### Composer ###
102+
composer.phar
103+
vendor/
104+
105+
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
106+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
107+
# composer.lock
108+
109+
110+
### PhpStorm ###
111+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
112+
113+
*.iml
114+
115+
## Directory-based project format:
116+
.idea/
117+
# if you remove the above rule, at least ignore the following:
118+
119+
# User-specific stuff:
120+
# .idea/workspace.xml
121+
# .idea/tasks.xml
122+
# .idea/dictionaries
123+
124+
# Sensitive or high-churn files:
125+
# .idea/dataSources.ids
126+
# .idea/dataSources.xml
127+
# .idea/sqlDataSources.xml
128+
# .idea/dynamic.xml
129+
# .idea/uiDesigner.xml
130+
131+
# Gradle:
132+
# .idea/gradle.xml
133+
# .idea/libraries
134+
135+
# Mongo Explorer plugin:
136+
# .idea/mongoSettings.xml
137+
138+
## File-based project format:
139+
*.ipr
140+
*.iws
141+
142+
## Plugin-specific files:
143+
144+
# IntelliJ
145+
/out/
146+
147+
# mpeltonen/sbt-idea plugin
148+
.idea_modules/
149+
150+
# JIRA plugin
151+
atlassian-ide-plugin.xml
152+
153+
# Crashlytics plugin (for Android Studio and IntelliJ)
154+
com_crashlytics_export_strings.xml
155+
crashlytics.properties
156+
crashlytics-build.properties
157+
158+
159+
### Vagrant ###
160+
.vagrant/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
// SimpleSAMLphp configuration
4+
# Provide universal absolute path to the installation.
5+
if (isset($_ENV['AH_SITE_NAME']) && is_dir('/var/www/html/' . $_ENV['AH_SITE_NAME'] . '/vendor/simplesamlphp/simplesamlphp')) {
6+
$settings['simplesamlphp_dir'] = '/var/www/html/' . $_ENV['AH_SITE_NAME'] . '/vendor/simplesamlphp/simplesamlphp';
7+
}
8+
else {
9+
// Local SAML path.
10+
if (is_dir(DRUPAL_ROOT . '/../simplesamlphp')) {
11+
$settings['simplesamlphp_dir'] = DRUPAL_ROOT . '/../vendor/simplesamlphp/simplesamlphp';
12+
}
13+
}

settings/blt.settings.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
// Prevent APCu memory exhaustion.
5757
$settings['container_yamls'][] = __DIR__ . '/apcu_fix.yml';
5858

59+
// Include simplesamlphp settings if the file exists.
60+
if (file_exists(__DIR__ . '/simplesamlphp.settings.php')) {
61+
require __DIR__ . '/simplesamlphp.settings.php';
62+
}
63+
5964
/**
6065
* Salt for one-time login links, cancel links, form tokens, etc.
6166
*
@@ -75,7 +80,6 @@
7580
*/
7681
$settings['hash_salt'] = file_get_contents(DRUPAL_ROOT . '/../salt.txt');
7782

78-
7983
/*******************************************************************************
8084
* Environment-specific includes.
8185
******************************************************************************/

0 commit comments

Comments
 (0)