From 6dc73f2adfded7fe5ee94c992daaaba5be2b66c8 Mon Sep 17 00:00:00 2001 From: "OpenGenesis (MPL 2.0)" <153564363+opengenesislink@users.noreply.github.com> Date: Sun, 11 Oct 2026 18:49:34 +0200 Subject: [PATCH] fix(experiences): enable issuing standalone Firestorm viewer manage API keys (#162) * fix(experiences): allow standalone viewer:manage API key without privilege bundling * test(experiences): viewer manage key issuance, persistence and mixed privilege rejection * feat(admin-ui): offer dedicated Firestorm Experience acquisition management key checkbox * docs(experiences): precise HTTPS admin UI key issuance and developer simulator provisioning * docs(worldapi): document third Firestorm management-only machine key and issuing procedure * ci(experiences): enforce management-key issuing scope and admin UI wiring --- NexVerse/Core/Security/NexApiKeyStore.cs | 13 +++++- NexVerse/Server/Api/NexApiDocsPage.cs | 10 ++++- .../FIRESTORM_EXPERIENCE_ACQUIRE_09310.md | 45 +++++++++++++++++++ doc/NexVerse/WORLD_API.md | 2 +- tools/ci/NexApiKeyRegression/Program.cs | 40 ++++++++++++++++- tools/ci/verify_experiences_nexbus_enabled.py | 6 +++ 6 files changed, 110 insertions(+), 6 deletions(-) diff --git a/NexVerse/Core/Security/NexApiKeyStore.cs b/NexVerse/Core/Security/NexApiKeyStore.cs index 5e9b643e..b8c60cc7 100644 --- a/NexVerse/Core/Security/NexApiKeyStore.cs +++ b/NexVerse/Core/Security/NexApiKeyStore.cs @@ -103,7 +103,10 @@ namespace NexVerse.Core.Security NexScopes.ExperiencesScript, // Separate trusted simulator CAP transport. This is // deliberately NOT experiences:manage or admin:*. - NexScopes.ExperiencesViewerPermissions + NexScopes.ExperiencesViewerPermissions, + // Firestorm Experience acquisition / owner-only edits + // require a separate privileged simulator credential. + NexScopes.ExperiencesViewerManage }, StringComparer.OrdinalIgnoreCase); @@ -125,6 +128,14 @@ namespace NexVerse.Core.Security "Experiences viewer permission credentials must have only experiences:viewer:permissions.", nameof(scopes)); + if (normalizedScopes.Contains( + NexScopes.ExperiencesViewerManage, + StringComparer.OrdinalIgnoreCase) && + normalizedScopes.Length != 1) + throw new ArgumentException( + "Firestorm Experience management credentials must have only experiences:viewer:manage.", + nameof(scopes)); + string normalizedName = string.IsNullOrWhiteSpace(name) ? "NexVerse API key" : name.Trim(); if (normalizedName.Length > 120) diff --git a/NexVerse/Server/Api/NexApiDocsPage.cs b/NexVerse/Server/Api/NexApiDocsPage.cs index 89a6d0f9..72723f94 100644 --- a/NexVerse/Server/Api/NexApiDocsPage.cs +++ b/NexVerse/Server/Api/NexApiDocsPage.cs @@ -456,6 +456,7 @@ input,textarea,select{width:100%;background:#08131e;color:var(--text);border:1px +

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.

@@ -1421,6 +1422,7 @@ function secretValidateEndpoint(text) { function secretBuildLines(values) { const names=['NEXVERSE_ECONOMY_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']; $('secretOutput').value=names.filter(name=>Object.hasOwn(values,name)).map(name=>name+'='+values[name]).join('\n')+'\n'; $('secretCopy').disabled=!Object.keys(values).length; @@ -1521,8 +1523,9 @@ async function secretGenerate() { const wantEconomy=$('secretEconomy').checked; const wantExperiences=$('secretExperiences').checked; const wantPermissions=$('secretExperiencePermissions').checked; + const wantManage=$('secretExperienceManage').checked; const wantBus=$('secretNexBus').checked; - if(!wantEconomy&&!wantExperiences&&!wantPermissions&&!wantBus){ + if(!wantEconomy&&!wantExperiences&&!wantPermissions&&!wantManage&&!wantBus){ secretStatus('Bitte mindestens einen Schlüssel auswählen.',false);return; } const values={}; @@ -1543,7 +1546,10 @@ async function secretGenerate() { scopes:['experiences:script'],env:'NEXVERSE_EXPERIENCES_API_KEY'}, {wanted:wantPermissions,name:'NexVerse Simulator Experience Permissions', scopes:['experiences:viewer:permissions'], - env:'NEXVERSE_EXPERIENCES_VIEWER_PERMISSIONS_API_KEY'} + env:'NEXVERSE_EXPERIENCES_VIEWER_PERMISSIONS_API_KEY'}, + {wanted:wantManage,name:'NexVerse Simulator Experience Management', + scopes:['experiences:viewer:manage'], + env:'NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY'} ].filter(item=>item.wanted); if(plan.length){ const inventory=await secretJson('/api/v1/auth/api-keys',{ diff --git a/doc/NexVerse/FIRESTORM_EXPERIENCE_ACQUIRE_09310.md b/doc/NexVerse/FIRESTORM_EXPERIENCE_ACQUIRE_09310.md index 646a884f..ff2e6c41 100644 --- a/doc/NexVerse/FIRESTORM_EXPERIENCE_ACQUIRE_09310.md +++ b/doc/NexVerse/FIRESTORM_EXPERIENCE_ACQUIRE_09310.md @@ -77,6 +77,51 @@ mit minimalen Scopes anlegen oder bestehende gültige Schlüssel verwenden: nur `experiences:viewer:manage`; privilegierte Ausgabe nur durch berechtigten Administrator. +### Neuen Verwaltungsschlüssel im Adminbereich erzeugen + +Der bisherige World-API-Schlüsselstore kannte den Scope +`experiences:viewer:manage` noch nicht als erlaubten **Maschinen**-Scope. +Damit scheiterte jede Ausstellung trotz korrekt implementierter +Firestorm-Experience-CAPS. Dieser Fehler wurde im API-Key-Store behoben. +Außerdem ist der neue Scope jetzt in der Adminseite als eigene, +standardmäßig nicht ausgewählte Option verfügbar. + +1. Auf **Robust** und dem Entwickler-Simulator mindestens den Git-Stand + mit dieser Korrektur ausrollen und die **tatsächlich verwendeten** + Dienste mit dem neu gebauten Code kontrolliert starten. Ohne neuen + Robust-Code lehnt der Endpunkt weiter den Scope mit HTTP 400 ab. +2. Den über HTTPS geschützten World-API-Adminbereich + `/api/v1/docs` öffnen; mit einem echten Administrator-Konto + anmelden (UserLevel 200 und `admin:*`). +3. **Schlüssel & Einrichtung** auswählen. Bei der + Schlüsselgenerierung **ausschließlich** die Option + **„Experiences / Firestorm-Erwerb und Editor“** ankreuzen. + Economy, Script, Permissions und NexBus für diesen Vorgang + nicht erneut anlegen. +4. „Ausgewählte Schlüssel erstellen“ bestätigen. Die World API stellt + einen eigenen Schlüssel mit dem einzigen Scope + `experiences:viewer:manage` aus und zeigt die Konfigurationszeile + **genau einmal** an. +5. `NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY=` + sicher in der **effektiv vom Entwickler-Simulator geladenen** + Secret-Umgebung hinterlegen, zum Beispiel in + `/etc/nexverse/nexverse.env` wenn diese Datei wirklich vom + Dienst geladen wird. Keine Schlüsselwerte in `OpenSim.ini`, + Shell-History, Screenshots, Chat, Git oder öffentlich erreichbare + Logdateien schreiben. +6. `ViewerManageApiKey` in der Simulator-Ini darf unverändert auf + `${Environment|NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY}` + zeigen. Nach dem gezielten Neustart von `/opt/developer` mit + **neuem Firestorm-Login** die `AgentExperiences`-CAP testen. + +Für reine API-Nutzung durch autorisierte Administratoren ist alternativ +`POST /api/v1/auth/api-keys` mit +`{"name":"NexVerse Simulator Experience Management", +"scopes":["experiences:viewer:manage"]}` möglich. Der Endpunkt +verlangt einen gültigen **Admin-Bearer**, keinen API-Key. +Die Antwort enthält `api_key` nur bei Erstellung. Niemals die +Antwort in geteilte Shell-Logs oder den Chat kopieren. + Es müssen wirklich **drei verschiedene Werte** sein. Im Simulator als getrennte Environment-Secrets hinterlegen. Die Variablen sind in `bin/nexverse.env.example` und diff --git a/doc/NexVerse/WORLD_API.md b/doc/NexVerse/WORLD_API.md index b0a3f9a1..2d26bbae 100644 --- a/doc/NexVerse/WORLD_API.md +++ b/doc/NexVerse/WORLD_API.md @@ -630,7 +630,7 @@ The full key is returned exactly once. Its secret is persisted only as a PBKDF2- `data/nexverse-api-keys.json` -Supported machine scopes are explicit NexVerse functional scopes such as `regions:read`, `regions:manage`, `users:read`, `inventory:read`, `estates:read`, `estates:manage`, `economy:read` and their documented write/transfer counterparts. The simulator's Experiences adapter uses dedicated `experiences:script` credentials for LSL and, **separately**, an `experiences:viewer:permissions` machine key for Firestorm Allow/Block/Forget. The latter MUST be issued as its **only** scope, not bundled with script or other permissions. The broader `experiences:manage` and administrator permissions remain unavailable to machine API keys. +Supported machine scopes are explicit NexVerse functional scopes such as `regions:read`, `regions:manage`, `users:read`, `inventory:read`, `estates:read`, `estates:manage`, `economy:read` and their documented write/transfer counterparts. The simulator's Experiences adapter uses three **different** single-purpose machine credentials: `experiences:script` for LSL; `experiences:viewer:permissions` for Firestorm Allow/Block/Forget; and `experiences:viewer:manage` for the avatar-bound Firestorm Experience purchase/profile editor. Both `experiences:viewer:permissions` and `experiences:viewer:manage` MUST be issued as their **only** scope, never bundled with script, economy or other permissions. They require an authorized administrator to issue credentials through `POST /api/v1/auth/api-keys` (Admin Bearer, `admin:*`) or the HTTPS `/api/v1/docs` **Schlüssel & Einrichtung** console. In the console select only **Experiences / Firestorm-Erwerb und Editor** for the new management key. The one-time plaintext key belongs only in the simulator's effective `NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY` secret environment. The broader `experiences:manage` and administrator permissions remain unavailable to machine API keys. API-key principals use subjects in the form `api-key:`. Disabling a key takes effect immediately because validation is performed against the persistent key store on every request. diff --git a/tools/ci/NexApiKeyRegression/Program.cs b/tools/ci/NexApiKeyRegression/Program.cs index fc5c18ca..76745d61 100644 --- a/tools/ci/NexApiKeyRegression/Program.cs +++ b/tools/ci/NexApiKeyRegression/Program.cs @@ -163,6 +163,42 @@ internal static class Program Require(rejectedMixedPermissions, "Viewer permission credentials must not be mixed with script rights"); + // Firestorm Experience creation / owner editor must receive a + // dedicated key with ONLY experiences:viewer:manage, never + // script, resident permission, admin or economy rights. + NexApiKeyRegistration viewerManage = + experiencesReloaded.Create( + "NexVerse Simulator Experience Management", + new[] { NexScopes.ExperiencesViewerManage }); + Require(experiencesReloaded.TryValidate( + viewerManage.ApiKey, out NexApiKeyRecord scopedManage) && + scopedManage.Scopes.Length == 1 && + scopedManage.Scopes[0] == NexScopes.ExperiencesViewerManage, + "Dedicated Firestorm acquisition/editor machine key failed"); + + PersistentNexApiKeyStore viewerReloaded = + new PersistentNexApiKeyStore(path); + Require(viewerReloaded.TryValidate(viewerManage.ApiKey, out _), + "Viewer management key did not survive store reload"); + + foreach (string forbidden in new[] { + NexScopes.ExperiencesScript, + NexScopes.ExperiencesViewerPermissions, + NexScopes.EconomyTransfer, + NexScopes.AdminAll + }) + { + bool rejected = false; + try + { + viewerReloaded.Create("unsafe viewer management " + forbidden, + new[] { NexScopes.ExperiencesViewerManage, forbidden }); + } + catch (ArgumentException) { rejected = true; } + Require(rejected, + "Viewer management key must not combine with " + forbidden); + } + // Duplicate detection is scoped to the exact service identity, // case-insensitive name and normalized set of scopes. It must // never reveal or silently replace the existing plaintext secret. @@ -175,7 +211,7 @@ internal static class Program } catch (InvalidOperationException) { rejectedDuplicate = true; } Require(rejectedDuplicate, "Duplicate enabled service key accepted"); - Require(experiencesReloaded.List().Count == 3, + Require(experiencesReloaded.List().Count == 4, "Duplicate rejection modified the persistent key inventory"); // Deletion is an irreversible second step after explicit disable. @@ -205,7 +241,7 @@ internal static class Program "Last-used metadata lost when cloning records"); PersistentNexApiKeyStore afterCleanup = new PersistentNexApiKeyStore(path); - Require(afterCleanup.List().Count == 3 && + Require(afterCleanup.List().Count == 4 && afterCleanup.TryValidate(replacement.ApiKey, out _), "Key cleanup or replacement did not survive restart"); diff --git a/tools/ci/verify_experiences_nexbus_enabled.py b/tools/ci/verify_experiences_nexbus_enabled.py index 97ed283a..1146eb01 100644 --- a/tools/ci/verify_experiences_nexbus_enabled.py +++ b/tools/ci/verify_experiences_nexbus_enabled.py @@ -60,6 +60,8 @@ assert "return new InMemoryNexEventBus();" in connector store=contents("NexVerse/Core/Security/NexApiKeyStore.cs") assert "NexScopes.ExperiencesScript" in store assert "NexScopes.ExperiencesViewerPermissions" in store +assert "NexScopes.ExperiencesViewerManage" in store +assert "Firestorm Experience management credentials must have only experiences:viewer:manage." in store assert "normalizedScopes.Length != 1" in store assert "existing.Enabled" in store and "SameScopes(existing.Scopes, normalizedScopes)" in store assert "record == null || record.Enabled" in store, "cannot delete enabled keys" @@ -85,6 +87,10 @@ for marker in ('data-page="adminlogin"','id="page-adminlogin"','id="adminLoginPa "'secrets','nodes','grid'", 'id="page-secrets"', "'/api/v1/auth/api-keys'","window.crypto.getRandomValues(bytes)"): assert marker in ui,marker +assert 'id="secretExperienceManage"' in ui +assert "'NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY'" in ui +assert "scopes:['experiences:viewer:manage']" in ui +assert "const wantManage=$('secretExperienceManage').checked;" in ui assert "localStorage.setItem(" not in ui assert "sessionStorage.setItem(" not in ui assert 'id="secretAdminPassword"' not in ui, "secrets must use shared admin session"