Both the ESAP-API (backend) and ESAP-GUI (frontend) projects are created in a way that allows running code locally in webservers that are provided by the frameworks that they are developed with.
For the Django backend this a built-in webserver:
https://docs.djangoproject.com/en/3.2/ref/django-admin/#runserver
This will default serve the backend at: http://localhost:8000 (however, we run the ESAP backend on port localhost:5555)
For the ReactJS frontend it is the node
webserver that comes with the 'Create React App' environment that was used to setup the project: https://reactjs.org/docs/create-a-new-react-app.html#create-react-app
This will default serve the frontend at: localhost:3000
Prerequisites
- python 3.7 or higher
- venv
- git
- pip
- npm
The Procedure
ESAP API Gateway (backend)
git clone https://git.astron.nl/astron-sdc/esap-api-gateway.git
cd esap-api-gateway
python3 -m venv env
source env/bin/activate
cd esap
pip install -r requirements/dev.txt
Migrating the databases
Before running, the databases need to be created.
python manage.py migrate accounts --database=accounts --settings=esap.settings.dev --no-input
python manage.py migrate rucio --database=rucio --settings=esap.settings.dev --no-input
python manage.py migrate ida --database=ida --settings=esap.settings.dev --no-input
python manage.py migrate batch --database=batch --settings=esap.settings.dev --no-input
python manage.py migrate uws --database=uws --settings=esap.settings.dev --no-input
python manage.py migrate --settings=esap.settings.dev # the default database
Loading data
If you want to use the development test data, you can load the provided YAML files.
python manage.py loaddata --database=ida --settings=esap.settings.dev esap/esap_ida_config.yaml
python manage.py loaddata --database=batch --settings=esap.settings.dev esap/esap_batch_config.yaml
python manage.py loaddata --database=default --settings=esap.settings.dev esap/esap_config.yaml
Registering at IAM
A development ESAP client is already registered as a service at IAM for the 'localhost' redirect url. If you want to use that client registration, then ask us for the OIDC_RP_CLIENT_ID
and OIDC_RP_CLIENT_SECRET
But you can also choose to register your own ESAP client and then get your own OIDC_RP_CLIENT_ID
and OIDC_RP_CLIENT_SECRET
. See Register at IAM for that procedure.
Fill in OIDC settings
The OIDC_RP_CLIENT_ID
and OIDC_RP_CLIENT_SECRET
settings from the previous step should be filled in where it now says ''.
You could add the following environment variables and django 'runserver' command into a script like runs.sh
to start the backend. note: Linux users might require to prefix each environment variable with export
.
OIDC_RP_CLIENT_ID=<secret>
OIDC_RP_CLIENT_SECRET=<secret>
OIDC_OP_JWKS_ENDPOINT=https://iam-escape.cloud.cnaf.infn.it/jwk
OIDC_OP_AUTHORIZATION_ENDPOINT=https://iam-escape.cloud.cnaf.infn.it/authorize
OIDC_OP_TOKEN_ENDPOINT=https://iam-escape.cloud.cnaf.infn.it/token
OIDC_OP_USER_ENDPOINT=https://iam-escape.cloud.cnaf.infn.it/userinfo
LOGIN_REDIRECT_URL=http://localhost:3000/esap-gui/login
LOGOUT_REDIRECT_URL=http://localhost:3000/esap-gui/logout
LOGIN_REDIRECT_URL_FAILURE=http://localhost:3000/esap-gui/error
RUCIO_HOST=https://escape-rucio.cern.ch
RUCIO_AUTH_HOST=https://escape-rucio-auth.cern.ch/
python manage.py runserver 5555 --settings=esap.settings.dev
ESAP-GUI (frontend)
git clone https://git.astron.nl/astron-sdc/esap-gui.git
cd esap-gui
npm install
npm run start