Compare commits

...

11 Commits

Author SHA1 Message Date
ec2c61b308 Martin's change 2025-05-09 09:23:20 +02:00
0cdd5f371b Use temp directory for secret sync cache 2025-05-09 09:21:40 +02:00
Jan
cd38957dd7 Merge pull request #289 from samply/develop
Merge develop into main
2025-04-15 10:17:11 +02:00
Jan
2ddd535794 feat: ssh tunnel (#292)
* Added ccp module for a ssh tunnel

Usage details under https://github.com/samply/ssh-tunnel

* chore: update ssh-tunnel image to harbor

* feat: ssh tunnel support diffrent port

* chore: fix indentation

* chore: move to top level modules

* docs: add ssh-tunnel docs

---------

Co-authored-by: Tobias Kussel <tobias.kussel@dkfz-heidelberg.de>
2025-04-14 10:45:15 +02:00
Jan
973547c322 chore(transfair): add new gw option (#291) 2025-04-11 08:37:31 +02:00
Jan
6b649c9233 feat: expose transfair via traefik (#290)
Note: Requires a bridgehead install to generate the basic auth user
2025-04-09 13:19:52 +02:00
3144ee5214 Fix GitLab token syncing for BBMRI 2025-03-31 11:08:59 +02:00
68804dc71b feat: add transfair setup to ccp 2025-03-26 13:11:43 +01:00
e5aebfe382 chore!: update transfair config 2025-03-26 13:11:43 +01:00
Jan
4ef585bfc5 Merge pull request #281 from samply/develop
Merge develop into main
2025-03-17 10:02:58 +01:00
6ca67ca082 Merge pull request #270 from samply/develop 2025-02-20 15:46:40 +01:00
9 changed files with 125 additions and 13 deletions

View File

@ -30,3 +30,11 @@ idManagementSetup
mtbaSetup mtbaSetup
obds2fhirRestSetup obds2fhirRestSetup
blazeSecondarySetup blazeSecondarySetup
for module in modules/*.sh
do
log DEBUG "sourcing $module"
source $module
done
transfairSetup

View File

@ -334,24 +334,40 @@ function secret_sync_gitlab_token() {
;; ;;
esac esac
# Use Secret Sync to validate the GitLab token in /var/cache/bridgehead/secrets/gitlab_token. if [ "$PROJECT" == "bbmri" ]; then
# If the project is BBMRI, use the BBMRI-ERIC broker and not the GBN broker
proxy_id=$ERIC_PROXY_ID
broker_url=$ERIC_BROKER_URL
broker_id=$ERIC_BROKER_ID
root_crt_file="/srv/docker/bridgehead/bbmri/modules/${ERIC_ROOT_CERT}.root.crt.pem"
else
proxy_id=$PROXY_ID
broker_url=$BROKER_URL
broker_id=$BROKER_ID
root_crt_file="/srv/docker/bridgehead/$PROJECT/root.crt.pem"
fi
# Create a temporary directory for Secret Sync that is valid per boot
secret_sync_tempdir="/tmp/bridgehead/secret-sync.boot-$(cat /proc/sys/kernel/random/boot_id)"
mkdir -p $secret_sync_tempdir
# Use Secret Sync to validate the GitLab token in $secret_sync_tempdir/cache.
# If it is missing or expired, Secret Sync will create a new token and write it to the file. # If it is missing or expired, Secret Sync will create a new token and write it to the file.
# The git credential helper reads the token from the file during git pull. # The git credential helper reads the token from the file during git pull.
mkdir -p /var/cache/bridgehead/secrets
touch /var/cache/bridgehead/secrets/gitlab_token # the file has to exist to be mounted correctly in the Docker container
log "INFO" "Running Secret Sync for the GitLab token (gitlab=$gitlab)" log "INFO" "Running Secret Sync for the GitLab token (gitlab=$gitlab)"
docker pull docker.verbis.dkfz.de/cache/samply/secret-sync-local:latest # make sure we have the latest image docker pull docker.verbis.dkfz.de/cache/samply/secret-sync-local:latest # make sure we have the latest image
docker run --rm \ docker run --rm \
-v /var/cache/bridgehead/secrets/gitlab_token:/usr/local/cache \
-v $PRIVATEKEYFILENAME:/run/secrets/privkey.pem:ro \ -v $PRIVATEKEYFILENAME:/run/secrets/privkey.pem:ro \
-v /srv/docker/bridgehead/$PROJECT/root.crt.pem:/run/secrets/root.crt.pem:ro \ -v $root_crt_file:/run/secrets/root.crt.pem:ro \
-v /etc/bridgehead/trusted-ca-certs:/conf/trusted-ca-certs:ro \ -v /etc/bridgehead/trusted-ca-certs:/conf/trusted-ca-certs:ro \
-v $secret_sync_tempdir:/secret-sync/ \
-e CACHE_PATH=/secret-sync/gitlab-token \
-e TLS_CA_CERTIFICATES_DIR=/conf/trusted-ca-certs \ -e TLS_CA_CERTIFICATES_DIR=/conf/trusted-ca-certs \
-e NO_PROXY=localhost,127.0.0.1 \ -e NO_PROXY=localhost,127.0.0.1 \
-e ALL_PROXY=$HTTPS_PROXY_FULL_URL \ -e ALL_PROXY=$HTTPS_PROXY_FULL_URL \
-e PROXY_ID=$PROXY_ID \ -e PROXY_ID=$proxy_id \
-e BROKER_URL=$BROKER_URL \ -e BROKER_URL=$broker_url \
-e GITLAB_PROJECT_ACCESS_TOKEN_PROVIDER=secret-sync-central.central-secret-sync.$BROKER_ID \ -e GITLAB_PROJECT_ACCESS_TOKEN_PROVIDER=secret-sync-central.central-secret-sync.$broker_id \
-e SECRET_DEFINITIONS=GitLabProjectAccessToken:BRIDGEHEAD_CONFIG_REPO_TOKEN:$gitlab \ -e SECRET_DEFINITIONS=GitLabProjectAccessToken:BRIDGEHEAD_CONFIG_REPO_TOKEN:$gitlab \
docker.verbis.dkfz.de/cache/samply/secret-sync-local:latest docker.verbis.dkfz.de/cache/samply/secret-sync-local:latest
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then

View File

@ -2,7 +2,7 @@
[ "$1" = "get" ] || exit [ "$1" = "get" ] || exit
source /var/cache/bridgehead/secrets/gitlab_token source "/tmp/bridgehead/secret-sync.boot-$(cat /proc/sys/kernel/random/boot_id)/gitlab-token"
# Any non-empty username works, only the token matters # Any non-empty username works, only the token matters
cat << EOF cat << EOF

View File

@ -41,6 +41,14 @@ if [ ! -z "$NNGM_CTS_APIKEY" ] && [ -z "$NNGM_AUTH" ]; then
add_basic_auth_user "nngm" $generated_passwd "NNGM_AUTH" $PROJECT add_basic_auth_user "nngm" $generated_passwd "NNGM_AUTH" $PROJECT
fi fi
if [ -z "$TRANSFAIR_AUTH" ]; then
if [[ -n "$TTP_URL" || -n "$EXCHANGE_ID_SYSTEM" ]]; then
log "INFO" "Now generating basic auth user for transfair API (see adduser in bridgehead for more information). "
generated_passwd="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 32)"
add_basic_auth_user "transfair" $generated_passwd "TRANSFAIR_AUTH" $PROJECT
fi
fi
log "INFO" "Registering system units for bridgehead and bridgehead-update" log "INFO" "Registering system units for bridgehead and bridgehead-update"
cp -v \ cp -v \
lib/systemd/bridgehead\@.service \ lib/systemd/bridgehead\@.service \

View File

@ -0,0 +1,17 @@
version: "3.7"
services:
ssh-tunnel:
image: docker.verbis.dkfz.de/cache/samply/ssh-tunnel
container_name: bridgehead-ccp-ssh-tunnel
environment:
SSH_TUNNEL_USERNAME: "${SSH_TUNNEL_USERNAME}"
SSH_TUNNEL_HOST: "${SSH_TUNNEL_HOST}"
SSH_TUNNEL_PORT: "${SSH_TUNNEL_PORT:-22}"
volumes:
- "/etc/bridgehead/ssh-tunnel.conf:/ssh-tunnel.conf:ro"
secrets:
- privkey
secrets:
privkey:
file: /etc/bridgehead/pki/ssh-tunnel.priv.pem

View File

@ -0,0 +1,6 @@
#!/bin/bash
if [ -n "$ENABLE_SSH_TUNNEL" ]; then
log INFO "SSH Tunnel setup detected -- will start SSH Tunnel."
OVERRIDE+=" -f ./$PROJECT/modules/ssh-tunnel-compose.yml"
fi

19
modules/ssh-tunnel.md Normal file
View File

@ -0,0 +1,19 @@
# SSH Tunnel Module
This module enables SSH tunneling capabilities for the Bridgehead installation.
The primary use case for this is to connect bridgehead components that are hosted externally due to security concerns.
To connect the new components to the locally running bridgehead infra one is supposed to write a docker-compose.override.yml changing the urls to point to the corresponding forwarded port of the ssh-tunnel container.
## Configuration Variables
- `ENABLE_SSH_TUNNEL`: Required to enable the module
- `SSH_TUNNEL_USERNAME`: Username for SSH connection
- `SSH_TUNNEL_HOST`: Target host for SSH tunnel
- `SSH_TUNNEL_PORT`: SSH port (defaults to 22)
## Configuration Files
The module requires the following files to be present:
- `/etc/bridgehead/ssh-tunnel.conf`: SSH tunnel configuration file. Detailed information can be found [here](https://github.com/samply/ssh-tunnel?tab=readme-ov-file#configuration).
- `/etc/bridgehead/pki/ssh-tunnel.priv.pem`: The SSH private key used to connect to the `SSH_TUNNEL_HOST`. **Passphrases for the key are not supported!**

View File

@ -5,8 +5,12 @@ services:
container_name: bridgehead-transfair container_name: bridgehead-transfair
environment: environment:
# NOTE: Those 3 variables need only to be passed if their set, otherwise transfair will complain about empty url values # NOTE: Those 3 variables need only to be passed if their set, otherwise transfair will complain about empty url values
- INSTITUTE_TTP_URL - TTP_URL
- INSTITUTE_TTP_API_KEY - TTP_ML_API_KEY
- TTP_GW_SOURCE
- TTP_GW_DOMAIN
- TTP_TYPE
- TTP_AUTH
- PROJECT_ID_SYSTEM - PROJECT_ID_SYSTEM
- FHIR_REQUEST_URL=${FHIR_REQUEST_URL} - FHIR_REQUEST_URL=${FHIR_REQUEST_URL}
- FHIR_INPUT_URL=${FHIR_INPUT_URL} - FHIR_INPUT_URL=${FHIR_INPUT_URL}
@ -21,6 +25,17 @@ services:
volumes: volumes:
- /var/cache/bridgehead/${PROJECT}/transfair:/transfair - /var/cache/bridgehead/${PROJECT}/transfair:/transfair
- /etc/bridgehead/trusted-ca-certs:/conf/trusted-ca-certs:ro - /etc/bridgehead/trusted-ca-certs:/conf/trusted-ca-certs:ro
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.transfair-strip.stripprefix.prefixes=/transfair"
- "traefik.http.routers.transfair.middlewares=transfair-strip,transfair-auth"
- "traefik.http.routers.transfair.rule=PathPrefix(`/transfair`)"
- "traefik.http.services.transfair.loadbalancer.server.port=8080"
- "traefik.http.routers.transfair.tls=true"
traefik:
labels:
- "traefik.http.middlewares.transfair-auth.basicauth.users=${TRANSFAIR_AUTH}"
transfair-input-blaze: transfair-input-blaze:
image: docker.verbis.dkfz.de/cache/samply/blaze:${BLAZE_TAG} image: docker.verbis.dkfz.de/cache/samply/blaze:${BLAZE_TAG}
@ -34,6 +49,13 @@ services:
volumes: volumes:
- "transfair-input-blaze-data:/app/data" - "transfair-input-blaze-data:/app/data"
profiles: ["transfair-input-blaze"] profiles: ["transfair-input-blaze"]
labels:
- "traefik.enable=true"
- "traefik.http.routers.transfair-input-blaze.rule=PathPrefix(`/data-delivery`)"
- "traefik.http.middlewares.transfair-input-strip.stripprefix.prefixes=/data-delivery"
- "traefik.http.services.transfair-input-blaze.loadbalancer.server.port=8080"
- "traefik.http.routers.transfair-input-blaze.middlewares=transfair-input-strip,transfair-auth"
- "traefik.http.routers.transfair-input-blaze.tls=true"
transfair-request-blaze: transfair-request-blaze:
image: docker.verbis.dkfz.de/cache/samply/blaze:${BLAZE_TAG} image: docker.verbis.dkfz.de/cache/samply/blaze:${BLAZE_TAG}
@ -47,6 +69,13 @@ services:
volumes: volumes:
- "transfair-request-blaze-data:/app/data" - "transfair-request-blaze-data:/app/data"
profiles: ["transfair-request-blaze"] profiles: ["transfair-request-blaze"]
labels:
- "traefik.enable=true"
- "traefik.http.routers.transfair-request-blaze.rule=PathPrefix(`/data-requests`)"
- "traefik.http.middlewares.transfair-request-strip.stripprefix.prefixes=/data-requests"
- "traefik.http.services.transfair-request-blaze.loadbalancer.server.port=8080"
- "traefik.http.routers.transfair-request-blaze.middlewares=transfair-request-strip,transfair-auth"
- "traefik.http.routers.transfair-request-blaze.tls=true"
volumes: volumes:
transfair-input-blaze-data: transfair-input-blaze-data:

View File

@ -1,7 +1,7 @@
#!/bin/bash -e #!/bin/bash -e
function transfairSetup() { function transfairSetup() {
if [[ -n "$INSTITUTE_TTP_URL" || -n "$EXCHANGE_ID_SYSTEM" ]]; then if [[ -n "$TTP_URL" || -n "$EXCHANGE_ID_SYSTEM" ]]; then
echo "Starting transfair." echo "Starting transfair."
OVERRIDE+=" -f ./modules/transfair-compose.yml" OVERRIDE+=" -f ./modules/transfair-compose.yml"
if [ -n "$FHIR_INPUT_URL" ]; then if [ -n "$FHIR_INPUT_URL" ]; then
@ -18,5 +18,14 @@ function transfairSetup() {
FHIR_REQUEST_URL="http://transfair-requests-blaze:8080" FHIR_REQUEST_URL="http://transfair-requests-blaze:8080"
OVERRIDE+=" --profile transfair-request-blaze" OVERRIDE+=" --profile transfair-request-blaze"
fi fi
if [ -n "$TTP_GW_SOURCE" ]; then
log INFO "TransFAIR configured with greifswald as ttp"
TTP_TYPE="greifswald"
elif [ -n "$TTP_ML_API_KEY" ]; then
log INFO "TransFAIR configured with mainzelliste as ttp"
TTP_TYPE="mainzelliste"
else
log INFO "TransFAIR configured without ttp"
fi
fi fi
} }