Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

uktrade/great-domestic-ui

Repository files navigation

great-domestic-ui

code-climate-image circle-ci-image codecov-image gitflow-image calver-image

GREAT.gov.uk, Domestic UI for GREAT platform - the Department for International Trade (DIT)


Development

Installing

$ git clone https://github.com/uktrade/great-domestic-ui
$ cd great-domestic-ui
$ [create and activate virtual environment]
$ make install_requirements

Requirements

Python 3.6

Redis

Configuration

Secrets such as API keys and environment specific configurations are placed in conf/env/secrets-do-not-commit - a file that is not added to version control. To create a template secrets file with dummy values run make secrets.

Commands

Command Description
make clean Delete pyc files
make pytest Run all tests
make pytest test_foo.py Run all tests in file called test_foo.py
make pytest -- --last-failed` Run the last tests to fail
make pytest -- -k foo Run the test called foo
make pytest -- Run arbitrary pytest command
make flake8 Run linting
make manage Run arbitrary management command
make webserver Run the development web server
make requirements Compile the requirements file
make install_requirements Installed the compile requirements file
make css Compile scss to css
make secrets Create your secret env var file
redirect Add a new redirect

CSS development

We use SASS CSS pre-compiler. If you're doing front-end work your local machine will also need the following dependencies:

node SASS

Then run:

$ npm install yarn
$ yarn install --production=false

We add compiled CSS files to version control. This will sometimes result in conflicts if multiple developers are working on the same SASS files. However, by adding the compiled CSS to version control we avoid having to install node, npm, node-sass, etc to non-development machines.

You should not edit CSS files directly, instead edit their SCSS counterparts.

Geolocation data

Maxmind geolite2 is used to determine the country the user is from via their IP address. The geolocation dataset must be updated to stay fresh. To update the geolocation data run:

make manage download_geolocation_data

Session

Signed cookies are used as the session backend to avoid using a database. We therefore must avoid storing non-trivial data in the session, because the browser will be exposed to the data.

SSO

To make sso work locally add the following to your machine's /etc/hosts:

IP Adress URL
127.0.0.1 buyer.trade.great
127.0.0.1 supplier.trade.great
127.0.0.1 sso.trade.great
127.0.0.1 api.trade.great
127.0.0.1 profile.trade.great
127.0.0.1 exred.trade.great
127.0.0.1 cms.trade.great

Then log into directory-sso via sso.trade.great:8001, and use great-domestic-ui on exred.trade.great:8001

Note in production, the directory-sso session cookie is shared with all subdomains that are on the same parent domain as directory-sso. However in development we cannot share cookies between subdomains using localhost - that would be like trying to set a cookie for .com, which is not supported by any RFC.

Therefore to make cookie sharing work in development we need the apps to be running on subdomains. Some stipulations:

  • great-domestic-ui and directory-sso must both be running on sibling subdomains (with same parent domain)
  • directory-sso must be told to target cookies at the parent domain.

Helpful links

Related projects:

https://github.com/uktrade?q=directory https://github.com/uktrade?q=great