Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#27 add basic auth for dev/test environments #71

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ jobs:
ssh-private-key: ${{ secrets.GHA_SSH_PRIVATE_KEY }}
- name: Prepare and upload app config
run: |
if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi;
if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi;
DOMAIN=${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}
make prepare-config
if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi;
if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi;
Expand Down
3 changes: 3 additions & 0 deletions src/docker-compose.sanchonet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ services:

vva-fe:
image: ${VVA_FE_REPO:-733019650473.dkr.ecr.eu-west-1.amazonaws.com/frontend}:${TAG:-main-dev-sanchonet}
volumes:
- /home/ubuntu/config/nginx/auth.conf:/etc/nginx/conf.d/auth.conf
- /home/ubuntu/config/nginx/govtool.htpasswd:/etc/nginx/conf.d/govtool.htpasswd
depends_on:
cardano-node:
condition: service_healthy
Expand Down
17 changes: 17 additions & 0 deletions src/scripts/prepare-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,20 @@ cp -a "$repo_root_dir/src/config/grafana-provisioning/"* "$grafana_provisioning_
sed -e "s/GRAFANA_SLACK_RECIPIENT/$GRAFANA_SLACK_RECIPIENT/" \
-e "s|GRAFANA_SLACK_OAUTH_TOKEN|$GRAFANA_SLACK_OAUTH_TOKEN|" \
-i "$grafana_provisioning_dir/alerting/alerting.yml"

# nginx config for frontend optional basic auth
nginx_config_dir="$target_config_dir/nginx"
mkdir -p "$nginx_config_dir"
if [[ "$DOMAIN" == *"govtool.byron.network"* ]]; then
cat >"$nginx_config_dir/auth.conf" <<_EOF_
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/conf.d/govtool.htpasswd;
_EOF_
cat >"$nginx_config_dir/govtool.htpasswd" <<_EOF_
$NGINX_BASIC_AUTH
_EOF_
else
# create empty files if no basic auth is needed
touch "$nginx_config_dir/auth.conf"
touch "$nginx_config_dir/govtool.htpasswd"
fi