DyCons server configuration and deployment
All DyCons software is archived and deprecated, left for reference only.
See dycons/design for additional context on this repository.
Services diagram describing the current milestone for the DyCons stack and core workflows (called demo1).
Setup expects the following repos to be available on the development/test machine:
To set these up at the paths specified in this repo's .env file, you could run the following snippet from the compose root folder:
git clone https://github.com/dycons/participant-portal.git ../participant-portal && \
git clone https://github.com/dycons/researcher-portal.git ../researcher-portal && \
git clone https://github.com/CSCfi/rems.git ../rems && \
git clone https://github.com/dycons/consents.git ../consents && \
git clone https://github.com/dycons/relay.git ../relay && \
git clone https://github.com/CanDIG/candigv2_opa.git ../candigv2_opa
Services diagram describing the OPA-powered authorization of Katsu.
Sequence diagram describing the process of authorizing a researcher's request to Katsu via the DyCons researcher-portal.
Spin up these components as follows:
- Prepare environment: Ensure that you have a well-configured
.envfile in thecomposeroot. To use the default configuration, runcp .default.env .env - Start up Katsu and OPA:
- Follow the steps here to authenticate to the GitHub Container Registry. This is necessary for pulling the
katsuimage. - Run
docker-compose up katsu
- Follow the steps here to authenticate to the GitHub Container Registry. This is necessary for pulling the
- (Optional) Add Sample Katsu Data:
- To add sample data to Katsu, run:
docker exec -it -w /app/chord_metadata_service/scripts katsu python ingest.py
- To add sample data to Katsu, run:
- Add Authorization Rules to OPA: Run
./init/opa.sh
- Prepare environment: Ensure that you have a well-configured
.envfile in thecomposeroot. To use the default configuration, runcp .default.env .env - First make sure the keycloak service is running via
docker-compose up pp-keycloak - Add test Realm:
- Navigate to http://127.0.0.1:8080/auth/admin.
- Login using the username and password:
admin/admin - Add the test Realm by hovering over the "Master" label in the top left, and click "Add realm".
- Click "Select File" and choose the preconfigured realm at
../participant-portal/keycloak/realm-export.json. The name should be autofilled withdycons-participant-idp. - Click "Save" to finish.
- Add test User:
- Navigate to the "Users" menu via the navbar on the left
- Click "Add User" on the right side of the page
- Set the username to
varcharand click "Save". - On the next page, click the "Credentials" tab
- Enter
varcharin both password fields, toggleTemporaryoff, and click "Set Password"
- Testing - Now it's time to test our setup by using the bundled front end:
- Boot up the React frontend by running
docker-compose up pp-react - Start by going to http://127.0.0.1:3003/.
- Click on the "Login" button and you should be redirected to the Keycloak login screen.
- Access the account using
varchar/varchar. You'll be redirected back to the React frontend with the user's JWT token and email displayed. - ** For active development **
- Instead of step 1, run the following, which will log you into the application:
docker-compose run --rm --entrypoint sh --service-port pp-react - Run
yarn startto compile the app. - Continue development on your machine - changes will be mapped to the volume inside the container and reflected at http://127.0.0.1:3002
- Instead of step 1, run the following, which will log you into the application:
- Boot up the React frontend by running
- Prepare environment: Ensure that you have a well-configured
.envfile in thecomposeroot. To use the default configuration, runcp .default.env .env - Start up Researcher IdP:
- Run
docker-compose up rp-keycloak.
- Run
- Prepare Keycloak:
- To prepare the keycloak for use with rems, run:
. ./init/rp-keycloak.sh- This will add two test users
- username:
applicant, password:applicant - username:
owner, password:owner
- username:
- This will export the following environment variables to your shell, for use in authorization. Skip sourcing the script if this is not desired.
- REMS_CLIENT_SECRET
- OWNER_ID
- APPLICANT_ID
- This will add two test users
- To prepare the keycloak for use with rems, run:
- Start up Katsu and OPA:
- Follow the steps here to authenticate to the GitHub Container Registry.
- Run
docker-compose up katsu
- Add Sample Katsu Data:
- To add sample data to Katsu, run:
docker exec -it -w /app/chord_metadata_service/scripts katsu python ingest.py
- To add sample data to Katsu, run:
- Add Authorization Rules and Data to OPA:
- To add authorization policies and data to OPA, run
./init/opa.sh- Note that the only datasets that will be affected by these policies are those listed in the
data.jsonfile ingested in this initialization. Currently only the following dataset titles are authorized on:
https://ega-archive.org/datasets/710 https://ega-archive.org/datasets/712 urn:nbn:fi:lb-201403262- As a result, if you are using the
rems-permissions-test.postman_collection.jsonPostman Collection for testing, the value of theresource-titleenvironment variable must be one of the above datasets.
- Note that the only datasets that will be affected by these policies are those listed in the
- To add authorization policies and data to OPA, run
- Migrate and seed REMS:
- To prepare the database and migrate the required tables, run
./init/migrate.sh rems - (Optional) To populate REMS with test data, run
docker-compose run --rm -e CMD="test-data" rems - REMS should now be ready for use. Run
docker-compose up rems
- To prepare the database and migrate the required tables, run
- Log In to REMS:
- Navigate to http://127.0.0.1:3001
- Click "Login".
- Login using the username and password:
owner/owner - In the top right, click "Sign out".
- REMS can be made aware of any other users via either the
/users/createendpoint, or by logging in as that user. To logout of REMS via therp-keycloak, as the keycloakadmin, navigate toSessions>Logout Allvia the navbar on the left.
- Using the REMS API:
You can test the REMS API by submitting requests through the instance's Swagger UI, or by running requests from one of the Postman Collections. For the latter option, testing the API outside of the browser will require you to include some authorization information in the request headers.
- Prepare credentials: Provide REMS with an API key and grant your user the
ownerrole by running./init/authorize.sh [options] USERID- By default, the API key set by this script is
abc123, matching the API key in the Postman collection, but you can optionally set a custom key. - The USERID is output by the
init/rp-keycloak.shscript used to prepare keycloak. If you sourced the script, you can use the$OWNER_IDand$APPLICANT_IDenvironment variables in your shell.
- By default, the API key set by this script is
- Make sure your user is known to REMS. This can be accomplished by logging in through the browser or by sending a request to the
/api/users/createendpoint. Theuseridmust match the user's id in Keycloak. - Add headers to your requests containing the following key-value pairs:
x-rems-api-key: The API key to use for authorizing your call. Must be known to REMS.x-rems-user-id: The ID of your user in REMS, as set by Keycloak (ex.$OWNER_ID)
- Configure any environment variables required by other services being used alongside REMS (see #6 above).
- Prepare credentials: Provide REMS with an API key and grant your user the
- Using the Researcher-Portal frontend - Now it's time to test our setup by using the bundled front end:
- Boot up the React frontend by running
docker-compose up rp-react - Start by going to http://127.0.0.1:3004/.
- Click on the "Log In" button and you should be redirected to the Keycloak login screen.
- Access the account using
applicant/applicant. You'll be redirected back to the React frontend. - ** For active development **
- Instead of step 1, run the following, which will log you into the application:
docker-compose run --rm --entrypoint sh --service-port rp-react - Run
npm startto compile the app. - Continue development on your machine - changes will be mapped to the volume inside the container and reflected at http://127.0.0.1:3004/.
- Instead of step 1, run the following, which will log you into the application:
- Boot up the React frontend by running
To push new entitlements to the Consents service, uncomment the following rems environment variable in docker-compose.yaml prior to running the REMS container:
ENTITLEMENTS_TARGET__ADD: "http://consents:3005/v0/rems/add_entitlements"
- Prepare environment: Ensure that you have a well-configured
.envfile in thecomposeroot. To use the default configuration, runcp .default.env .env - Run the Consents service with
docker-compose up consents - Migrate the Consents service with
./init/migrate.sh consents - (Optional) Test the Consents service by running requests from the Postman collection and test data.
- Prepare environment: Ensure that you have a well-configured
.envfile in thecomposeroot. To use the default configuration, runcp .default.env .env - Run the Relay sevrice with
docker-compose up relay - (Optional) Test the Relay service by running the Postman collection at
../relay/tests/key-relay-service.postman_collection.json