Skip to content

Latest commit

 

History

History
133 lines (96 loc) · 3.28 KB

File metadata and controls

133 lines (96 loc) · 3.28 KB

Developing the UMich OIDC Login plugin

How to set up a local development environment to run and modify the plugin.

The development environment is set up at https://wp.local/

Unless specified, all commands below should be run from the top-level directory of the plugin source code repository.

Requirements

  • git
  • bash
  • Docker and Docker Compose
  • mkcert (see below)

Create TLS/SSL certificate

Although it should be possible to use HTTP in most cases, we do the extra work for HTTPS in order to avoid special cases with third party systems and OIDC Identity Providers.

If you are using a Mac with Homebrew, install mkcert by running

brew install mkcert nss

Otherwise, refer to the mkcert documentation for how to install mkcert on your platform.

mkdir scratch/certs
pushd scratch/certs
mkcert -cert-file wp.local.crt -key-file wp.local.key wp.local
mkcert -install
popd

Add wp.local to your hosts file so the name can be used in URLs:

echo "127.0.0.1 wp.local" | sudo tee -a /etc/hosts

Install WordPress

echo "DB_NAME='wordpress'" > .env
echo "DB_ROOT_PASSWORD='$(openssl rand -base64 24 | cut -c 1-32)'" >> .env
docker-compose up

run-wp core install \
    --url=https://wp.local \
    --title="Local WordPress Test" \
    --skip-email \
    --admin_user=admin \
    --admin_email="YOU@example.com"  # replace with your email address

COPY AND SAVE THE ADMIN PASSWORD from the output of the wp core install command above, you will need to use it often.

Turn on debug logging.

run-wp config set WP_DEBUG true --raw
run-wp config set WP_DEBUG_DISPLAY true --raw
run-wp config set SCRIPT_DEBUG true --raw
run-wp config set WP_DEBUG_LOG /tmp/wp-debug.log

Other configuration:

run-wp rewrite structure '/%postname%/'
run-wp plugin delete akismet hello
run-wp plugin install wp-native-php-sessions --activate

UMICH OIDC Login plugin

BUILD THE PLUGIN BY FOLLOWING THE INSTRUCTIONS IN docs/building.md.

Then,

run-wp plugin activate umich-oidc-login

Watch for errors using

tail -f scratch/logs/wordpress/wp-debug.log

Other tasks

Check for errors, warning and coding style issues

check-code

If you get the following error

Error while loading rules from rules directory - ENOENT: no such file or directory, scandir '/home/node/app/node_modules/npm-package-json-lint/src/rules'

then run

pushd node_modules/npm-package-json-lint/src
cp -a rules rules-dir
sed -i -e "s/'rules'/'rules-dir'/" Rules.js
popd

Develop the plugin settings page

This currently uses NodeJS 14.x installed on the local system, not from a Docker image.

TOP=$(pwd)
cd umich-oidc-login/includes/admin/wp-react-optionskit
# --hot=true must be last command line option
npx wp-scripts start --host=wp.local --server-type=https \
    --server-options-cert="${TOP}/scratch/certs/wp.local.crt" \
    --server-options-key="${TOP}/scratch/certs/wp.local.key" \
    --live-reload --hot=true

Clean up and start over

Delete the WordPress database and all WordPress files.

docker-compose down --volumes  # deletes the DB data volume
rm -rf scratch/wordpress scratch/composer-php* scratch/logs