@scalio-cloud/ui 0.93.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/nginx/geoip-attribution.txt +1 -0
- package/nginx/geoip-db.sh +61 -0
- package/nginx/geoip-module.sh +68 -0
- package/package.json +1 -1
- package/react/mail.js +19 -1
package/README.md
CHANGED
|
@@ -89,6 +89,37 @@ allowed. An invalid entry closes the instance for everyone except the machine pa
|
|
|
89
89
|
`ngx_http_geoip2_module` and the free DB-IP «IP to Country Lite» database (CC BY 4.0: show «IP Geolocation by DB-IP»
|
|
90
90
|
on the about page). Tests (`test/access.test.js`) run with real nginx when it is installed.
|
|
91
91
|
|
|
92
|
+
### Country limit: geoip2 module and DB-IP database in the image (from 0.94.0)
|
|
93
|
+
|
|
94
|
+
The official nginx image has neither the geoip2 module nor a country database. Two scripts close that gap at
|
|
95
|
+
image build time; add this to the app's frontend Dockerfile (same nginx version in both stages):
|
|
96
|
+
|
|
97
|
+
```dockerfile
|
|
98
|
+
FROM nginx:1.27-alpine AS geoip
|
|
99
|
+
COPY --from=build /app/node_modules/@scalio-cloud/ui/nginx/geoip-*.sh /usr/local/bin/
|
|
100
|
+
RUN geoip-module.sh build /geoip && geoip-db.sh /geoip/dbip-country.mmdb
|
|
101
|
+
# ... in the final nginx stage, after the access-limit lines above:
|
|
102
|
+
COPY --from=build /app/node_modules/@scalio-cloud/ui/nginx/geoip-module.sh /usr/local/bin/
|
|
103
|
+
COPY --from=geoip /geoip /tmp/geoip
|
|
104
|
+
RUN geoip-module.sh install /tmp/geoip && rm -rf /tmp/geoip
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- `geoip-module.sh build` compiles `ngx_http_geoip2_module` (pinned, `SCALIO_GEOIP2_VERSION`) for the nginx of that
|
|
108
|
+
stage. `install` copies it, adds `load_module` to `nginx.conf`, installs libmaxminddb and the database. A module that
|
|
109
|
+
cannot be built breaks the build (a silent image without the module would be worse).
|
|
110
|
+
- `geoip-db.sh` loads this month's «IP to Country Lite» file from download.db-ip.com (last month's while the new one is
|
|
111
|
+
not out yet) and checks gzip, size, MaxMind marker and, if `SCALIO_GEOIP_SHA256` is set, a pinned checksum
|
|
112
|
+
(db-ip.com publishes none). **It never breaks the build:** on any error the log says
|
|
113
|
+
`scalio-geoip: no country database (...) without countries`, the image has no database and `access-limit.sh` only
|
|
114
|
+
uses the IP list (and says so at start, `countries_unavailable` in `access-status.json`).
|
|
115
|
+
- Attribution (CC BY 4.0): show the text in `nginx/geoip-attribution.txt`, «IP Geolocation by DB-IP» linked to
|
|
116
|
+
https://db-ip.com, on the app's about page.
|
|
117
|
+
- Monthly update: the database is part of the image, so every image build loads the current month. «Dev neu bauen» and a
|
|
118
|
+
release therefore renew it; a running instance only gets the new month with a new image. For customers who stay on
|
|
119
|
+
one image for months a scheduled monthly rebuild is needed (open decision, see the PR of Nr. 154).
|
|
120
|
+
- Tests: `test/geoip_db.test.js` (local directory instead of db-ip.com), `test/geoip_module.test.js` (install step; the
|
|
121
|
+
module build needs Docker and is checked by building the image).
|
|
122
|
+
|
|
92
123
|
### Show the limit in the settings: `AccessLimitStatus` (React, from 0.93.0)
|
|
93
124
|
|
|
94
125
|
At start the script also writes `access-status.json` into the web root (nginx serves it like any static file):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
IP Geolocation by DB-IP (https://db-ip.com), IP to Country Lite database, licensed under CC BY 4.0.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Loads the DB-IP «IP to Country Lite» database (CC BY 4.0, https://db-ip.com) for the country limit of the frontend
|
|
3
|
+
# images (scalio-docs ADR 0085, Nr. 154). Run it in a build stage of the app's Dockerfile, see README.
|
|
4
|
+
#
|
|
5
|
+
# geoip-db.sh [TARGET] TARGET default $SCALIO_GEOIP_DB or /etc/nginx/geoip/dbip-country.mmdb
|
|
6
|
+
#
|
|
7
|
+
# Takes this month's file, or last month's while db-ip.com has not published the new one yet. Checks before it
|
|
8
|
+
# replaces TARGET: gzip, size (SCALIO_GEOIP_MIN_BYTES / SCALIO_GEOIP_MAX_BYTES), MaxMind DB marker and, when
|
|
9
|
+
# SCALIO_GEOIP_SHA256 is set, the SHA-256 of the unpacked file (db-ip.com publishes no checksum file, so it is a pin).
|
|
10
|
+
# Never breaks the build: on any error it says why in the log, leaves TARGET as it was and exits 0. The image then
|
|
11
|
+
# has no database and access-limit.sh falls back to the IP list at start (and logs it).
|
|
12
|
+
#
|
|
13
|
+
# SCALIO_GEOIP_URL base URL, default https://download.db-ip.com/free (tests use file://)
|
|
14
|
+
# SCALIO_GEOIP_MONTH fixed month YYYY-MM instead of the current and the previous one
|
|
15
|
+
set -u
|
|
16
|
+
|
|
17
|
+
TARGET="${1:-${SCALIO_GEOIP_DB:-/etc/nginx/geoip/dbip-country.mmdb}}"
|
|
18
|
+
BASE="${SCALIO_GEOIP_URL:-https://download.db-ip.com/free}"
|
|
19
|
+
MIN="${SCALIO_GEOIP_MIN_BYTES:-1000000}"
|
|
20
|
+
MAX="${SCALIO_GEOIP_MAX_BYTES:-200000000}"
|
|
21
|
+
SHA="${SCALIO_GEOIP_SHA256:-}"
|
|
22
|
+
|
|
23
|
+
log() { echo "scalio-geoip: $*" >&2; }
|
|
24
|
+
giveup() { log "no country database ($1): the image continues without countries, ALLOWED_COUNTRIES will not work until the next build"; exit 0; }
|
|
25
|
+
|
|
26
|
+
if [ -n "${SCALIO_GEOIP_MONTH:-}" ]; then
|
|
27
|
+
MONTHS="$SCALIO_GEOIP_MONTH"
|
|
28
|
+
else
|
|
29
|
+
y=$(date -u +%Y); m=$(date -u +%m | sed 's/^0//')
|
|
30
|
+
if [ "$m" -le 1 ]; then py=$((y - 1)); pm=12; else py=$y; pm=$((m - 1)); fi
|
|
31
|
+
MONTHS=$(printf '%04d-%02d %04d-%02d' "$y" "$m" "$py" "$pm")
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
command -v curl >/dev/null 2>&1 || giveup "curl missing"
|
|
35
|
+
DIR=$(dirname "$TARGET")
|
|
36
|
+
mkdir -p "$DIR" 2>/dev/null || giveup "cannot create $DIR"
|
|
37
|
+
TMP=$(mktemp -d 2>/dev/null) || giveup "no temporary directory"
|
|
38
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
39
|
+
|
|
40
|
+
REASON="nothing tried"
|
|
41
|
+
for month in $MONTHS; do
|
|
42
|
+
NAME="dbip-country-lite-$month"
|
|
43
|
+
if ! curl -fsSL --retry 2 --connect-timeout 15 --max-time 300 -o "$TMP/db.gz" "$BASE/$NAME.mmdb.gz" 2>"$TMP/err"; then
|
|
44
|
+
REASON="$NAME not downloadable: $(tr '\n' ' ' < "$TMP/err")"; log "$REASON"; continue
|
|
45
|
+
fi
|
|
46
|
+
if ! gzip -t "$TMP/db.gz" 2>/dev/null; then REASON="$NAME is not a gzip file"; log "$REASON"; continue; fi
|
|
47
|
+
gzip -dc "$TMP/db.gz" > "$TMP/db.mmdb" 2>/dev/null || { REASON="$NAME cannot be unpacked"; log "$REASON"; continue; }
|
|
48
|
+
size=$(wc -c < "$TMP/db.mmdb" | tr -d ' ')
|
|
49
|
+
if [ "$size" -lt "$MIN" ]; then REASON="$NAME too small ($size bytes, minimum $MIN)"; log "$REASON"; continue; fi
|
|
50
|
+
if [ "$size" -gt "$MAX" ]; then REASON="$NAME too large ($size bytes, maximum $MAX)"; log "$REASON"; continue; fi
|
|
51
|
+
if ! grep -aq 'MaxMind.com' "$TMP/db.mmdb"; then REASON="$NAME is not a MaxMind DB file"; log "$REASON"; continue; fi
|
|
52
|
+
if [ -n "$SHA" ]; then
|
|
53
|
+
got=$(sha256sum "$TMP/db.mmdb" | cut -d' ' -f1)
|
|
54
|
+
if [ "$got" != "$SHA" ]; then REASON="$NAME checksum differs (SCALIO_GEOIP_SHA256)"; log "$REASON"; continue; fi
|
|
55
|
+
fi
|
|
56
|
+
mv "$TMP/db.mmdb" "$TARGET.new" && mv "$TARGET.new" "$TARGET" || giveup "cannot write $TARGET"
|
|
57
|
+
chmod 644 "$TARGET" 2>/dev/null
|
|
58
|
+
log "loaded $NAME ($size bytes) into $TARGET. IP Geolocation by DB-IP (https://db-ip.com), CC BY 4.0"
|
|
59
|
+
exit 0
|
|
60
|
+
done
|
|
61
|
+
giveup "$REASON"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ngx_http_geoip2_module for the official nginx image (scalio-docs ADR 0085, Nr. 154). The official image has no
|
|
3
|
+
# geoip2 module, and a module only loads into the exact nginx version it was built for, so the build stage uses the
|
|
4
|
+
# same base image as the final stage. Usage, see README:
|
|
5
|
+
#
|
|
6
|
+
# geoip-module.sh build DIR build stage (nginx:<version>-alpine or -debian, as root): compiles
|
|
7
|
+
# DIR/ngx_http_geoip2_module.so for the nginx that is installed there
|
|
8
|
+
# geoip-module.sh install DIR final stage: libmaxminddb, DIR/*.so into the modules directory, `load_module` first
|
|
9
|
+
# in nginx.conf, DIR/dbip-country.mmdb (from geoip-db.sh) to /etc/nginx/geoip/
|
|
10
|
+
#
|
|
11
|
+
# SCALIO_GEOIP2_VERSION version of leev/ngx_http_geoip2_module, default below
|
|
12
|
+
# SCALIO_NGINX_DIR, SCALIO_MODULES_DIR, SCALIO_SKIP_PACKAGES for tests (other paths, no apk/apt)
|
|
13
|
+
set -eu
|
|
14
|
+
|
|
15
|
+
CMD="${1:-}"; DIR="${2:-}"
|
|
16
|
+
[ -n "$CMD" ] && [ -n "$DIR" ] || { echo "usage: geoip-module.sh build|install DIR" >&2; exit 2; }
|
|
17
|
+
MODVER="${SCALIO_GEOIP2_VERSION:-3.4}"
|
|
18
|
+
NGINX_DIR="${SCALIO_NGINX_DIR:-/etc/nginx}"
|
|
19
|
+
MODULES_DIR="${SCALIO_MODULES_DIR:-/usr/lib/nginx/modules}"
|
|
20
|
+
SO=ngx_http_geoip2_module.so
|
|
21
|
+
|
|
22
|
+
log() { echo "scalio-geoip: $*" >&2; }
|
|
23
|
+
|
|
24
|
+
pkg_install() {
|
|
25
|
+
[ -z "${SCALIO_SKIP_PACKAGES:-}" ] || return 0
|
|
26
|
+
if command -v apk >/dev/null 2>&1; then apk add --no-cache "$@"
|
|
27
|
+
else apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends "$@" && rm -rf /var/lib/apt/lists/*
|
|
28
|
+
fi
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
case "$CMD" in
|
|
32
|
+
build)
|
|
33
|
+
if command -v apk >/dev/null 2>&1; then
|
|
34
|
+
pkg_install build-base linux-headers pcre2-dev zlib-dev openssl-dev libmaxminddb-dev curl
|
|
35
|
+
else
|
|
36
|
+
pkg_install build-essential libpcre2-dev zlib1g-dev libssl-dev libmaxminddb-dev curl ca-certificates
|
|
37
|
+
fi
|
|
38
|
+
NGXVER=$(nginx -v 2>&1 | sed 's|.*nginx/||; s| .*||')
|
|
39
|
+
[ -n "$NGXVER" ] || { log "cannot read the nginx version (nginx -v)"; exit 1; }
|
|
40
|
+
log "building ngx_http_geoip2_module $MODVER for nginx $NGXVER"
|
|
41
|
+
W=$(mktemp -d); trap 'rm -rf "$W"' EXIT
|
|
42
|
+
curl -fsSL "https://nginx.org/download/nginx-$NGXVER.tar.gz" | tar xz -C "$W"
|
|
43
|
+
curl -fsSL "https://github.com/leev/ngx_http_geoip2_module/archive/refs/tags/$MODVER.tar.gz" | tar xz -C "$W"
|
|
44
|
+
# The module must be compiled with the flags of the installed nginx, --with-compat keeps the binary interface.
|
|
45
|
+
( cd "$W/nginx-$NGXVER" && ./configure --with-compat --add-dynamic-module="$W/ngx_http_geoip2_module-$MODVER" >/dev/null && make modules >/dev/null )
|
|
46
|
+
mkdir -p "$DIR"
|
|
47
|
+
cp "$W/nginx-$NGXVER/objs/$SO" "$DIR/$SO"
|
|
48
|
+
log "built $DIR/$SO"
|
|
49
|
+
;;
|
|
50
|
+
install)
|
|
51
|
+
[ -f "$DIR/$SO" ] || { log "$DIR/$SO is missing: run 'geoip-module.sh build' in the build stage first"; exit 1; }
|
|
52
|
+
if command -v apk >/dev/null 2>&1; then pkg_install libmaxminddb-libs; else pkg_install libmaxminddb0; fi
|
|
53
|
+
mkdir -p "$MODULES_DIR"
|
|
54
|
+
cp "$DIR/$SO" "$MODULES_DIR/$SO"
|
|
55
|
+
CONF="$NGINX_DIR/nginx.conf"
|
|
56
|
+
if ! grep -q 'ngx_http_geoip2_module' "$CONF"; then
|
|
57
|
+
{ echo "load_module modules/$SO;"; cat "$CONF"; } > "$CONF.new" && mv "$CONF.new" "$CONF"
|
|
58
|
+
fi
|
|
59
|
+
if [ -f "$DIR/dbip-country.mmdb" ]; then
|
|
60
|
+
mkdir -p "$NGINX_DIR/geoip"
|
|
61
|
+
cp "$DIR/dbip-country.mmdb" "$NGINX_DIR/geoip/dbip-country.mmdb"
|
|
62
|
+
log "installed the module and the country database"
|
|
63
|
+
else
|
|
64
|
+
log "module installed, but no country database (geoip-db.sh failed or was not run): ALLOWED_COUNTRIES will not work"
|
|
65
|
+
fi
|
|
66
|
+
;;
|
|
67
|
+
*) echo "usage: geoip-module.sh build|install DIR" >&2; exit 2 ;;
|
|
68
|
+
esac
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.95.0",
|
|
4
4
|
"description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"private": false,
|
package/react/mail.js
CHANGED
|
@@ -306,6 +306,17 @@ function select(id, value, options, onChange, extra) {
|
|
|
306
306
|
// With scalio-platform 0.45.0 the status names a `reason` when the app can not set the send right itself: the button
|
|
307
307
|
// «Senderecht setzen» stays visible but greyed out with that reason (grantOffHint {read_only, no_exchange, identity}:
|
|
308
308
|
// the app's own texts, e.g. Citadel «Mit Scalio Schreiben setzt Citadel das Senderecht selbst»).
|
|
309
|
+
// With scalio-platform 0.60.0 settings and the test mail answer carry from_name_applies, from_name_hint and
|
|
310
|
+
// from_name_hint_de: when applies is false (e.g. Microsoft 365 sends with the mailbox's display name) the sender name
|
|
311
|
+
// has no effect; the field is locked and the hint shown. Without these fields (older backends) nothing changes.
|
|
312
|
+
function pickNameInfo(src) {
|
|
313
|
+
return { applies: src.from_name_applies !== false, hint: src.from_name_hint || "", hint_de: src.from_name_hint_de || "" };
|
|
314
|
+
}
|
|
315
|
+
function nameHintText(info, lang) {
|
|
316
|
+
if (!info || info.applies) return "";
|
|
317
|
+
return (lang === "en" ? info.hint : info.hint_de || info.hint) || (lang === "en" ? info.hint_de : info.hint) || "";
|
|
318
|
+
}
|
|
319
|
+
|
|
309
320
|
function settlingTime(iso, lang) {
|
|
310
321
|
const d = new Date(iso);
|
|
311
322
|
if (isNaN(d.getTime())) return iso;
|
|
@@ -327,6 +338,7 @@ function MailTransport(props) {
|
|
|
327
338
|
const [scriptMsg, setScriptMsg] = React.useState(null);
|
|
328
339
|
const [rightsInfo, setRightsInfo] = React.useState(null); // {mode, state, detail, sender} (scalio-platform 0.43.0)
|
|
329
340
|
const [granting, setGranting] = React.useState(false);
|
|
341
|
+
const [nameInfo, setNameInfo] = React.useState(null); // from_name_* of the last test mail answer (scalio-platform 0.60.0)
|
|
330
342
|
const [mbxList, setMbxList] = React.useState(null); // shared mailboxes of the chosen tenant, or null
|
|
331
343
|
const [mbxOther, setMbxOther] = React.useState(false);
|
|
332
344
|
const [testOk, setTestOk] = React.useState(false);
|
|
@@ -428,6 +440,7 @@ function MailTransport(props) {
|
|
|
428
440
|
setTestMsg(null);
|
|
429
441
|
try {
|
|
430
442
|
const r = await client.test(to.trim());
|
|
443
|
+
if (r && typeof r.from_name_applies === "boolean") setNameInfo(pickNameInfo(r));
|
|
431
444
|
const text = L.testSent.replace("{to}", (r && r.to) || to);
|
|
432
445
|
setTestOk(true);
|
|
433
446
|
if (props.notify) props.notify(text, "success");
|
|
@@ -487,6 +500,9 @@ function MailTransport(props) {
|
|
|
487
500
|
const providers = (form.providers || ["off", "smtp", "graph"]).filter((id) => L.providers[id]);
|
|
488
501
|
// ADR 0090: the default from Compass or the installation (scalio-platform 0.19.0); never a secret in it
|
|
489
502
|
const dflt = form.default || null;
|
|
503
|
+
const nameInfoNow = nameInfo || (typeof form.from_name_applies === "boolean" ? pickNameInfo(form) : null);
|
|
504
|
+
const nameLocked = !!(nameInfoNow && !nameInfoNow.applies);
|
|
505
|
+
const nameHint = nameHintText(nameInfoNow, lang);
|
|
490
506
|
const defaultUsable = !!(dflt && dflt.available);
|
|
491
507
|
const defaultBlock = () => {
|
|
492
508
|
if (!defaultUsable) return h("div", { className: "scalio-notice is-info", "data-testid": "mail-default-none" }, L.defaultNone);
|
|
@@ -497,6 +513,7 @@ function MailTransport(props) {
|
|
|
497
513
|
h("p", { className: "scalio-field-label" }, `${L.defaultFrom[dflt.source] || L.defaultFrom.compass}: ${L.defaultWays[dflt.provider] || dflt.provider}`),
|
|
498
514
|
h("dl", { className: "scalio-mail-default-facts" },
|
|
499
515
|
facts.filter((f) => f[1]).map((f) => h(React.Fragment, { key: f[0] }, h("dt", null, f[0]), h("dd", null, f[1])))),
|
|
516
|
+
nameHint ? h("p", { className: "scalio-settings-help", "data-testid": "mail-from-name-hint" }, nameHint) : null,
|
|
500
517
|
h("p", { className: "scalio-settings-help" }, L.defaultHint));
|
|
501
518
|
};
|
|
502
519
|
const transport = h(
|
|
@@ -520,7 +537,8 @@ function MailTransport(props) {
|
|
|
520
537
|
: null,
|
|
521
538
|
form.provider !== "off" && form.provider !== "default"
|
|
522
539
|
? h("div", { className: "scalio-mail-grid" },
|
|
523
|
-
h(Field, { id: "mail-from-name", label: L.fromName
|
|
540
|
+
h(Field, { id: "mail-from-name", label: L.fromName, hint: nameHint || undefined },
|
|
541
|
+
input("mail-from-name", form.from_name, (v) => set({ from_name: v }), { maxLength: 80, disabled: busy || nameLocked })),
|
|
524
542
|
form.provider === "smtp"
|
|
525
543
|
? h(Field, { id: "mail-from", label: L.fromAddress }, input("mail-from", form.from_address, (v) => set({ from_address: v }),
|
|
526
544
|
{ type: "email", maxLength: 254, placeholder: "noreply@example.com", disabled: busy }))
|