arrow-left

All pages
gitbookPowered by GitBook
1 of 8

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Configuration

This set of pages provide configuration instructions for MedCo. Note that all of them are not necessarily always needed, follow one of the deployment instructions to know which ones are.

Local Test Deployment

Deployment of profile test-local-3nodes.

triangle-exclamation

This deployment profile comes with default pre-generated keys and default passwords. It is not meant to contain any real data nor be used in production. If you wish to do so, use instead the Network Production Deployment (prod-network) deployment profile.

This test profile deploys 3 MedCo nodes on a single machine for test purposes. It can be used either on your local machine, or any other machine to which you have access. The version of the docker images used are the latest released versions. This profile is for example used for the MedCo public demoarrow-up-right.

hashtag
MedCo Stack Deployment

First step is to get the MedCo Deployment latest release and download the docker images. Adapt ${MEDCO_SETUP_DIR} to where you wish to install MedCo.

The default configuration of the deployment is suitable if the stack is deployed on your local host, and if you do not need to modify the default passwords. If so, edit the file ${MEDCO_SETUP_DIR}/compose-profiles/test-local-3nodes/.env to reflect your configuration. For example:

MEDCO_NODE_HOST should be the fully qualified domain name of the host, MEDCO_NODE_HTTP_SCHEME should be http or https. The other fields control the default passwords for the various services running. Note that setting the passwords that way works only on the first deployment. If the passwords need to be updated later, you should use the specific component way of modifying password.

circle-exclamation

If you enable HTTPS, follow to set up the needed certificates.

Final step is to run the nodes, all three will run simultaneously:

Wait some time for the initialization of the containers to be done (up to the message: “i2b2-medco-srv… - Started x of y services (z services are lazy, passive or on-demand)”), this can take up to 10 minutes. For the subsequent runs, the startup will be faster. In order to stop the containers, hit Ctrl+C in the active window.

circle-info

You can use the command docker-compose up -d instead to run MedCo in the background and thus not keeping the console captive. In that case use docker-compose stop to stop the containers.

hashtag
Keycloak Configuration

circle-exclamation

Only needed if you are deploying somewhere else than your local host. Otherwise the default configuration will work fine.

Follow the instructions for to be able to login in Glowing Bear.

hashtag
Test the deployment

In order to test that the local test deployment of MedCo is working, access Glowing Bear in your web browser at http(s)://${MEDCO_NODE_HOST} and use the default credentials specified in . If you are new to Glowing Bear you can watch the video. You can also use the to perform tests.

By default MedCo loads a specific test data, refer to for expected results to queries. To load a dataset, follow the guide .

Deployment

These pages explain how to deploy MedCo in different scenarios.

Each deployment scenario corresponds to a deployment profile, as described below. All these instructions use the deployment scripts from the medco-deploymentarrow-up-right repository.

If you are new to MedCo…

… and want to try to deploy the system on a single machine to test it, you should should follow the Local Test Deployment guide.

… and want to create or join a MedCo network for test purposes, you should follow the Network Test Deployment guide.

… and want to create or join a MedCo network in production, you should follow the Network Production Deployment guide.

… and want to develop around MedCo, you should follow the guide.

hashtag
Deployment Profiles

A deployment profile is composed of two things:

  • a compose profile in medco-deployment/compose-profiles/<profile name>/: docker-compose file and parameters like ports to expose, log level, etc.

  • a configuration profile in medco-deployment/configuration-profiles/<profile name>/: files mounted in the docker containers, containing the cryptographic keys, the certificates, etc.

Some profiles are provided by default, for development or testing purposes. Those should not be used in a production scenario with real data, as the private keys are set by default, thus not private. Other types of profiles must generated using the scripts in medco-deployment/resources/profile-generation-scripts/<profile name>/.

The different profiles are the following:

hashtag
test-local-3nodes ()

  • for test on a single machine (used by the MedCo live demo)

  • 3 nodes on any host

  • using the latest release of the source codes

hashtag
test-network ()

  • for test on several different hosts

  • a single node on a host part of a MedCo network

  • using the latest release of the source codes

