diff --git a/README.md b/README.md index 7745b47..48a794c 100644 --- a/README.md +++ b/README.md @@ -286,9 +286,8 @@ It is not recommended to use this script in production! ### Basic Auth -Some services we use authfication to protect the data. For example for local data managemnt like the blaze. +use add_user.sh -The /auth direcotry contians for each project a file with user and password combination. If it is not present please create a file with just the project name. To add a combination use [htpasswdgenerator](https://htpasswdgenerator.de/) or use htpasswd on your maschine. ### HTTPS Access diff --git a/dktk-fed/docker-compose.yml b/dktk-fed/docker-compose.yml index bd25386..408066a 100644 --- a/dktk-fed/docker-compose.yml +++ b/dktk-fed/docker-compose.yml @@ -6,23 +6,26 @@ services: container_name: bridgehead-traefik image: traefik:2.4 command: - - --api.insecure=true - --entrypoints.web.address=:80 - --entrypoints.websecure.address=:443 - --providers.docker=true - - --providers.file.directory=/configuration/ + - --api.dashboard=true + - --accesslog=true # print access-logs - --entrypoints.web.http.redirections.entrypoint.to=websecure - --entrypoints.web.http.redirections.entrypoint.scheme=https - - --providers.file.watch=true + labels: + - "traefik.http.routers.dashboard.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)" + - "traefik.http.routers.dashboard.entrypoints=websecure" + - "traefik.http.routers.dashboard.service=api@internal" + - "traefik.http.routers.dashboard.tls=true" + - "traefik.http.routers.dashboard.middlewares=auth" + - "traefik.http.middlewares.auth.basicauth.users=${bc_auth_users}" ports: - 80:80 - 443:443 - - 8080:8080 volumes: - ../certs:/tools/certs - - ../tools/traefik/:/configuration/ - /var/run/docker.sock:/var/run/docker.sock:ro - - ../auth/:/auth extra_hosts: - "host.docker.internal:host-gateway" @@ -62,12 +65,13 @@ services: - "blaze-data:/app/data" labels: - "traefik.enable=true" - - "traefik.http.middlewares.test-auth.basicauth.usersfile=/auth/dktk" + - "traefik.http.middlewares.test-auth.basicauth.users=${bc_auth_users}" - "traefik.http.routers.blaze_dktk.rule=PathPrefix(`/dktk-localdatamanagement`)" - "traefik.http.middlewares.dktk_b_strip.stripprefix.prefixes=/dktk-localdatamanagement" - "traefik.http.services.blaze_dktk.loadbalancer.server.port=8080" - "traefik.http.routers.blaze_dktk.middlewares=dktk_b_strip,test-auth" - "traefik.http.routers.blaze_dktk.tls=true" + dktk-connector: image: "samply/share-client:gbn-feature-environmentPreconfiguration" diff --git a/lib/add_bc_user.sh b/lib/add_bc_user.sh new file mode 100755 index 0000000..924f2e1 --- /dev/null +++ b/lib/add_bc_user.sh @@ -0,0 +1,29 @@ +#!/bin/bash -e + +echo "This script add's a user with password to the bridghead" + +if [ $# -eq 0 ]; then + echo "No arguments provided, please provide the project name" + exit 1 +fi + +if [ ! -f /etc/systemd/system/bridgehead@$1.service.d/override.conf ]; then + echo "Please create a Service first, with setup-bridgehead-units.sh" + exit +fi + +read -p 'Username: ' bc_user +read -sp 'Password: ' bc_password + +echo + + +bc=`docker run --rm -it httpd:latest htpasswd -nb $bc_user $bc_password` + +if grep -q -E "Environment=bc_auth_users=" /etc/systemd/system/bridgehead@$1.service.d/override.conf ; then + x=`grep -E "Environment=bc_auth_users=" /etc/systemd/system/bridgehead@$1.service.d/override.conf` + sed -i "/Environment=bc_auth_users=/c\\$x,$bc" /etc/systemd/system/bridgehead@$1.service.d/override.conf + +else + echo "Environment=bc_auth_users=${bc}" >> /etc/systemd/system/bridgehead@$1.service.d/override.conf +fi \ No newline at end of file diff --git a/lib/generate.sh b/lib/generate.sh index 2e6859b..8d64d14 100755 --- a/lib/generate.sh +++ b/lib/generate.sh @@ -70,11 +70,11 @@ cat > ./landing/index.html < Bridgehead - Reverse Proxy Traefik + Reverse Proxy Traefik DKTK - Blaze + Blaze diff --git a/start-bridgehead.sh b/start-bridgehead.sh index 0d534e9..cbeef04 100755 --- a/start-bridgehead.sh +++ b/start-bridgehead.sh @@ -1,6 +1,11 @@ #!/bin/bash ### Note: Currently not complete, needs some features before useable for production +if [ $# -eq 0 ]; then + echo "No arguments provided" + exit 1 +fi + source lib/functions.sh if ! lib/prerequisites.sh; then