- Python 3
- Ruby 2.2.0 (for
govuk_template
) - PhantomJS (for UI testing)
- Dex (see Setting up Dex locally)
- PostgreSQL 9.4
-
Clone this repository and cd to the working directory
-
Install the requirements listed above if you don't have them already
-
mkvirtualenv --python=/path/to/python3 <appname>
-
pip install -r requirements.txt
-
python manage.py install_all_govuk_assets
-
createdb notes
-
python manage.py db upgrade
-
python manage.py runserver
To run all tests:
python manage.py test
To run only fast unit tests:
python manage.py test spec
To run only smoke tests:
python manage.py test smoke
To run only UI tests:
python manage.py test ui
To generate HTML coverage reports (in the htmlcov
directory)
python manage.py test coverage
The app looks for a SETTINGS
environment variable on start up. To retrieve
configuration values from AWS DynamoDB using credstash, set the SETTINGS
environment variable to AWS
. Otherwise, the default configuration is used,
which fetches values from the environment.
DEBUG
- (default: True) Run the app in debug mode, with exceptions triggering the online debugger
SECRET_KEY
- (default: randomly generated) The key used to encypt session cookies and possibly other encrypted data. The default changes on server restart, so sessions will be lost unless a constant value is used
DB_USERNAME
- (default: None) The username for the database
DB_PASSWORD
- (default: None) The password for the database
DB_HOST
- (default: `localhost`) The database hostname
DB_PORT
- (default: None) The database port number
OK, this is a little long-winded:
-
Find your Google ID number
-
Browse to Google's OAuth 2 playground
-
Click on
Exchange authorization code for tokens
-
Paste
https://www.googleapis.com/oauth2/v2/userinfo
into theRequest URI
field andSend the request
-
Make a note of the
id
field in the JSON data at the bottom of the right hand side of the page -
Get a Google client id and client secret
-
If you do not already have one, create a Google APIs project
-
Go to
Credentials > OAuth consent screen
-
Add a
Product name
-
Select
Create Credentials > OAuth client ID
-
Select
Web application
, enterhttp://127.0.0.1:5556/auth/google/callback
intoAuthorized redirect URIs
-
Make a note of the
Client ID
andClient secret
values near the top of the page -
Click
Save
-
Build Dex
-
Run
sh GOPATH="$(pwd)/go" mkdir -p go/src/github.com/coreos cd go/src/github.com/coreos git clone https://github.com/coreos/dex cd dex
-
Paste the following into
static/fixtures/client.json
:json [ { "id": "notes-app", "secret": "c2VjcmV0ZQ==", "redirectURLs": ["http://localhost:5000/callback"] } ]
-
Paste the following into
static/fixtures/emailer.json
:json { "type": "fake" }
-
Paste the following into
static/fixtures/users.json
, replacingYOUR_ID
with your Google ID number as found in step 1, and YOUR_EMAIL and YOUR_NAME with your email address and name, respectivelyjson [ { "id": "YOUR_ID", "email": "[email protected]", "displayName": "YOUR_NAME", "password": "password", "remoteIdentities": [ { "connectorId": "google", "id": "YOUR_ID" } ] } ]
-
Paste the following into
static/fixtures/connectors.json
, replacing CLIENT_ID and CLIENT_SECRET with the Client ID and Client secret you obtained in step 2json [ { "type": "oidc", "id": "google", "issuerURL": "https://accounts.google.com", "clientID": "CLIENT_ID", "clientSecret": "CLIENT_SECRET" } ]
-
Run
bin/dex-worker --no-db --enable-registration
-
Set up the app as per README instructions, but set the following environment variables before you run it:
export DEX_APP_CLIENT_ID="notes-app" export DEX_APP_CLIENT_SECRET="c2VjcmV0ZQ==" export DEX_APP_DISCOVERY_URL="http://127.0.0.1:5556" python manage.py runserver
-
Browse to [http://localhost:5000/notes](notes page)
-
Be redirected to Dex's login page and click on
Log in with Google
-
(Maybe) be redirected to Google's login page - sign in
-
Be redirected to the notes app list page, and see your name next to the
Sign out
link near the top of the page