27 lines
1.1 KiB
Bash
27 lines
1.1 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
if [ -n "$SUPABASE_SECRET_KEY" ] && [ -n "$SUPABASE_PUBLISHABLE_KEY" ]; then
|
||
|
|
export LUA_AUTH_EXPR="\$((headers.authorization ~= nil and headers.authorization:sub(1, 10) ~= 'Bearer sb_' and headers.authorization) or (headers.apikey == '$SUPABASE_SECRET_KEY' and 'Bearer $SERVICE_ROLE_KEY_ASYMMETRIC') or (headers.apikey == '$SUPABASE_PUBLISHABLE_KEY' and 'Bearer $ANON_KEY_ASYMMETRIC') or headers.apikey)"
|
||
|
|
else
|
||
|
|
export LUA_AUTH_EXPR="\$((headers.authorization ~= nil and headers.authorization:sub(1, 10) ~= 'Bearer sb_' and headers.authorization) or headers.apikey)"
|
||
|
|
fi
|
||
|
|
|
||
|
|
awk '{
|
||
|
|
result = ""
|
||
|
|
rest = $0
|
||
|
|
while (match(rest, /\$[A-Za-z_][A-Za-z_0-9]*/)) {
|
||
|
|
varname = substr(rest, RSTART + 1, RLENGTH - 1)
|
||
|
|
if (varname in ENVIRON) {
|
||
|
|
result = result substr(rest, 1, RSTART - 1) ENVIRON[varname]
|
||
|
|
} else {
|
||
|
|
result = result substr(rest, 1, RSTART + RLENGTH - 1)
|
||
|
|
}
|
||
|
|
rest = substr(rest, RSTART + RLENGTH)
|
||
|
|
}
|
||
|
|
print result rest
|
||
|
|
}' /home/kong/temp.yml > "$KONG_DECLARATIVE_CONFIG"
|
||
|
|
|
||
|
|
sed -i '/^[[:space:]]*- key:[[:space:]]*$/d' "$KONG_DECLARATIVE_CONFIG"
|
||
|
|
|
||
|
|
exec /entrypoint.sh kong docker-start
|