@scalio-cloud/ui 0.92.0 → 0.93.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 +18 -0
- package/nginx/access-limit.sh +24 -2
- package/package.json +1 -1
- package/react/access_limit.js +66 -0
- package/react/index.js +1 -1
- package/react/labels.js +37 -0
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ server {
|
|
|
80
80
|
| `TRUSTED_PROXIES` | Proxies whose `X-Forwarded-For` counts (Caddy, Azure front end); the last entry is used |
|
|
81
81
|
| `SCALIO_APP` | App name (`nexus`, …) for the app-specific machine paths |
|
|
82
82
|
| `SCALIO_GEOIP_DB` | Country database, default `/etc/nginx/geoip/dbip-country.mmdb` |
|
|
83
|
+
| `SCALIO_ACCESS_STATUS` | Public status file, default `/usr/share/nginx/html/access-status.json` (from 0.93.0) |
|
|
83
84
|
|
|
84
85
|
Both lists empty: no limit (both files stay empty). An address passes if it is in the IP list or its country is
|
|
85
86
|
allowed. An invalid entry closes the instance for everyone except the machine paths and names the entry in the log
|
|
@@ -88,6 +89,23 @@ allowed. An invalid entry closes the instance for everyone except the machine pa
|
|
|
88
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»
|
|
89
90
|
on the about page). Tests (`test/access.test.js`) run with real nginx when it is installed.
|
|
90
91
|
|
|
92
|
+
### Show the limit in the settings: `AccessLimitStatus` (React, from 0.93.0)
|
|
93
|
+
|
|
94
|
+
At start the script also writes `access-status.json` into the web root (nginx serves it like any static file):
|
|
95
|
+
`{ "active": true, "ip_ranges": 3, "countries": ["CH", "DE"], "countries_unavailable": false, "invalid": false }`.
|
|
96
|
+
Only numbers and country codes, never an IP address. `countries_unavailable`: countries set but no database or geoip2
|
|
97
|
+
module (only the IP list counts); `invalid`: a wrong entry closed the instance. A file that cannot be written only
|
|
98
|
+
logs a line; the settings then show «Status nicht verfügbar». The component reads it (read only, changing happens in
|
|
99
|
+
Scalio Compass) and belongs in Einstellungen -> Sicherheit:
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
import { AccessLimitStatus } from "@scalio-cloud/ui/react";
|
|
103
|
+
<AccessLimitStatus lang={lang} /> // props: status (skips the request), url, fetcher, labels
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Test ids: `access-limit`, `access-limit-state`, `access-limit-ips`, `access-limit-countries`, `access-limit-warn`.
|
|
107
|
+
`accessLimitState(data)` returns `off`, `on`, `partial`, `invalid` or `null`. Texts: `LABELS.<lang>.accessLimit`.
|
|
108
|
+
|
|
91
109
|
## Sign-in state (React, from 0.37.0)
|
|
92
110
|
|
|
93
111
|
`createAuth({ api, formatError, signInWithPasskey, passkeyCancelled, legacyTokenKey })` gives `{ AuthProvider,
|
package/nginx/access-limit.sh
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
# loaded in nginx.conf (load_module, or modules/*.conf as in the Alpine package)
|
|
9
9
|
# TRUSTED_PROXIES CIDR list of the proxy in front (Caddy network, Azure ingress); its X-Forwarded-For counts
|
|
10
10
|
# SCALIO_APP nexus, citadel, … : picks the app's machine paths (machine-paths.txt)
|
|
11
|
+
# SCALIO_ACCESS_STATUS public status file for the settings page, default /usr/share/nginx/html/access-status.json
|
|
12
|
+
# (active yes/no, number of IP ranges, countries; never an address); cannot be written: only a log line
|
|
11
13
|
# SCALIO_GEOIP_DB country database (DB-IP «IP to Country Lite», mmdb); default /etc/nginx/geoip/dbip-country.mmdb
|
|
12
14
|
#
|
|
13
15
|
# Allowed is who is in the IP list OR in an allowed country; machine paths stay open. Everyone else gets 403 with a
|
|
@@ -25,6 +27,7 @@ PATHS_FILE="${SCALIO_MACHINE_PATHS_FILE:-$(dirname "$0")/machine-paths.txt}"
|
|
|
25
27
|
GEOIP_DB="${SCALIO_GEOIP_DB:-$DIR/geoip/dbip-country.mmdb}"
|
|
26
28
|
NGINX_CONF="${SCALIO_NGINX_CONF:-$DIR/nginx.conf}"
|
|
27
29
|
APP="${SCALIO_APP:-}"
|
|
30
|
+
STATUS_FILE="${SCALIO_ACCESS_STATUS:-/usr/share/nginx/html/access-status.json}"
|
|
28
31
|
|
|
29
32
|
log() { echo "scalio-access: $*" >&2; }
|
|
30
33
|
|
|
@@ -50,6 +53,18 @@ valid_cidr() {
|
|
|
50
53
|
return 0
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
# Public status for the settings (AccessLimitStatus): numbers and country codes only, never an IP address.
|
|
57
|
+
# $1 active (true|false), $2 ip ranges, $3 countries (space separated), $4 countries unavailable, $5 invalid entries
|
|
58
|
+
write_status() {
|
|
59
|
+
cl=""
|
|
60
|
+
for c in $3; do cl="${cl:+$cl, }\"$c\""; done
|
|
61
|
+
if ! { mkdir -p "$(dirname "$STATUS_FILE")" &&
|
|
62
|
+
printf '{"active": %s, "ip_ranges": %s, "countries": [%s], "countries_unavailable": %s, "invalid": %s}\n' \
|
|
63
|
+
"$1" "$2" "$cl" "$4" "$5" > "$STATUS_FILE.tmp" && mv "$STATUS_FILE.tmp" "$STATUS_FILE"; } 2>/dev/null; then
|
|
64
|
+
log "cannot write the status file $STATUS_FILE (the settings page shows no status)"
|
|
65
|
+
fi
|
|
66
|
+
}
|
|
67
|
+
|
|
53
68
|
IPS=$(words "${ALLOWED_CLIENT_IPS:-}")
|
|
54
69
|
COUNTRIES=$(words "${ALLOWED_COUNTRIES:-}" | tr 'a-z' 'A-Z')
|
|
55
70
|
PROXIES=$(words "${TRUSTED_PROXIES:-}")
|
|
@@ -58,27 +73,34 @@ mkdir -p "$(dirname "$HTTP_CONF")" "$(dirname "$SERVER_CONF")"
|
|
|
58
73
|
if [ -z "$IPS" ] && [ -z "$COUNTRIES" ]; then
|
|
59
74
|
: > "$HTTP_CONF"
|
|
60
75
|
: > "$SERVER_CONF"
|
|
76
|
+
write_status false 0 "" false false
|
|
61
77
|
log "no access limit (ALLOWED_CLIENT_IPS and ALLOWED_COUNTRIES empty)"
|
|
62
78
|
exit 0
|
|
63
79
|
fi
|
|
64
80
|
|
|
65
81
|
broken=""
|
|
82
|
+
invalid=false
|
|
66
83
|
for c in $IPS $PROXIES; do valid_cidr "$c" || broken="$broken $c"; done
|
|
67
84
|
for c in $COUNTRIES; do echo "$c" | grep -Eq '^[A-Z]{2}$' || broken="$broken $c"; done
|
|
68
85
|
geo_ok=1
|
|
86
|
+
geo_missing=false
|
|
69
87
|
if [ -n "$COUNTRIES" ] && [ ! -r "$GEOIP_DB" ]; then
|
|
70
|
-
geo_ok=0
|
|
88
|
+
geo_ok=0; geo_missing=true
|
|
71
89
|
log "ALLOWED_COUNTRIES set, but no country database at $GEOIP_DB: only the IP list counts"
|
|
72
90
|
elif [ -n "$COUNTRIES" ] && ! cat "$NGINX_CONF" "$DIR"/modules/*.conf "$DIR"/modules-enabled/*.conf 2>/dev/null \
|
|
73
91
|
| grep -v '^[[:space:]]*#' | grep -q 'ngx_http_geoip2_module'; then
|
|
74
92
|
# Without load_module nginx would refuse the geoip2 block and not start at all.
|
|
75
|
-
geo_ok=0
|
|
93
|
+
geo_ok=0; geo_missing=true
|
|
76
94
|
log "ALLOWED_COUNTRIES set, but the geoip2 module is not loaded ($NGINX_CONF): only the IP list counts"
|
|
77
95
|
fi
|
|
78
96
|
if [ -n "$broken" ]; then
|
|
79
97
|
log "invalid entries:$broken -> access closed for everyone except the machine paths"
|
|
80
98
|
IPS=""; COUNTRIES=""
|
|
99
|
+
invalid=true
|
|
81
100
|
fi
|
|
101
|
+
COUNTRIES_SHOWN="$COUNTRIES"
|
|
102
|
+
[ "$geo_ok" = 1 ] || COUNTRIES_SHOWN=""
|
|
103
|
+
write_status true "$(echo "$IPS" | wc -w | tr -d ' ')" "$COUNTRIES_SHOWN" "$geo_missing" "$invalid"
|
|
82
104
|
|
|
83
105
|
{
|
|
84
106
|
echo "# Written by scalio-access (@scalio-cloud/ui nginx/access-limit.sh) at container start. Do not edit."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.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,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Einstellungen -> Sicherheit: shows the IP and country limit of the instance (scalio-docs ADR 0085, zugang/Z1).
|
|
3
|
+
// nginx/access-limit.sh writes /access-status.json at container start:
|
|
4
|
+
// { active, ip_ranges, countries: ["CH"], countries_unavailable?, invalid? } (numbers and codes, never an address)
|
|
5
|
+
// Read only: the limit is set in Scalio Compass (ALLOWED_CLIENT_IPS / ALLOWED_COUNTRIES), not here.
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const h = React.createElement;
|
|
8
|
+
const { labelsFor } = require("./labels");
|
|
9
|
+
const { StatusBadge, Notice } = require("./blocks");
|
|
10
|
+
const { SettingsSection, SettingsRow } = require("./settings");
|
|
11
|
+
|
|
12
|
+
// -> null (unknown) | { kind: "off" | "on" | "partial" | "invalid", ipRanges, countries }
|
|
13
|
+
function accessLimitState(data) {
|
|
14
|
+
if (!data || typeof data.active !== "boolean") return null;
|
|
15
|
+
const countries = (Array.isArray(data.countries) ? data.countries : [])
|
|
16
|
+
.filter((c) => typeof c === "string" && c).map((c) => c.toUpperCase());
|
|
17
|
+
const n = Number(data.ip_ranges);
|
|
18
|
+
const ipRanges = Number.isFinite(n) && n > 0 ? Math.floor(n) : 0;
|
|
19
|
+
if (!data.active) return { kind: "off", ipRanges: 0, countries: [] };
|
|
20
|
+
const kind = data.invalid ? "invalid" : data.countries_unavailable ? "partial" : "on";
|
|
21
|
+
return { kind, ipRanges, countries };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Props: status (the parsed file; skips the request), url (default /access-status.json), fetcher (tests), lang, labels.
|
|
25
|
+
function AccessLimitStatus(props) {
|
|
26
|
+
const L = labelsFor(props.lang, props.labels).accessLimit;
|
|
27
|
+
const [data, setData] = React.useState(props.status || null);
|
|
28
|
+
const [loaded, setLoaded] = React.useState(!!props.status);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
if (props.status) { setData(props.status); setLoaded(true); return undefined; }
|
|
31
|
+
let alive = true;
|
|
32
|
+
const get = props.fetcher || (typeof fetch === "function" ? fetch : null);
|
|
33
|
+
const done = (d) => { if (alive) { setData(d); setLoaded(true); } };
|
|
34
|
+
if (!get) { done(null); return undefined; }
|
|
35
|
+
Promise.resolve()
|
|
36
|
+
.then(() => get(props.url || "/access-status.json", { cache: "no-store", headers: { Accept: "application/json" } }))
|
|
37
|
+
.then((r) => (r && r.ok ? r.json() : null))
|
|
38
|
+
.then(done, () => done(null));
|
|
39
|
+
return () => { alive = false; };
|
|
40
|
+
}, [props.status, props.url, props.fetcher]);
|
|
41
|
+
|
|
42
|
+
const s = accessLimitState(data);
|
|
43
|
+
const text = !loaded ? L.loading : !s ? L.unknown : s.kind === "off" ? L.off : L.on;
|
|
44
|
+
const tone = !s ? "neutral" : s.kind === "off" ? "neutral" : s.kind === "on" ? "ok" : "warn";
|
|
45
|
+
const ips = s && s.ipRanges === 1 ? L.ipOne : (L.ipMany || "").replace("{n}", s ? s.ipRanges : 0);
|
|
46
|
+
return h(
|
|
47
|
+
SettingsSection,
|
|
48
|
+
{ id: "access-limit", title: L.title, description: L.hint, testId: "access-limit" },
|
|
49
|
+
h(SettingsRow, { title: L.state }, h(StatusBadge, { tone, testId: "access-limit-state" }, text)),
|
|
50
|
+
s && s.kind !== "off"
|
|
51
|
+
? h(
|
|
52
|
+
"div",
|
|
53
|
+
{ className: "scalio-settings-form" },
|
|
54
|
+
h(SettingsRow, { title: L.ips }, h("span", { "data-testid": "access-limit-ips" }, ips)),
|
|
55
|
+
h(SettingsRow, { title: L.countries },
|
|
56
|
+
h("span", { "data-testid": "access-limit-countries" }, s.countries.length ? s.countries.join(", ") : L.none)),
|
|
57
|
+
h("p", { className: "scalio-settings-help", "data-testid": "access-limit-machine" }, L.machine),
|
|
58
|
+
s.kind === "invalid" ? h(Notice, { kind: "error", testId: "access-limit-warn", lang: props.lang, labels: props.labels }, L.invalid) : null,
|
|
59
|
+
s.kind === "partial" ? h(Notice, { kind: "warn", testId: "access-limit-warn", lang: props.lang, labels: props.labels }, L.noCountryDb) : null
|
|
60
|
+
)
|
|
61
|
+
: null,
|
|
62
|
+
h("p", { className: "scalio-settings-help", "data-testid": "access-limit-where" }, L.where)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { AccessLimitStatus, accessLimitState };
|
package/react/index.js
CHANGED
|
@@ -386,6 +386,6 @@ module.exports = {
|
|
|
386
386
|
TEST_IDS,
|
|
387
387
|
initials,
|
|
388
388
|
};
|
|
389
|
-
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./limited_mode"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"));
|
|
389
|
+
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./limited_mode"), require("./access_limit"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"));
|
|
390
390
|
// After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
|
|
391
391
|
Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
|
package/react/labels.js
CHANGED
|
@@ -503,6 +503,24 @@ const LABELS = {
|
|
|
503
503
|
setUpFactor: "Zum Profil",
|
|
504
504
|
run: "Auf Werkseinstellungen zurücksetzen",
|
|
505
505
|
},
|
|
506
|
+
accessLimit: {
|
|
507
|
+
title: "Zugriff eingrenzen",
|
|
508
|
+
hint: "Wer diese Instanz öffnen darf: nach IP-Adresse oder Land.",
|
|
509
|
+
state: "Stand",
|
|
510
|
+
loading: "Wird geladen …",
|
|
511
|
+
unknown: "Status nicht verfügbar",
|
|
512
|
+
off: "Keine Eingrenzung: jede Adresse darf zugreifen",
|
|
513
|
+
on: "Eingegrenzt",
|
|
514
|
+
ips: "Erlaubte IP-Bereiche",
|
|
515
|
+
ipOne: "1 IP-Bereich",
|
|
516
|
+
ipMany: "{n} IP-Bereiche",
|
|
517
|
+
countries: "Erlaubte Länder",
|
|
518
|
+
none: "Keine",
|
|
519
|
+
machine: "Maschinen-Pfade (Health, Version, Provisionierung) bleiben immer offen. Wer weder in einem IP-Bereich noch in einem erlaubten Land ist, sieht eine Seite «Zugriff nicht freigegeben».",
|
|
520
|
+
invalid: "Ein Eintrag der Eingrenzung ist ungültig. Aus Sicherheitsgründen ist der Zugriff für alle gesperrt, bis der Eintrag in Scalio Compass korrigiert ist.",
|
|
521
|
+
noCountryDb: "Die Länderdatenbank ist in dieser Instanz nicht verfügbar. Es gelten nur die IP-Bereiche; die Länder sind noch nicht wirksam.",
|
|
522
|
+
where: "Die Eingrenzung ändern Sie in Scalio Compass unter «Zugriff eingrenzen». Die Änderung gilt nach dem nächsten Start der Instanz. Die IP-Adressen selbst werden hier nicht angezeigt.",
|
|
523
|
+
},
|
|
506
524
|
limitedMode: {
|
|
507
525
|
license: "Lizenz",
|
|
508
526
|
limitedTitle: "Eingeschränkter Modus: nur lesen",
|
|
@@ -1088,6 +1106,24 @@ const LABELS = {
|
|
|
1088
1106
|
setUpFactor: "Go to profile",
|
|
1089
1107
|
run: "Reset to factory settings",
|
|
1090
1108
|
},
|
|
1109
|
+
accessLimit: {
|
|
1110
|
+
title: "Restrict access",
|
|
1111
|
+
hint: "Who may open this instance: by IP address or country.",
|
|
1112
|
+
state: "Status",
|
|
1113
|
+
loading: "Loading …",
|
|
1114
|
+
unknown: "Status not available",
|
|
1115
|
+
off: "No restriction: every address may connect",
|
|
1116
|
+
on: "Restricted",
|
|
1117
|
+
ips: "Allowed IP ranges",
|
|
1118
|
+
ipOne: "1 IP range",
|
|
1119
|
+
ipMany: "{n} IP ranges",
|
|
1120
|
+
countries: "Allowed countries",
|
|
1121
|
+
none: "None",
|
|
1122
|
+
machine: "Machine paths (health, version, provisioning) always stay open. Anyone outside the IP ranges and the allowed countries sees an «Access not allowed» page.",
|
|
1123
|
+
invalid: "An entry of the restriction is invalid. For safety access is closed for everyone until the entry is corrected in Scalio Compass.",
|
|
1124
|
+
noCountryDb: "The country database is not available in this instance. Only the IP ranges apply; the countries are not effective yet.",
|
|
1125
|
+
where: "Change the restriction in Scalio Compass under «Restrict access». It applies after the next start of the instance. The IP addresses themselves are not shown here.",
|
|
1126
|
+
},
|
|
1091
1127
|
limitedMode: {
|
|
1092
1128
|
license: "License",
|
|
1093
1129
|
limitedTitle: "Limited mode: read-only",
|
|
@@ -1190,6 +1226,7 @@ function labelsFor(lang, overrides) {
|
|
|
1190
1226
|
mfa: Object.assign({}, base.mfa, o.mfa),
|
|
1191
1227
|
users: Object.assign({}, base.users, o.users),
|
|
1192
1228
|
license: Object.assign({}, base.license, o.license),
|
|
1229
|
+
accessLimit: Object.assign({}, base.accessLimit, o.accessLimit),
|
|
1193
1230
|
limitedMode: Object.assign({}, base.limitedMode, o.limitedMode, { units: Object.assign({}, base.limitedMode.units, (o.limitedMode || {}).units) }),
|
|
1194
1231
|
edition: Object.assign({}, base.edition, o.edition),
|
|
1195
1232
|
accountTabs: Object.assign({}, base.accountTabs, o.accountTabs),
|