-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentik-bootstrap-tenant.sh
More file actions
executable file
·36 lines (27 loc) · 1.02 KB
/
authentik-bootstrap-tenant.sh
File metadata and controls
executable file
·36 lines (27 loc) · 1.02 KB
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
#!/bin/sh
if [ x"${AUTHENTIK_URL}" == "x" ]; then
echo "AUTHENTIK_URL is not set"
exit 1
fi
if [ x"${AUTHENTIK_TOKEN}" == "x" ]; then
echo "AUTHENTIK_TOKEN is not set"
exit 2
fi
if [ x"${AUTHENTIK_DEFAULT_TENANT_DOMAIN}" == "x" ]; then
echo "AUTHENTIK_DEFAULT_TENANT_DOMAIN is not set"
exit 3
fi
if [ x"${AUTHENTIK_DEFAULT_TENANT_DEFAULT}" == "x" ]; then
echo "AUTHENTIK_DEFAULT_TENANT_DEFAULT is not set"
exit 4
fi
_JSON_RESPONSE=$(curl -X GET "${AUTHENTIK_URL}/api/v3/core/tenants/?domain=${AUTHENTIK_DEFAULT_TENANT_DOMAIN}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${AUTHENTIK_TOKEN}")
_TENANT_UUID=$(echo $_JSON_RESPONSE | grep -o '"tenant_uuid":"[^"]*' | grep -o '[^"]*$')
_PAYLOAD="{\"default\":${AUTHENTIK_DEFAULT_TENANT_DEFAULT},\"domain\":\"${AUTHENTIK_DEFAULT_TENANT_DOMAIN}\"}"
curl -X PUT "${AUTHENTIK_URL}/api/v3/core/tenants/${_TENANT_UUID}/" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${AUTHENTIK_TOKEN}" \
-H "Content-Type: application/json" \
-d "${_PAYLOAD}"