hashtag
prod-network ()

  • for a deployment in production

  • a single node on a host part of a MedCo network

  • using the latest release of the source codes

hashtag
dev-local-3nodes ()

  • for software development

  • 3 nodes on the local host

  • using development version of source codes

circle-info

The database is pre-loaded with some encrypted test data using a key that is pre-generated from the combination of all the participating nodes’ public keys. For the test-network and prod-network deployment profiles this data will not be correctly encrypted, since the public key of each node is generated independently, and, as such, the data must be re-loaded.

Keycloak

Here follows some MedCo-specific instructions for the administration of Keycloak. For anything else, please refer to the Keycloak Server Administration Guidearrow-up-right. Those instructions do not necessarily need to be all followed for all deployments, refer to the deployment guide to know which ones are important.

triangle-exclamation

For a production deployment, it is crucial to change the default keys and credentials.

hashtag
Accessing the web administration interface

You can access the Keycloak administration interface at http(s)://<node domain name>/auth/admin. For example if MedCo is deployed on your local host, you can access it at http://localhost/auth/admin. Use the admin default credentials if you had just deployed MedCo.

hashtag
User Management

hashtag
Default users

The default configuration shipped with the MedCo deployments come with two users.

hashtag
Admin user

The default admin credentials has all the admin access to Keycloak, but no access rights to MedCo. Its credentials are :

  • User keycloak

  • Password keycloak (unless configured otherwise through the .env file)

hashtag
Test user

The default MedCo user has all the authorizations to run all types of MedCo query. It is this user you should use to log in MedCo. Its credentials are:

  • User test

  • Password test

hashtag
Add a user

  • Go to the configuration panel Users, click on Add user.

  • Fill the Username field, toggle to ON the Email Verified button and click Save.

hashtag
Give query permissions to a user

  • Go to the configuration panel Users, search for the user you want to give authorization to and click on Edit.

  • Go to the Role Mappings tab, and select medco (or another client ID set up for the MedCo OIDC client) in the Client Roles.

  • Add the roles you wish to give the user, each of the roles maps to a query type.

hashtag
MedCo Default Settings

hashtag
medco OpenID Connect client

The default Keycloak configuration provides an example of a fully working configuration for deployments on your local host. In other cases, you will need to modify this configuration.

Access the configuration panel of the MedCo client by going to the Clients tab, and click on the medco client. Then, in the Settings tab, fill Valid Redirect URIs to reflect the following table (you can delete the existing entries):

In the same tab, fill Web Origins with + and save.

hashtag
Securing a production deployment

hashtag
Changing default passwords

Both keycloak and test users comes with default passwords. For a production deployment they need to be changed:

  • Go to the configuration panel Users, click on View all users.

  • For each of the users you want to change the password of:

    • Click on Edit, then go the Credentials tab.

hashtag
Changing default realm keys

The example configuration comes with default keys. They have to be changed for a network deployment where there are several Keycloak instances.

  • Go to the configuration panel Realm Settings, then to the Keys tab and Providers subtab.

  • Click on Add keystore... and add the three following providers:

    • aes-generated

hashtag
Enabling brute force detection

  • Go to the configuration panel Realm Settings, then to the Security Defenses tab and Brute Force Detection subtab.

  • Toggle to ON the Enabled button.

  • Fill the following:

hashtag

Network Test Deployment

Deployment of profile test-network.

triangle-exclamation

This deployment profile comes with default pre-generated keys and default passwords. It is not meant to contain any real data nor be used in production. If you wish to do so, use instead the deployment profile.

This test profile deploys an arbitrary set of MedCo nodes independently in different machines that together form a MedCo network. This deployment assumes each node is deployed in a single dedicated machine. All the machines have to be reachable between each other. Nodes should agree on a network name and individual indexes beforehand (to be assigned a unique ID).

circle-exclamation
In the next window, click on
Credentials
, enter twice the user’s password, toggle to
OFF
the
Temporary
button if desired and click
Reset Password
.

