Skip to content

Instantly share code, notes, and snippets.

@floehopper
Last active February 28, 2018 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save floehopper/afc493fc544d4770e6478ffb42ee23b7 to your computer and use it in GitHub Desktop.
Save floehopper/afc493fc544d4770e6478ffb42ee23b7 to your computer and use it in GitHub Desktop.
Setup GOV.UK development VM with local SSO, Whitehall & its draft stack

Data replication

The idea here is to load the routes for the router and draft-router. Life's too short to work out how to create the routes manually!

  • cd /var/govuk/govuk-puppet/development-vm/replication
  • Apply replicate-data-local.diff patch to skip all dbs on mongo-1.backend & api-mongo-1.api
  • Run the following command to import data for router & draft-router: ./replicate-data-local.sh -s -d backups/YYYY-MM-DD -p -q -e -t -i 'collections_publisher contacts release search_admin tariff_admin tariff_temporal'

Authenticating proxy

  • bin/rails db:create
  • bin/rails db:schema:load
  • sudo su -c 'echo -n oauth-authenticating-proxy > /etc/govuk/authenticating-proxy/env.d/OAUTH_ID'
  • sudo su -c 'echo -n secret > /etc/govuk/authenticating-proxy/env.d/OAUTH_SECRET'
  • sudo su -c 'echo -n http://draft-router.dev.gov.uk > /etc/govuk/authenticating-proxy/env.d/GOVUK_UPSTREAM_URI'
  • sudo su -c 'echo -n http://signon.dev.gov.uk > /etc/govuk/authenticating-proxy/env.d/PLEK_SERVICE_SIGNON_URI'

Signon

Create empty database

  • bin/rails db:create
  • bin/rails db:schema:load

Create application

  • bundle exec rake applications:create name="whitehall" home_uri="http://whitehall-admin.dev.gov.uk" redirect_uri="http://whitehall-admin.dev.gov.uk/auth/gds/callback"
  • bundle exec rake applications:create name=authenticating-proxy description="authenticating proxy" home_uri="http://authenticating-proxy.dev.gov.uk" redirect_uri="http://authenticating-proxy.dev.gov.uk/auth/gds/callback"
  • Copy OAuth credentials from app env vars to Signon database: bundle exec script/make_oauth_work_in_dev

Create user

  • bundle exec rake users:create name="$USER_NAME$" email="$USER_EMAIL$" applications="whitehall,authenticating-proxy"
  • Capture "URL to set password" from stdout
  • Start signon app using bowl signon
  • Visit "URL to set password" captured above

Ref: https://github.com/alphagov/signon/blob/master/doc/usage.md

Whitehall

  • bin/rails db:create

  • bin/rails db:schema:load

  • Create an API user for Whitehall in Signon

    • Follow these instructions
    • Create an access token for Asset Manager
    • Copy this access token to Whitehall env var:
      • sudo su -c 'echo -n $ACCESS_TOKEN_FROM_SIGNON > /etc/govuk/whitehall/env.d/ASSET_MANAGER_BEARER_TOKEN'

Publishing API

  • bin/rails db:create
  • bin/rails db:schema:load

Rummager

  • RUMMAGER_INDEX=all bundle exec rake rummager:create_all_indices

Running Whitehall with draft stack & real SSO

  • GDS_SSO_STRATEGY=real bowl whitehall signon authenticating-proxy draft-government-frontend draft-router
  • The Whitehall app and its dependencies need to be running so that content generated by the following commands is saved/published in the Content Store via the Publishing API
  • govuk_app_console whitehall
    • Government.create!(name: 'Government of the Lizard People', slug: 'government-of-the-lizard-people', start_date: Date.parse('2010-01-01'))
    • Organisation.create!(organisation_type: OrganisationType.ministerial_department, slug: 'dummy-organisation', name: 'Dummy Organisation', logo_formatted_name: 'dummy-organisation', alternative_format_contact_email: 'dummy-organisation@example.com')
    • Topic.create!(name: 'Dummy Policy Area for Testing', description: 'Dummy Policy Area for Testing - Description') # also possible via UI
  • Sign-in to Whitehall app - this will create a user in Whitehall based on data from Signon
diff --git a/development-vm/replication/replicate-data-local.sh b/development-vm/replication/replicate-data-local.sh
index c16008b..57ec808 100755
--- a/development-vm/replication/replicate-data-local.sh
+++ b/development-vm/replication/replicate-data-local.sh
@@ -11,10 +11,10 @@ status "Running bundle install"
bundle install --quiet
$(dirname $0)/sync-mysql.sh "$@" mysql-backup-1.backend.integration
$(dirname $0)/sync-mysql.sh "$@" whitehall-mysql-backup-1.backend.integration
-$(dirname $0)/sync-mongo.sh "$@" mongo-1.backend.integration
-$(dirname $0)/sync-mongo.sh "$@" api-mongo-1.api.integration
+#$(dirname $0)/sync-mongo.sh "$@" mongo-1.backend.integration
+#$(dirname $0)/sync-mongo.sh "$@" api-mongo-1.api.integration
$(dirname $0)/sync-mongo.sh "$@" router-backend-1.router.integration
if ! ($SKIP_MONGO || $DRY_RUN); then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment