-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhent-og-lagre-miljøvariabler.sh
48 lines (37 loc) · 1.47 KB
/
hent-og-lagre-miljøvariabler.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
kubectl config use-context dev-gcp
function get_secrets() {
local repo=$1
kubectl -n teamfamilie get secret ${repo} -o json | jq '.data | map_values(@base64d)'
}
KLAGE_FRONTEND_LOKAL_SECRETS=$(get_secrets azuread-familie-klage-frontend-lokal)
KLAGE_FRONTEND_CLIENT_ID=$(echo "$KLAGE_FRONTEND_LOKAL_SECRETS" | jq -r '.AZURE_APP_CLIENT_ID')
KLAGE_FRONTEND_CLIENT_SECRET=$(echo "$KLAGE_FRONTEND_LOKAL_SECRETS" | jq -r '.AZURE_APP_CLIENT_SECRET')
# Generate random 32 character strings for the cookie and session keys
COOKIE_KEY1=$(openssl rand -hex 16)
COOKIE_KEY2=$(openssl rand -hex 16)
PASSPORTCOOKIE_KEY1=$(openssl rand -hex 16)
PASSPORTCOOKIE_KEY2=$(openssl rand -hex 16)
PASSPORTCOOKIE_KEY3=$(openssl rand -hex 16)
PASSPORTCOOKIE_KEY4=$(openssl rand -hex 16)
SESSION_SECRET=$(openssl rand -hex 16)
if [ -z "$KLAGE_FRONTEND_CLIENT_ID" ]
then
echo "Klarte ikke å hente miljøvariabler. Er du pålogget Naisdevice og google?"
return 1
fi
# Write the variables into the .env file
cat << EOF > .env
# Denne filen er generert automatisk ved å kjøre \`hent-og-lagre-miljøvariabler.sh\`
COOKIE_KEY1=$COOKIE_KEY1
COOKIE_KEY2=$COOKIE_KEY2
SESSION_SECRET=$SESSION_SECRET
CLIENT_ID=$KLAGE_FRONTEND_CLIENT_ID
CLIENT_SECRET=$KLAGE_FRONTEND_CLIENT_SECRET
# Lokalt
#ENV=local
#FAMILIE_KLAGE_SCOPE=api://dev-gcp.teamfamilie.familie-klage-lokal/.default
# Lokalt mot preprod
ENV=lokalt-mot-preprod
FAMILIE_KLAGE_SCOPE=api://dev-gcp.teamfamilie.familie-klage/.default
APP_VERSION=0.0.1
EOF