Skip to content

Commit

Permalink
Get username and password for basic authentication via user_data.sh (c…
Browse files Browse the repository at this point in the history
…loses #107)
  • Loading branch information
aldemirenes committed Jul 6, 2017
1 parent 71c4bab commit aeb84a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions provisioning/resources/configs/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
localhost:2000 {
basicauth "USERNAME_PLACEHOLDER" PASSWORD_PLACEHOLDER {
/
/kibana
/elasticsearch
/controlplane
}
proxy / localhost:3000
proxy /collector localhost:8080 {
without /collector
Expand Down
16 changes: 13 additions & 3 deletions utils/scripts/user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,33 @@ iglu_server_super_uid="980ae3ab-3aba-4ffe-a3c2-3b2e24e2ffce"
domain_name=example.com
tls_cond="off"

username=USERNAME_PLACEHOLDER
password=PASSWORD_PLACEHOLDER


# DO NOT ALTER BELOW #
#add apiKey to iglu-resolver.json for auth in the iglu server
iglu_resolver_config_dir="/home/ubuntu/snowplow/configs/iglu-resolver.json"
sed -i 's/\(.*"apikey":\)\(.*\)/\1 "'$iglu_server_super_uid'"/' $iglu_resolver_config_dir

#write super apikey to db
export PGPASSWORD=snowplow
iglu_server_setup="INSERT INTO apikeys (uid, vendor_prefix, permission, createdat) VALUES ('${iglu_server_super_uid}','*','super',current_timestamp);"
psql --host=localhost --port=5432 --username=snowplow --dbname=iglu -c "${iglu_server_setup}"

#add domain name to Caddyfile
inserted_line=""

sed -i '1d' /home/ubuntu/snowplow/configs/Caddyfile #delete first line of the default Caddyfile

if [[ "${tls_cond}" == "on" ]]; then
inserted_line="$domain_name *:80 { \n tls [email protected] \n"
else
inserted_line="*:80 { \n tls off \n"
fi
sed -i "1s/^/${inserted_line}/" /home/ubuntu/snowplow/configs/Caddyfile


sed -i "1s/^/${inserted_line}/" /home/ubuntu/snowplow/configs/Caddyfile
#add username and password to Caddyfile for basic auth
sed -i "s/USERNAME_PLACEHOLDER/$username/g" /home/ubuntu/snowplow/configs/Caddyfile
sed -i "s/PASSWORD_PLACEHOLDER/$password/g" /home/ubuntu/snowplow/configs/Caddyfile
sudo service caddy_init restart

0 comments on commit aeb84a2

Please sign in to comment.