Skip to content

Commit

Permalink
[#1003] Apply basic auth on staging environment
Browse files Browse the repository at this point in the history
In this commit, basic authentication has been implemented on the staging
environment to ensure that only authorized users can access it.
Different environment variables have been set up for each environment
(dev, test, staging) to provide different configurations. This allows
for specifying the basic authentication credentials specific to the
staging environment. The changes made include modifying the .envrc file
to set environment variables based on the selected environment, as well
as updating the configuration in config.mk to generate the appropriate
nginx authentication file based on the environment chosen.
  • Loading branch information
placek committed May 14, 2024
1 parent 16a578b commit 3a948e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion scripts/govtool/.envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
source_up
env_vars_required ENVIRONMENT AWS_PROFILE CARDANO_NETWORK DBSYNC_POSTGRES_USER DBSYNC_POSTGRES_PASSWORD DBSYNC_POSTGRES_DB TRAEFIK_LE_EMAIL GTM_ID SENTRY_DSN_BACKEND SENTRY_DSN SENTRY_ENVIRONMENT GRAFANA_ADMIN_PASSWORD GRAFANA_SLACK_RECIPIENT NGINX_BASIC_AUTH GRAFANA_SLACK_OAUTH_TOKEN IP_ADDRESS_BYPASSING_BASIC_AUTH1 IP_ADDRESS_BYPASSING_BASIC_AUTH2
env_vars_required ENVIRONMENT AWS_PROFILE CARDANO_NETWORK DBSYNC_POSTGRES_USER DBSYNC_POSTGRES_PASSWORD DBSYNC_POSTGRES_DB TRAEFIK_LE_EMAIL GTM_ID SENTRY_DSN_BACKEND SENTRY_DSN SENTRY_ENVIRONMENT GRAFANA_ADMIN_PASSWORD GRAFANA_SLACK_RECIPIENT GRAFANA_SLACK_OAUTH_TOKEN IP_ADDRESS_BYPASSING_BASIC_AUTH1 IP_ADDRESS_BYPASSING_BASIC_AUTH2

case "$ENVIRONMENT" in
"dev")
env_vars_required DEV_NGINX_BASIC_AUTH
;;
"test")
env_vars_required TEST_NGINX_BASIC_AUTH
;;
"staging")
env_vars_required STAGING_NGINX_BASIC_AUTH
;;
esac

use flake --extra-experimental-features nix-command --extra-experimental-features flakes ../..#scripts
6 changes: 3 additions & 3 deletions scripts/govtool/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ $(target_config_dir)/nginx/auth.conf: $(target_config_dir)/nginx/
fi

$(target_config_dir)/nginx/govtool.htpasswd: $(target_config_dir)/nginx/
@:$(call check_defined, domain)
if [[ "$(domain)" == *"sanchonet.govtool.byron.network"* ]]; then \
echo "$${NGINX_BASIC_AUTH}" > $@; \
@:$(call check_defined, env)
if [[ "$(env)" != "beta" ]]; then \
echo "$${$(shell echo $(env) | tr a-z A-Z)_NGINX_BASIC_AUTH}" > $@; \
else \
echo > $@; \
fi

0 comments on commit 3a948e2

Please sign in to comment.