Enter the new password of the user

  • Optionally toggle to OFF the Temporary button; if ON the user at the next login will need to update his password.

  • Click on Reset Password.

    • Console Display Name: aes-medco

    • Priority: 100

  • hmac-generated

    • Console Display Name: hmac-medco

    • Priority: 100

    • rsa-generated

      • Console Display Name: rsa-medco

      • Priority: 100

  • Finally, delete all the other key providers listed that you did not just add. They should be named xxx-generated. Note that it is normal if you get logged out during the operation, just log back in and continue the process.

  • Max Login Failures: 3

  • Wait Increment: 30 Seconds

  • Save the configuration.

  • Deployment Profile

    Valid Redirect URIs

    test-local-3nodes

    http(s)://<node domain name>/*

    test-network + prod-network

    https://<node domain name>/*

    dev-local-3nodes

    http://localhost:4200/*

    no debug logging
  • profile pre-generated

  • no debug logging
  • profile must be generated prior to use with the provided scripts

  • no debug logging
  • profile must be generated prior to use with the provided scripts

  • debug logging enabled
  • profile pre-generated

  • Local Development Deployment
    Local Test Deployment
    Network Test Deployment
    Network Production Deployment
    Local Development Deployment

    Network Production Deployment

    Deployment of profile prod-network.

    circle-info

    Coming in MedCo v1.0.0.

    HTTPS Configuration
    configuring the MedCo OpenID Connect client in Keycloak
    Keycloak user management
    Glowing Bear user interface walkthrougharrow-up-right
    CLI client
    Description of the default test data
    Loading Data

    The next set of steps must be fully executed individually by each node of the network.

    hashtag
    Pre-requisites

    First step is to get the MedCo Deployment latest release at each node. Adapt ${MEDCO_SETUP_DIR} to where you wish to install MedCo.

    hashtag
    Generation of the deployment Profile

    Next the compose and configuration profiles must be generated using a script, executed in two steps.

    • Step 1: each node generates its keys and certificates, and shares its public information with the other nodes

    • Step 2: each node collects the public keys and certificates of the all the other nodes

    hashtag
    Step 1

    For step 1, the network name ${MEDCO_SETUP_NETWORK_NAME} should be common to all the nodes. ${MEDCO_SETUP_NODE_DNS_NAME} corresponds to the machine domain name where the node is being deployed. As mentioned before the different parties should have agreed beforehand on the members of the network, and assigned an index ${MEDCO_SETUP_NODE_IDX} to each different node to construct its UID (starting from 0, to n-1, n being the total number of nodes).

    This script will generate the compose profile and part of the configuration profile, including a file srv${MEDCO_SETUP_NODE_IDX}-public.tar.gz. This file should be shared with the other nodes, and all of them need to place it in their configuration profile folder (${MEDCO_SETUP_DIR}/configuration-profiles/test-network-${MEDCO_SETUP_NETWORK_NAME}-node${MEDCO_SETUP_NODE_IDX}).

    hashtag
    Step 2

    circle-exclamation

    Before proceeding to this step, you need to have gathered all the files srv${MEDCO_SETUP_NODE_IDX}-public.tar.gz from the persons deploying MedCo on the other nodes.

    Once all nodes have shared their srv${MEDCO_SETUP_NODE_IDX}-public.tar.gz file with all other nodes, step 2 can be executed:

    At this point, it is possible to edit the default configuration generated in ${MEDCO_SETUP_DIR}/configuration-profiles/test-network-${MEDCO_SETUP_NETWORK_NAME}-node${MEDCO_SETUP_NODE_IDX}/.env This is needed if you want to modify the default passwords. When editing this file, be careful to change only the passwords and not the other values. Note that setting the passwords that way works only on the first deployment. If the passwords need to be updated later, you should use the specific component way of modifying password.

    The deployment profile is now ready to be used.

    hashtag
    MedCo Stack Deployment

    Next step is to download the docker images and run the node:

    Wait some time for the initialization of the containers to be done, this can take up to 10 minutes. For the subsequent runs, the startup will be faster. You can use docker-compose stop to stop the containers and docker-compose down to delete them.

    hashtag
    Keycloak Configuration

    You will need to follow two sets of instruction to make Keycloak functional and be able to log in. Access the Keycloak administration interface and then:

    • Update the MedCo OIDC client

    • Update the Keycloak realm keys

    hashtag
    Test the deployment

    circle-exclamation

    Note that by default the certificates generated by the script are self-signed and thus, when using Glowing Bear, the browser will issue a security warning. To use your own valid certificates, see HTTPS Configuration.

    circle-info

    The database is pre-loaded with some encrypted test data using a key that is pre-generated from the combination of all the participating nodes’ public keys. For the test-network deployment profile this data will not be correctly encrypted, since the public key of each node is generated independently, and, as such, the data must be re-loaded before being able to test the system successfully.

    Run first the MedCo loader (see Loading Data) to load some data and be able to test this deployment. Then access Glowing Bear in your web browser at https://${MEDCO_SETUP_NODE_DNS_NAME} and use the default credentials specified in Keycloak user management. If you are new to Glowing Bear you can watch the Glowing Bear user interface walkthrougharrow-up-right video. You can also use the CLI client to perform tests.

    Network Production Deployment (prod-network)
    export MEDCO_SETUP_DIR=~/medco-deployment MEDCO_SETUP_VER=0.3.1
    wget https://github.com/ldsec/medco-deployment/archive/v${MEDCO_SETUP_VER}.tar.gz
    tar xvzf v${MEDCO_SETUP_VER}.tar.gz
    mv medco-deployment-${MEDCO_SETUP_VER} "${MEDCO_SETUP_DIR}"
    cd "${MEDCO_SETUP_DIR}/compose-profiles/test-local-3nodes"
    docker-compose -f docker-compose.yml -f docker-compose.tools.yml pull
    MEDCO_NODE_HOST=medco-demo.epfl.ch
    MEDCO_NODE_HTTP_SCHEME=https
    POSTGRES_PASSWORD=postgres_password
    PGADMIN_PASSWORD=pgadmin_password
    KEYCLOAK_PASSWORD=keycloak_password
    I2B2_WILDFLY_PASSWORD=i2b2_wildfly_password
    I2B2_SERVICE_PASSWORD=i2b2_service_password
    I2B2_USER_PASSWORD=i2b2_user_password
    cd "${MEDCO_SETUP_DIR}/compose-profiles/test-local-3nodes"
    docker-compose up
    export MEDCO_SETUP_DIR=~/medco-deployment MEDCO_SETUP_VER=0.3.1
    wget https://github.com/ldsec/medco-deployment/archive/v${MEDCO_SETUP_VER}.tar.gz
    tar xvzf v${MEDCO_SETUP_VER}.tar.gz
    mv medco-deployment-${MEDCO_SETUP_VER} "${MEDCO_SETUP_DIR}"
    export MEDCO_SETUP_NETWORK_NAME=example \
        MEDCO_SETUP_NODE_IDX=0 \
        MEDCO_SETUP_NODE_DNS_NAME=medconode0.example.com
    cd "${MEDCO_SETUP_DIR}/resources/profile-generation-scripts/test-network"
    bash step1.sh ${MEDCO_SETUP_NETWORK_NAME} ${MEDCO_SETUP_NODE_IDX} ${MEDCO_SETUP_NODE_DNS_NAME}
    cd "${MEDCO_SETUP_DIR}/resources/profile-generation-scripts/test-network"
    bash step2.sh ${MEDCO_SETUP_NETWORK_NAME} ${MEDCO_SETUP_NODE_IDX}
    cd "${MEDCO_SETUP_DIR}/compose-profiles/test-network-${MEDCO_SETUP_NETWORK_NAME}-node${MEDCO_SETUP_NODE_IDX}"
    docker-compose -f docker-compose.yml -f docker-compose.tools.yml pull
    docker-compose up -d

    Configuring SwitchAAI Authentication

    This guide walks you through the process of configuring Keycloak as a Service Provider to one or more SwitchAAI identity provider(s), in order for MedCo to rely on SwitchAAI for user authentication.

    hashtag
    Prerequisites

    • A MedCo network is up and running, with one or more functional Keycloak within the network.

    • One or several identity provider(s) part of the SwitchAAI federation is/are chosen to be used as user source.

    • The institution at which the Keycloak of MedCo is deployed is ready to accept being registered as the home organization.

    • You have access to the .

    circle-info

    Right now the SwitchAAI WAYF (Where Are You From) mechanism is not supported (i.e. the web UI used to select with institution the user wishes to login). This means that you will need to register in Keycloak each identity provider you wish to support.

    circle-exclamation

    The process described in this guide will need to be repeated for each instance of Keycloak deployed, if there are more than one in the MedCo network.

    hashtag
    Configure the identity provider(s) in Keycloak

    The following instructions are to be executed on the administration UI of Keycloak, e.g. https://medco-demo.epfl.ch/auth/admin.

    hashtag
    Configure the first login flow

    The behavior of Keycloak during the very login of users through the identity provider is highly customisable. We propose below an example of a working flow but this can be changed to fit your need.

    • Navigate to Authentication > Flows, select First Broker Login and make a Copy of it. Name it for example SwitchAAI-Test Demo IdP First Broker Login.

    • Change the list of executions to make it look like the following image.

    hashtag
    Add the identity provider

    • In the Identity Providers menu, choose Add provider... > SAML v2.0

    • Specify an Alias. Note this will not be changeable later without redoing the whole process. Example: SwitchAAI-Test.

    hashtag
    Add the username mapper

    We need to import a unique but intelligible username in Keycloak from the identity provider. For this we use the SwitchAAI mandatory attribute swissEduPersonUniqueID.

    • Open the Mappers tab and click Create.

    • Fill the field as:

      • Name: SwitchAAI Unique ID.

    hashtag
    Setup a certificate

    A certificate compliant with the SwitchAAI federation needs to be generated and configured. First to generate a self-signed certificate that meets their requirements. You will need from the Keycloak instance:

    • Its FQDN (fully-qualified domain name). Example: medco-demo.epfl.ch.

    • Its SAML entityID, that you can find out in the XML descriptor from the Export tab of the previously configured Keycloak identity provider. Example: https://medco-demo.epfl.ch/auth/realms/master.

    Once you have generated the certificate, set it up in Keycloak:

    • Navigate to the settings page Realm Settings > Keys > Providers and select Add Keystore... > rsa.

    • Specify a name in Console Display Name. Example: rsa-switchaaitest.

    hashtag
    Register Keycloak instance as a Service Provider in SwitchAAI

    The following instructions are to be executed in the . As a result, a Keycloak instance will be registered as a service provider linked to a home organization in the SwitchAAI federation.

    hashtag
    Register new resource

    Click Add a Resource Description and fill the 7 categories of information according to the following instructions. Note that if some fields are not listed in this documentation, their value are not important for the registration of the Keycloak instance and can be set according to the explanations provided by the resource registry.

    hashtag
    1. Basic Resource Information

    • Entity ID: the same SAML entityID you used to generate the certificate. Example: https://medco-demo.epfl.ch/auth/realms/master.

    • Home Organization: the organization that hosts the Keycloak instance currently being registered. The responsible persons of the organization specified here will need to approve the registration. This will typically be the the institution where the MedCo node is deployed. For the purpose of our test we are using AAI Demo Home Organization (aai-demo-idp.switch.ch, AAI Test).

    hashtag
    2. Descriptive Information

    hashtag
    3. Contacts

    hashtag
    4. Service Locations

    • SAML2 HTTP POST binding (x2): the URL at witch the SwitchAAI infrastructure will communicate with the Keycloak instance. You will find it in the configuration page of the configured identity provider in Keycloak under Redirect URI. Example: https://medco-demo.epfl.ch/auth/realms/master/broker/SwitchAAI-Test/endpoint

    hashtag
    5. Certificates

    Copy/paste in this field the PEM part of the certificate that was previously generated. Note that in the example showed below the certificate has already been validated through a separate channel.

    hashtag
    6. Requested Attributes

    Put on Required at least the following attributes. Note that the release of attributes needs to have a justification.

    • E-mail (email). Example reason: Identify user for being able to assign them specific authorizations.

    • Unique ID (swissEduPersonUniqueID). Example reason: Get a unique ID of user.

    hashtag
    7. Intended Audience and Interfederation

    hashtag
    Get the new resource approved

    Once submitted, the responsible persons from the home organization will need to approve the new resource and validate the fingerprint of the certificate submitted. This is a manual process that will most likely be done through email.

    Once this is done, the setup should be functional, and the users will be able to select the configured identity provider to login. Don't forget that this covers only users' authentication, their authorization needs to be handled manually through Keycloak after they login at least once.

    Specify a Display Name, which will be displayed to the user in the login page. Example: SwitchAAI-Test Demo IdP.
  • Specify the Single Sign-On Service URL of the identity provider you are linking with. Example: https://aai-demo-idp.switch.ch/idp/profile/SAML2/POST/SSO.

  • Specify the First Login Flow previously configured to use. Example: SwitchAAI-Test Demo IdP First Broker Login.

  • Toggle to ON the following buttons:

    • Enabled

    • Trust Email

    • HTTP-POST Binding Response

    • HTTP-POST Binding for AuthnRequest

    • Validate Signature

  • Specify the NameID Policy Format as Persistent.

  • Add the certificate(s) (PEM format, separated by commas if there are several of them) of the identity provider you are linking with in Validating X509 Certificates.

  • Save the changes.

  • Mapper Type: Username Template Importer.

  • Template: ${ATTRIBUTE.swissEduPersonUniqueID}

  • Save the changes.

  • Specify a Priority higher than any other RSA key. Example: 150.
  • In Private RSA Key and X509 Certificate fields, copy/paste the respective PEM parts of both the private key and the certificate that were previously generated.

  • Home URL: the address of the MedCo node, at which the UI Glowing Bear can be accessed. Example: https://medco-demo.epfl.ch/.
    SwitchAAI Resource Registryarrow-up-right
    follow this SwitchAAI guidearrow-up-right
    AAI Resource Registryarrow-up-right
    Resulting configuration for the authentication flow.
    Resulting configuration for the identity provider.
    Resulting configuration for the username mapper.
    Resulting configuration.
    Example configuration for the basic resource information.
    Example configuration for the descriptive information.
    Example configuration for the contacts.
    Example configuration for the service locations.
    Example configuration for the certificates.
    Example configuration for the requested attributes.
    Example configuration for the intended audience.

    HTTPS Configuration

    HTTPS is supported for the profiles test-local-3nodes, test-network and prod-network.

    hashtag
    Certificate

    The certificates are held in the configuration profile folder (e.g, ${MEDCO_SETUP_DIR}/configuration-profiles/test-local-3nodes):

    • certificate.key: private key

    • certificate.crt: certificate of own node

    • srv0-certificate.crt, srv1-certificate.crt, …: certificates of all nodes of the network

    hashtag
    Enable HTTPS for the Local Local Deployment

    To enable HTTPS for the profile test-local-3nodes, replace the files certificate.key and certificate.crt from the configuration profile folder with your own versions. Such a certificate can be obtained for example through .

    Then edit the file .env from the compose profile, replace the http with https, and restart the deployment.

    hashtag
    Configure HTTPS for the Network Test and Production Deployments

    For these profiles, HTTPS is mandatory. The profile generation scripts generate and use default self-signed certificates for each node. Those are perfectly fine to be used, but because they are self-signed, an HTTPS warning will be displayed to users in their browser when accessing one of the Glowing Bear instance.

    There is currently only one way of avoiding this warning: configuring the browsers of your users to trust this certificate. This procedure is specific to the browsers and operating systems used at your site.

    circle-info

    In MedCo v1.0.0 the possibility of using your own trusted certificates will be added.

    Let’s Encryptarrow-up-right