feat(worldapi): one-click NexGroups land API key setup (#275)
Add dedicated groups:read land-key checkbox and standalone secure one-click issue action to the World API control center, preserve admin HTTPS and duplicate protection, emit NEXVERSE_GROUP_LAND_API_KEY for protected simulator env setup, and cover setup isolation plus key persistence in CI.
This commit is contained in:
1 parent
bd6bf4f28c
commit
7396897d3d
7 files changed
+140
-14
No files matched your search
@@ -365,6 +365,10 @@ jobs:
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_nexgroups_security.py
|
||||
|
||||
- name: Verify one-click World API group land key issuance
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_worldapi_group_land_key_setup.py
|
||||
|
||||
- name: Verify Firestorm Experience acquire and editor security
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_experience_viewer_purchase.py
|
||||
|
||||
@@ -608,6 +608,7 @@ Archivprüfungen bleiben auch für freigegebene Importe aktiv.</div>
|
||||
<p class="sectionlead">Bereits eingerichtete Schlüssel nicht unnötig neu erzeugen. Neue API-Schlüssel bleiben zusätzlich zu bestehenden registriert, bis sie ausdrücklich deaktiviert werden.</p>
|
||||
<div class="changegrid">
|
||||
<label class="change"><input type="checkbox" id="secretEconomy" style="width:auto" /> <strong>Economy / NV$</strong><p><code>economy:read</code> und <code>economy:transfer</code>. Nur auswählen, wenn noch kein gültiger Economy-Key existiert.</p></label>
|
||||
<label class="change"><input type="checkbox" id="secretGroupLand" style="width:auto" /> <strong>NexGroups / Gridweite Landabfrage</strong><p><code>groups:read</code>. Eigener Simulator-Dienstschlüssel ausschließlich für die gruppeneigene Parzellensuche über die World API.</p></label>
|
||||
<label class="change"><input type="checkbox" id="secretExperiences" checked style="width:auto" /> <strong>Experiences / Script</strong><p><code>experiences:script</code>. Eigener Schlüssel für die Simulator-LSL-Funktionen.</p></label>
|
||||
<label class="change"><input type="checkbox" id="secretExperiencePermissions" style="width:auto" /> <strong>Experiences / Firestorm-Rechte</strong><p><code>experiences:viewer:permissions</code>. Separater Service-Schlüssel für Firestorm Allow/Block/Forget; nur für kontrolliert aktivierte Permission-CAPS.</p></label>
|
||||
<label class="change"><input type="checkbox" id="secretExperienceManage" style="width:auto" /> <strong>Experiences / Firestorm-Erwerb und Editor</strong><p><code>experiences:viewer:manage</code>. Eigenständiger privilegierter Simulator-Service-Schlüssel für „Erlebnis erwerben“ und die Bearbeitung eigener Experiences; nicht mit anderen Scopes kombinieren.</p></label>
|
||||
@@ -616,8 +617,10 @@ Archivprüfungen bleiben auch für freigegebene Importe aktiv.</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top:14px;flex-wrap:wrap">
|
||||
<button class="action" id="secretGenerateRegistration">Nur Registrierungs-API-Key erstellen</button>
|
||||
<button class="action" id="secretGenerateGroupLand">Nur Gruppenland-API-Key erstellen</button>
|
||||
</div>
|
||||
<p class="authnote">Für die Stadtportal-Registrierung genügt dieser einzelne Schlüssel. Der Button ignoriert die Vorauswahl für Experiences und NexBus und verlangt keine NexBus-URLs. <code>NEXVERSE_REGISTER_API_KEY</code> gehört ausschließlich in die geschützte Umgebung des Stadtportal-Backends, niemals in Browser-JavaScript oder auf öffentliche Seiten.</p>
|
||||
<p class="authnote">Der Gruppenland-Button erstellt ausschließlich <code>groups:read</code>, unabhängig von den anderen Häkchen und ohne NexBus-URLs. <code>NEXVERSE_GROUP_LAND_API_KEY</code> gehört nur in die geschützte Environment-Datei der Simulatoren. Bereits aktive Schlüssel werden vor einer Neuausstellung geprüft.</p>
|
||||
<p class="authnote">Der NexBus-SharedKey ist kein World-API-Key. Er wird lokal im Browser per kryptografisch sicherem Zufall erzeugt und muss auf allen beteiligten Nodes identisch sein.</p>
|
||||
<div class="grid2">
|
||||
<div><label class="label2" for="secretPeerUrl">Simulator → Robust (NexBus-URL)</label><input id="secretPeerUrl" autocomplete="off" spellcheck="false" placeholder="https://intern.example/internal/nexbus/v1/events"></div>
|
||||
@@ -1687,7 +1690,8 @@ function secretValidateEndpoint(text) {
|
||||
return url.href;
|
||||
}
|
||||
function secretBuildLines(values) {
|
||||
const names=['NEXVERSE_REGISTER_API_KEY','NEXVERSE_ECONOMY_API_KEY','NEXVERSE_EXPERIENCES_API_KEY',
|
||||
const names=['NEXVERSE_REGISTER_API_KEY','NEXVERSE_ECONOMY_API_KEY',
|
||||
'NEXVERSE_GROUP_LAND_API_KEY','NEXVERSE_EXPERIENCES_API_KEY',
|
||||
'NEXVERSE_EXPERIENCES_VIEWER_PERMISSIONS_API_KEY',
|
||||
'NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY',
|
||||
'NEXVERSE_NEXBUS_SHARED_KEY','NEXVERSE_NEXBUS_PEER_URL','NEXVERSE_NEXBUS_PEERS'];
|
||||
@@ -1787,20 +1791,23 @@ async function secretAdminToken() {
|
||||
return token;
|
||||
}
|
||||
let secretIssuePending=false;
|
||||
async function secretGenerate(onlyRegistration=false) {
|
||||
async function secretGenerate(onlyRegistration=false, onlyGroupLand=false) {
|
||||
if(secretIssuePending)return;
|
||||
const wantRegister=onlyRegistration||$('secretRegister').checked;
|
||||
const wantEconomy=!onlyRegistration&&$('secretEconomy').checked;
|
||||
const wantExperiences=!onlyRegistration&&$('secretExperiences').checked;
|
||||
const wantPermissions=!onlyRegistration&&$('secretExperiencePermissions').checked;
|
||||
const wantManage=!onlyRegistration&&$('secretExperienceManage').checked;
|
||||
const wantBus=!onlyRegistration&&$('secretNexBus').checked;
|
||||
if(!wantRegister&&!wantEconomy&&!wantExperiences&&!wantPermissions&&!wantManage&&!wantBus){
|
||||
const onlyOne=onlyRegistration||onlyGroupLand;
|
||||
const wantRegister=onlyRegistration||(!onlyOne&&$('secretRegister').checked);
|
||||
const wantGroupLand=onlyGroupLand||(!onlyOne&&$('secretGroupLand').checked);
|
||||
const wantEconomy=!onlyOne&&$('secretEconomy').checked;
|
||||
const wantExperiences=!onlyOne&&$('secretExperiences').checked;
|
||||
const wantPermissions=!onlyOne&&$('secretExperiencePermissions').checked;
|
||||
const wantManage=!onlyOne&&$('secretExperienceManage').checked;
|
||||
const wantBus=!onlyOne&&$('secretNexBus').checked;
|
||||
if(!wantRegister&&!wantGroupLand&&!wantEconomy&&!wantExperiences&&!wantPermissions&&!wantManage&&!wantBus){
|
||||
secretStatus('Bitte mindestens einen Schlüssel auswählen.',false);return;
|
||||
}
|
||||
secretIssuePending=true;
|
||||
$('secretGenerate').disabled=true;
|
||||
$('secretGenerateRegistration').disabled=true;
|
||||
$('secretGenerateGroupLand').disabled=true;
|
||||
const values={};
|
||||
let peers=[];
|
||||
let peerUrl='';
|
||||
@@ -1815,6 +1822,8 @@ async function secretGenerate(onlyRegistration=false) {
|
||||
const plan=[
|
||||
{wanted:wantRegister,name:'OGL Stadtportal Registrierung',
|
||||
scopes:['users:register'],env:'NEXVERSE_REGISTER_API_KEY'},
|
||||
{wanted:wantGroupLand,name:'OGL Simulator Group Land',
|
||||
scopes:['groups:read'],env:'NEXVERSE_GROUP_LAND_API_KEY'},
|
||||
{wanted:wantEconomy,name:'OGL Simulator Economy',
|
||||
scopes:['economy:read','economy:transfer'],env:'NEXVERSE_ECONOMY_API_KEY'},
|
||||
{wanted:wantExperiences,name:'OGL Simulator Experiences',
|
||||
@@ -1839,6 +1848,8 @@ async function secretGenerate(onlyRegistration=false) {
|
||||
}
|
||||
if(!window.confirm(onlyRegistration?
|
||||
'Neuen dedizierten Registrierungs-API-Key (nur users:register) für das Stadtportal-Backend erstellen?':
|
||||
onlyGroupLand?
|
||||
'Neuen dedizierten Gruppenland-API-Key (nur groups:read) für die Simulatoren erstellen?':
|
||||
'Neue Maschinen-API-Schlüssel werden sofort serverseitig registriert. Erstellung starten?'))return;
|
||||
$('secretCopy').disabled=true;
|
||||
$('secretOutput').value='';
|
||||
@@ -1864,6 +1875,8 @@ async function secretGenerate(onlyRegistration=false) {
|
||||
}
|
||||
secretStatus(onlyRegistration?
|
||||
'Registrierungs-API-Key erstellt. NEXVERSE_REGISTER_API_KEY jetzt ausschließlich ins Stadtportal-Backend kopieren.':
|
||||
onlyGroupLand?
|
||||
'Gruppenland-API-Key erstellt. NEXVERSE_GROUP_LAND_API_KEY jetzt in die geschützte Simulator-Environment-Datei kopieren.':
|
||||
'Alle ausgewählten Schlüssel erstellt. Konfigurationsblock jetzt sicher kopieren.',true);
|
||||
if(plan.length)await secretLoadKeys();
|
||||
}catch(err){
|
||||
@@ -1874,6 +1887,7 @@ async function secretGenerate(onlyRegistration=false) {
|
||||
secretIssuePending=false;
|
||||
$('secretGenerate').disabled=false;
|
||||
$('secretGenerateRegistration').disabled=false;
|
||||
$('secretGenerateGroupLand').disabled=false;
|
||||
}
|
||||
}
|
||||
async function secretCopy() {
|
||||
@@ -1964,6 +1978,7 @@ $('adminLoginPassword').addEventListener('keydown',event=>{if(event.key==='Enter
|
||||
$('adminLoginTotp').addEventListener('keydown',event=>{if(event.key==='Enter'){event.preventDefault();adminLogin()}});
|
||||
$('secretGenerate').addEventListener('click',()=>secretGenerate());
|
||||
$('secretGenerateRegistration').addEventListener('click',()=>secretGenerate(true));
|
||||
$('secretGenerateGroupLand').addEventListener('click',()=>secretGenerate(false,true));
|
||||
$('secretCopy').addEventListener('click',secretCopy);
|
||||
$('secretClear').addEventListener('click',secretClear);
|
||||
$('secretLoadKeys').addEventListener('click',secretLoadKeys);
|
||||
|
||||
@@ -12,6 +12,9 @@ NEXVERSE_NATIVE_TOKEN_SIGNING_KEY=
|
||||
# SIMULATOR: dedizierte Machine API Keys, nicht auf Robust publizieren.
|
||||
# Die Gueltigkeit und Scopes werden zentral im World API Key Store verwaltet.
|
||||
NEXVERSE_ECONOMY_API_KEY=
|
||||
# Gruppenland-Verzeichnis, ausschließlich groups:read.
|
||||
# Über /api/v1/docs -> Schlüssel & Einrichtung -> Nur Gruppenland-API-Key erstellen.
|
||||
NEXVERSE_GROUP_LAND_API_KEY=
|
||||
NEXVERSE_EXPERIENCES_API_KEY=
|
||||
# Firestorm Allow/Block/Forget: NUR bei kontrolliert aktiviertem
|
||||
# [NexExperiencesViewer] FirestormPermissionCaps=true.
|
||||
|
||||
@@ -36,6 +36,28 @@ expliziten Scope `groups:read` für die Simulator-Landverzeichnisse
|
||||
erstellen. Nicht das Admin-Token und keinen Avatar-Token verwenden.
|
||||
Dieser Schlüssel muss nur für den Simulator erreichbar sein.
|
||||
|
||||
**Ein-Klick-Erstellung im World-API-Control-Center:**
|
||||
|
||||
1. `https://world.stadt-nexverse.de/api/v1/docs` über HTTPS öffnen,
|
||||
unter **Admin-Anmeldung** mit einem Administrator (UserLevel mindestens
|
||||
200, `admin:*`) anmelden.
|
||||
2. Unter **Schlüssel & Einrichtung** auf **Nur Gruppenland-API-Key erstellen**
|
||||
klicken. Die anderen Vorauswahlen für Experiences/NexBus werden
|
||||
ignoriert; NexBus-URLs sind dafür nicht erforderlich.
|
||||
3. Den Hinweis bestätigen. Die World API erstellt nur einen Schlüssel
|
||||
namens `OGL Simulator Group Land` mit exakt `groups:read` und zeigt
|
||||
`NEXVERSE_GROUP_LAND_API_KEY=<generierter Schlüssel>` zum Kopieren.
|
||||
4. Die Zeile in `/etc/nexverse/nexverse.env` auf **jedem betroffenen
|
||||
Simulator-Host** speichern, Dateiberechtigungen auf `600` setzen
|
||||
und den Simulator neu starten.
|
||||
|
||||
Alternativ die Checkbox **NexGroups / Gridweite Landabfrage** im
|
||||
Mehrfachgenerator auswählen. Bereits vorhandene aktive Schlüssel mit
|
||||
gleichem Namen und denselben Scopes werden erkannt und nicht
|
||||
überschrieben. Verlorene API-Secrets lassen sich nicht erneut anzeigen:
|
||||
für eine Rotation den bisherigen Schlüssel gezielt deaktivieren und einen
|
||||
neuen ausstellen. Keine Schlüssel ins Git-Repository committen.
|
||||
|
||||
Im Simulator:
|
||||
|
||||
```ini
|
||||
|
||||
@@ -83,6 +83,26 @@ internal static class Program
|
||||
out _),
|
||||
"disabled API key remained valid");
|
||||
|
||||
// Dedicated groups:read-only simulator key must be accepted,
|
||||
// persisted and must not accidentally obtain finance/admin scopes.
|
||||
NexApiKeyRegistration groupLand = reloaded.Create(
|
||||
"OGL Simulator Group Land",
|
||||
new[] { NexScopes.GroupsRead });
|
||||
Require(
|
||||
reloaded.TryValidate(groupLand.ApiKey,
|
||||
out NexApiKeyRecord groupLandRecord) &&
|
||||
groupLandRecord.Scopes.Length == 1 &&
|
||||
string.Equals(groupLandRecord.Scopes[0],
|
||||
NexScopes.GroupsRead, StringComparison.OrdinalIgnoreCase),
|
||||
"Group land API key did not retain exactly groups:read");
|
||||
PersistentNexApiKeyStore groupsReloaded =
|
||||
new PersistentNexApiKeyStore(path);
|
||||
Require(groupsReloaded.TryValidate(groupLand.ApiKey,
|
||||
out NexApiKeyRecord persistedLand) &&
|
||||
persistedLand.Scopes.Length == 1 &&
|
||||
persistedLand.Scopes[0] == NexScopes.GroupsRead,
|
||||
"Group land API key did not survive restart with least privilege");
|
||||
|
||||
bool rejectedAdmin = false;
|
||||
try
|
||||
{
|
||||
@@ -211,7 +231,7 @@ internal static class Program
|
||||
}
|
||||
catch (InvalidOperationException) { rejectedDuplicate = true; }
|
||||
Require(rejectedDuplicate, "Duplicate enabled service key accepted");
|
||||
Require(experiencesReloaded.List().Count == 4,
|
||||
Require(experiencesReloaded.List().Count == 5,
|
||||
"Duplicate rejection modified the persistent key inventory");
|
||||
|
||||
// Deletion is an irreversible second step after explicit disable.
|
||||
@@ -241,7 +261,7 @@ internal static class Program
|
||||
"Last-used metadata lost when cloning records");
|
||||
PersistentNexApiKeyStore afterCleanup =
|
||||
new PersistentNexApiKeyStore(path);
|
||||
Require(afterCleanup.List().Count == 4 &&
|
||||
Require(afterCleanup.List().Count == 5 &&
|
||||
afterCleanup.TryValidate(replacement.ApiKey, out _),
|
||||
"Key cleanup or replacement did not survive restart");
|
||||
|
||||
|
||||
@@ -92,15 +92,15 @@ for marker in ('data-page="adminlogin"','id="page-adminlogin"','id="adminLoginPa
|
||||
assert 'id="secretExperienceManage"' in ui
|
||||
assert "'NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY'" in ui
|
||||
assert "scopes:['experiences:viewer:manage']" in ui
|
||||
assert "const wantManage=!onlyRegistration&&$('secretExperienceManage').checked;" in ui
|
||||
assert "const wantManage=!onlyOne&&$('secretExperienceManage').checked;" in ui
|
||||
# Registration credential: the browser issues a dedicated server-only key,
|
||||
# never a generic users:write/admin key. The shortcut must ignore existing
|
||||
# Experiences/NexBus defaults (and must not demand NexBus peer URLs).
|
||||
for marker in ('id="secretRegister"', 'id="secretGenerateRegistration"',
|
||||
"'NEXVERSE_REGISTER_API_KEY'",
|
||||
"scopes:['users:register'],env:'NEXVERSE_REGISTER_API_KEY'",
|
||||
"const wantRegister=onlyRegistration||$('secretRegister').checked;",
|
||||
"const wantBus=!onlyRegistration&&$('secretNexBus').checked;",
|
||||
"const wantRegister=onlyRegistration||(!onlyOne&&$('secretRegister').checked);",
|
||||
"const wantBus=!onlyOne&&$('secretNexBus').checked;",
|
||||
"secretGenerate(true)"):
|
||||
assert marker in ui, f"Registration API key control missing: {marker}"
|
||||
assert "let secretIssuePending=false;" in ui
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard the one-click NexGroups groups:read key setup in the World API UI."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
page = (root / "NexVerse/Server/Api/NexApiDocsPage.cs").read_text(encoding="utf-8")
|
||||
keys = (root / "NexVerse/Core/Security/NexApiKeyStore.cs").read_text(encoding="utf-8")
|
||||
docs = (root / "doc/NexVerse/NEXGROUPS_GRID_LAND_HISTORY.md").read_text(encoding="utf-8")
|
||||
auth = (root / "NexVerse/Server/Api/NexVerseUserApi.cs").read_text(encoding="utf-8")
|
||||
|
||||
# The chooser and single-purpose shortcut are separate controls.
|
||||
assert page.count('id="secretGroupLand"') == 1
|
||||
assert page.count('id="secretGenerateGroupLand"') == 1
|
||||
assert "<strong>NexGroups / Gridweite Landabfrage</strong>" in page
|
||||
assert "<code>groups:read</code>" in page
|
||||
assert "$('secretGenerateGroupLand').addEventListener('click',()=>secretGenerate(false,true));" in page
|
||||
|
||||
generator = page.split("async function secretGenerate(onlyRegistration=false, onlyGroupLand=false) {", 1)[1].split(
|
||||
"async function secretCopy()", 1
|
||||
)[0]
|
||||
# Quick-create must not inherit the checked Experiences/NexBus selections.
|
||||
assert "const onlyOne=onlyRegistration||onlyGroupLand;" in generator
|
||||
assert "const wantRegister=onlyRegistration||(!onlyOne&&$('secretRegister').checked);" in generator
|
||||
assert "const wantGroupLand=onlyGroupLand||(!onlyOne&&$('secretGroupLand').checked);" in generator
|
||||
for control in ("secretEconomy", "secretExperiences", "secretExperiencePermissions",
|
||||
"secretExperienceManage", "secretNexBus"):
|
||||
assert f"const want" in generator
|
||||
assert f"!onlyOne&&$('{control}').checked" in generator
|
||||
assert "if(wantBus){" in generator
|
||||
assert generator.index("if(wantBus){") < generator.index("const plan=[")
|
||||
assert "{wanted:wantGroupLand,name:'OGL Simulator Group Land'," in generator
|
||||
assert "scopes:['groups:read'],env:'NEXVERSE_GROUP_LAND_API_KEY'" in generator
|
||||
assert "onlyGroupLand?" in generator
|
||||
assert "$('secretGenerateGroupLand').disabled=true;" in generator
|
||||
assert "$('secretGenerateGroupLand').disabled=false;" in generator
|
||||
assert "const inventory=await secretJson('/api/v1/auth/api-keys'" in generator
|
||||
assert "if(match)throw new Error(" in generator
|
||||
assert "window.isSecureContext" in generator
|
||||
assert "const token=await secretAdminToken();" in generator
|
||||
assert "'Authorization':'Bearer '+token" in generator
|
||||
assert "values[item.env]=data.api_key;" in generator
|
||||
assert "secretBuildLines(values);" in generator
|
||||
|
||||
# The rendered copy block must contain the exact simulator env assignment.
|
||||
builder = page.split("function secretBuildLines(values) {", 1)[1].split(
|
||||
"function secretKeyFingerprint", 1
|
||||
)[0]
|
||||
assert "'NEXVERSE_GROUP_LAND_API_KEY'" in builder
|
||||
assert "name+'='+values[name]" in builder
|
||||
|
||||
# Reuse the real admin-only API key issuer; never issue wildcard/admin scopes.
|
||||
assert "NexScopes.GroupsRead," in keys
|
||||
assert "NexScopes.AdminAll" not in keys.split("HashSet<string> supportedScopes", 1)[1].split(
|
||||
"foreach (string scope", 1
|
||||
)[0]
|
||||
assert 'NexScopes.AdminAll,' in auth
|
||||
assert '"/api/v1/auth/api-keys"' in auth
|
||||
assert "Nur Gruppenland-API-Key erstellen" in docs
|
||||
assert "/etc/nexverse/nexverse.env" in docs
|
||||
|
||||
print("World API one-click group land key: scoped, isolated, and documented")
|
||||
Reference in new issue
Block a user