UI delivery, stage B: single CSP with optional connect-src origins (OVPMON_CSP_CONNECT_EXTRA)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d38acd74de
commit
d5e83eaff5
13 files changed
+211
-17
No files matched your search
+15
-2
@@ -2,7 +2,7 @@
|
||||
# Update OpenVPN Monitor & Profiler (system services) without touching the data.
|
||||
#
|
||||
# deploy/native/update.sh [--prefix DIR] [--ui-dist FILE|DIR | --build-ui [--node-download]] [--source DIR]
|
||||
# [--no-pull] [--yes] [--rollback]
|
||||
# [--csp-connect-extra ORIGINS] [--no-pull] [--yes] [--rollback]
|
||||
#
|
||||
# --prefix install directory (default: from /etc/ovpmon/deploy.state, else /opt/OpenVPN-Monitoring-Simple)
|
||||
# --ui-dist UI tarball from build-ui.sh, or a directory with index.html: always installed (highest priority)
|
||||
@@ -12,6 +12,9 @@
|
||||
# Without these the committed build deploy/ui-dist of the source is installed automatically when
|
||||
# it differs from the installed UI (<web root>/.ui-source-hash); no UI source: the UI stays
|
||||
# --source checkout with the new version (default: the repository this script is in)
|
||||
# --csp-connect-extra extra origins the UI may call (CSP connect-src): https://host[:port] or http://host[:port]
|
||||
# separated by spaces, in quotes; "" removes them. Without the option the value kept in
|
||||
# /etc/ovpmon/deploy.state (OVPMON_CSP_CONNECT_EXTRA) is applied
|
||||
# --no-pull no "git pull --ff-only" of the source checkout (offline hosts, sources already in place)
|
||||
# --yes no confirmation questions
|
||||
# --rollback restore code, databases, configuration, PKI and client profiles from the newest backup
|
||||
@@ -51,6 +54,8 @@ STAMP=$(stamp)
|
||||
RESTORE_STAMP="$STAMP"
|
||||
STAGING=""
|
||||
HTTPS_PORT=""
|
||||
CSP_EXTRA=""
|
||||
CSP_EXTRA_SET=0
|
||||
OLD_VERSION="unknown"
|
||||
NEW_VERSION="unknown"
|
||||
UI_STAGED=0
|
||||
@@ -217,6 +222,7 @@ main() {
|
||||
--ui-dist) [ $# -ge 2 ] || die "--ui-dist needs a value"; UI_DIST="$2"; shift 2 ;;
|
||||
--build-ui) UI_BUILD=1; shift ;;
|
||||
--node-download) UI_NODE_DL=1; shift ;;
|
||||
--csp-connect-extra) [ $# -ge 2 ] || die "--csp-connect-extra needs a value"; CSP_EXTRA="$2"; CSP_EXTRA_SET=1; shift 2 ;;
|
||||
--source) [ $# -ge 2 ] || die "--source needs a value"; SOURCE="$2"; shift 2 ;;
|
||||
--no-pull) NO_PULL=1; shift ;;
|
||||
--yes|-y) ASSUME_YES=1; shift ;;
|
||||
@@ -243,6 +249,7 @@ main() {
|
||||
valid_prefix "$PREFIX" || die "invalid install directory '$PREFIX'"
|
||||
HTTPS_PORT=$(state_get OVPMON_HTTPS_PORT)
|
||||
[ -n "$HTTPS_PORT" ] || HTTPS_PORT=$(detect_https_port || true)
|
||||
if [ "$CSP_EXTRA_SET" = 0 ]; then CSP_EXTRA=$(state_get OVPMON_CSP_CONNECT_EXTRA); fi
|
||||
SOURCE="${SOURCE:-$ROOT_DIR}"
|
||||
case "$UI_DIST" in ""|/*) ;; *) UI_DIST="$PWD/$UI_DIST" ;; esac
|
||||
|
||||
@@ -252,6 +259,11 @@ main() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! _csp_reason=$(csp_extra_problem "$CSP_EXTRA"); then
|
||||
if [ "$CSP_EXTRA_SET" = 1 ]; then _csp_src="--csp-connect-extra"; else _csp_src="OVPMON_CSP_CONNECT_EXTRA in $STATE_FILE"; fi
|
||||
die "invalid CSP connect-src origins '$CSP_EXTRA' ($_csp_src): $_csp_reason"
|
||||
fi
|
||||
|
||||
# ----- Phase 0 -------------------------------------------------------------------------
|
||||
CURRENT_PHASE="0 preflight"
|
||||
phase 0 "preflight"
|
||||
@@ -480,7 +492,7 @@ main() {
|
||||
[ -d /etc/openvpn/scripts ] || ensure_dir /etc/openvpn/scripts root:root 755
|
||||
# nginx site (only when it is ours and the port is known)
|
||||
if [ -n "$HTTPS_PORT" ]; then
|
||||
render_nginx "$SOURCE" "$HTTPS_PORT" "$TMPD/ovpmon.conf"
|
||||
render_nginx "$SOURCE" "$HTTPS_PORT" "$TMPD/ovpmon.conf" "$CSP_EXTRA"
|
||||
rc=0; install_managed "$TMPD/ovpmon.conf" "$NGINX_SITE" 644 "deploy/native/nginx/ovpmon.conf.template" || rc=$?
|
||||
report "$rc" "$NGINX_SITE"
|
||||
if [ "$rc" = 0 ]; then
|
||||
@@ -510,6 +522,7 @@ main() {
|
||||
rm -rf "$WEB_ROOT.old"
|
||||
state_set OVPMON_PREFIX "$PREFIX"
|
||||
[ -z "$HTTPS_PORT" ] || state_set OVPMON_HTTPS_PORT "$HTTPS_PORT"
|
||||
state_set OVPMON_CSP_CONNECT_EXTRA "$CSP_EXTRA"
|
||||
state_set OVPMON_OS "$OS_ID $OS_VERSION_ID"
|
||||
state_set OVPMON_VERSION "$NEW_VERSION"
|
||||
[ -n "$(state_get OVPMON_INSTALLED_AT)" ] || state_set OVPMON_INSTALLED_AT "adopted $(now_iso)"
|
||||
|
||||
Reference in new issue
Block a user