# Deployment (Jenkins / composer-based) This project was historically deployed by `git pull` on the server. Because of that, several customizations were hand-edited **inside `vendor/`** or **inside `web/modules/contrib/`** — both of which are managed by Composer and get wiped by a clean `composer install`/`composer update`. This document describes how those customizations are now made reproducible so the site can be built from source by a CI pipeline. ## Environments `local` (ddev) · `dev` · `uat` · `prd` Each has its own SimpleSAMLphp config under `simplesaml-config//`. --- ## Use `composer install`, NOT `composer update` `composer.lock` **is now committed** (it used to be git-ignored — that was the root cause of "module versions are not fixed"). Deploys must run: ```bash composer install --no-dev --optimize-autoloader ``` - `composer install` installs the **exact** versions pinned in `composer.lock` → reproducible, identical on every environment. - `composer update` re-resolves to the newest versions allowed by the `^`/`@beta` constraints and rewrites the lock → uncontrolled drift. Do this **only** deliberately in development, test it, then commit the updated `composer.lock`. > Updating a dependency is a dev-time action (`composer update ` → test → > commit `composer.lock`). The pipeline only ever runs `composer install`. ### Platform note — the server has NO native `ext-sodium` `composer.json` declares: ```json "config": { "platform": { "ext-sodium": "1.0.18" } } ``` and requires `paragonie/sodium_compat` (a pure-PHP libsodium polyfill). Both are **required** because the servers do not have the native sodium PHP extension (used by `real_aes` / `encrypt`). Do not remove either. The `platform` setting lets `composer install` succeed on a host without `ext-sodium`. --- ## Customizations and how they survive a clean build ### 1. `drupal/simple_pass_reset` — composer patch The SSO `ReturnTo` integration (depends on the custom `drupalauth4ssp` module) lives in `patches/simple_pass_reset-drupalauth4ssp-returnto.patch` and is applied automatically by `cweagans/composer-patches` (see `extra.patches`). `drupal/simple_pass_reset` is **pinned to `1.2.0`** — the patch is generated against that exact version. `composer-exit-on-patch-failure` is `true`, so if the module is ever bumped and the patch no longer applies, the build **fails loudly** instead of silently shipping un-patched code. ### 2. SimpleSAMLphp `drupalauth` module — repo-managed + post-install sync The `drupalauth/simplesamlphp-module-drupalauth` module is **not** a tracked Composer dependency (it targets a dev branch of SimpleSAMLphp and is effectively vendored). It is kept under `simplesaml-modules/drupalauth/` and copied into `vendor/simplesamlphp/simplesamlphp/modules/` by `scripts/composer/simplesaml-sync.php`, which runs automatically via composer `post-install-cmd` / `post-update-cmd`. If you ever run composer with `--no-scripts`, run the sync manually afterwards: ```bash composer run-script simplesaml-sync ``` ### 3. SimpleSAMLphp config / metadata / certs — relocated out of vendor Per-environment config now lives in `simplesaml-config//` (was inside `vendor/`). SimpleSAMLphp is pointed at the right one **at runtime** via the `SIMPLESAMLPHP_CONFIG_DIR` environment variable set in the web-server vhost: | Env | `SIMPLESAMLPHP_CONFIG_DIR` | |-------|------------------------------------------------| | local | `/simplesaml-config/local/config` | | dev | `/simplesaml-config/dev/config` | | uat | `/simplesaml-config/uat/config` | | prd | `/simplesaml-config/prd/config` | > **Server action required:** update each environment's Apache/Nginx vhost to set > `SIMPLESAMLPHP_CONFIG_DIR` to the path above (previously it pointed inside > `vendor/`). The SimpleSAMLphp web UI alias still points at > `vendor/simplesamlphp/simplesamlphp/public` (composer-managed) — unchanged. > For ddev this is already done in `.ddev/apache/apache-site.conf`. --- ## Pipeline order (reference) ```bash git checkout composer install --no-dev --optimize-autoloader # patches + simplesaml-sync run automatically export SIMPLESAMLPHP_CONFIG_DIR=/simplesaml-config/$ENV/config drush sql:dump --result-file=../backup-pre-deploy.sql --gzip # rollback point drush state:set system.maintenance_mode 1 -y drush updatedb -y drush cache:rebuild drush state:set system.maintenance_mode 0 -y ``` (There is no `drush config:import` step — this site does not use config-in-code; configuration lives in the database.) --- ## ⚠️ Secrets to rotate (currently committed and shared across all envs) The SimpleSAMLphp configs contain real secrets that are identical across dev/uat/ prd, including production: - `secretsalt` - `auth.adminpassword` (also weak) - server certs/keys under `simplesaml-config//cert/` When moving to Jenkins, rotate these and inject them per-environment via Jenkins credentials instead of committing them.