deploy: route frontend and core through one origin
This commit is contained in:
@@ -4,27 +4,5 @@ set -eu
|
||||
value=${1-}
|
||||
policy_file=${BACKEND_URL_POLICY_FILE:-/etc/thothii/backend-url-policy.json}
|
||||
|
||||
if jq -e --arg value "$value" '.relativeBases | index($value) != null' \
|
||||
"$policy_file" >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! jq -e --arg value "$value" \
|
||||
'.absolutePattern as $pattern | $value | test($pattern)' \
|
||||
"$policy_file" >/dev/null; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
authority=${value#*://}
|
||||
authority=${authority%%/*}
|
||||
port=""
|
||||
case "$authority" in
|
||||
*]:*) port=${authority##*:} ;;
|
||||
*]) ;;
|
||||
*:*) port=${authority##*:} ;;
|
||||
esac
|
||||
|
||||
if [ -n "$port" ]; then
|
||||
max_port=$(jq -r '.maxPort' "$policy_file")
|
||||
if [ "${#port}" -gt 5 ] || [ "$port" -gt "$max_port" ]; then exit 2; fi
|
||||
fi
|
||||
jq -e --arg value "$value" '.relativeBases | index($value) != null' \
|
||||
"$policy_file" >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user