feat(world-api): deliver R287 portal image, group and Discovery operations (#159)

* feat(r287): serve owner-authorized avatar profile JPEG2000 as browser image bytes

* feat(r287): inject existing authoritative OpenSim asset service into profile image endpoint

* feat(r287): published event/classified detail GET and owner-checked restricted PATCH/DELETE

* docs(r287): publish profile binary image and approved Discovery event/classified detail CRUD contracts

* docs(r287): type event and classified storage records, list/detail JSON and restrictive PATCH bodies

* feat(r287): self-only paginated groups/mine membership view bound to authenticated resident

* security(r287): prevent arbitrary known asset UUID disclosure through profile picture reference

* docs(r287): expose own Group memberships, strict event/classified JSON and binary profile image

* ci(r287): prevent regressions in profile image, Discovery CRUD and group membership privacy

* ci(r287): test generated runtime OpenAPI for profile images, event/classified mutation scopes and own groups

* docs(r287): synchronize ChatGPT generated instructions with profile images, own groups and content detail edits

* docs(r287): implementation status, deferred high-risk endpoints and acceptance requirements

* build(r287): reference existing System.Drawing.Common for J2K->PNG profile conversion

* build(r287): avoid shadowed requester variable in own membership branch

* docs(r287): type 12 Banking/Commerce/Land response envelopes with real C# ledger DTOs

* docs(r287): declare real common fields in four legacy Discovery/Chapter11 envelope schemas

* ci(r287): follow renamed local identity variable for own-group privacy check

* docs(r287): track typed Banking/Commerce response coverage and remaining polymorphic legacy models

* feat(r287): add authenticated exact grid Region UUID detail endpoint

* docs(r287): register region detail GET with Region schema, UUID path and regions:read scope

* security(r287): close POST upsert owner/visibility escalation for events and classifieds

* test(r287): gate POST content impersonation and visibility escalation

* docs(chatgpt): document owner-only POST upsert and draft status

* docs(r287): explain sealed POST owner and publication invariants

* ci(r287): ensure all 16 historic opaque OpenAPI schemas declare real fields

* fix(ci): recognize real newline in OpenAPI object schema verification

* docs(r287): itemize all 16 source proposals with implemented alternatives and explicit blockers
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-11 16:34:42 +02:00
1 parent c6e095e2ba
commit b4731582cf
11 files changed
+1277 -20

No files matched your search

+23
View File
@@ -254,6 +254,10 @@ jobs:
shell: bash
run: python3 tools/ci/verify_simple_stream_routing.py
- name: Verify R287 World API profile, discovery and groups security
shell: bash
run: python3 tools/ci/verify_r287_portal_api.py
- name: Verify World API OpenAPI and ChatGPT MD consistency
shell: bash
run: python3 tools/ci/verify_worldapi_chatgpt_openapi.py
@@ -1016,6 +1020,25 @@ jobs:
"#/components/schemas/ExperiencePublicInfoResponse")
assert "check_original" in schemas["ExperienceKvRequest"]["properties"]
assert doc["x_nexverse_version_history"][0]["status"] == "development"
for path, required_methods in {
"/api/v1/profiles/{principalId}/image": ("get",),
"/api/v1/events/{eventId}": ("get", "patch", "delete"),
"/api/v1/classifieds/{classifiedId}": ("get", "patch", "delete"),
"/api/v1/groups/mine": ("get",),
}.items():
for method in required_methods:
assert method in doc["paths"][path], (path, method)
profile_image = doc["paths"]["/api/v1/profiles/{principalId}/image"]["get"]
assert "image/png" in profile_image["responses"]["200"]["content"]
assert profile_image["responses"]["200"]["content"]["image/png"]["schema"]["format"] == "binary"
assert doc["paths"]["/api/v1/events/{eventId}"]["patch"]["x-nexverse-scope"] == "discovery:manage"
assert doc["paths"]["/api/v1/groups/mine"]["get"]["x-nexverse-scope"] == "groups:read"
assert doc["paths"]["/api/v1/events/{eventId}"]["patch"]["requestBody"][
"content"]["application/json"]["schema"]["$ref"] == (
"#/components/schemas/DiscoveryEventPatch")
assert doc["paths"]["/api/v1/classifieds/{classifiedId}"]["patch"]["requestBody"][
"content"]["application/json"]["schema"]["$ref"] == (
"#/components/schemas/DiscoveryClassifiedPatch")
assert "/api/v1/chatgpt-instructions.md" in doc["paths"]
assert "/api/v1/chatgpt-buergerportal.md" in doc["paths"]
assert "/api/v1/chatgpt-admin.md" in doc["paths"]
@@ -191,8 +191,11 @@ namespace NexVerse.Server.Api
md.AppendLine("- DELETE /messages/history loescht die eigene Portal-IM-Historie, opt-out ebenfalls.");
md.AppendLine("- Fuer Antworten aus Firestorm muss [NexPortalIM] in Robust und Simulator mit demselben HMAC-Secret aktiviert sein.");
md.AppendLine("- GET/PATCH /profiles/{principalId} liest/bearbeitet das OpenSim-Avatarprofil einschliesslich profile_image als existierende Asset-UUID. Ein Webupload ist noch kein Bestandteil.");
md.AppendLine("- GET /profiles/{principalId}/image liefert autorisiert tatsaechliche PNG/JPEG-Bilddaten der *aktuell* hinterlegten Profiltextur. Oeffentlich nur bei PublishProfile, sonst ProfileRead + eigener Avatar/Admin; kein Asset-Browser oder beliebige Texture-UUID.");
md.AppendLine("- profile_image_url ist ein relativer Pfad und kann null sein. Keine Schluessel/Tokens in Querystrings ablegen; Browser-Fetch fuer private Profile braucht den authentifizierten Kontext.");
md.AppendLine("- Display Name via PATCH /users/{principalId} mit display_name, sieben Tage Cooldown fuer Self-Service.");
md.AppendLine("- Gruppenmitteilungen: GET/POST /groups/{groupId}/notices; Rechte des Gruppenmitglieds gelten auch mit Gruppen-Scopes.");
md.AppendLine("- GET /groups/mine liefert die Gruppenmitgliedschaften und aktiven Rollen des angemeldeten Einwohners paginiert (limit max. 100), ohne frei waehbare Fremd-Avatar-ID.");
md.AppendLine();
md.AppendLine("### Inventar");
md.AppendLine("- Lesen ueber /inventory/tree, /inventory/search, /inventory/folders/{folderId}, /inventory/items/{itemId} und /inventory/lost-and-found.");
@@ -295,6 +298,10 @@ namespace NexVerse.Server.Api
md.AppendLine("## OpenAPI-Metadaten fuer die automatische Zuordnung");
md.AppendLine();
md.AppendLine("- x-nexverse-audience: citizen, admin und/oder service; Service bedeutet nicht automatisch Browser/OAuth-Einwohnerzugriff.");
md.AppendLine("- R287: /events/{eventId} und /classifieds/{classifiedId} bieten oeffentliche GETs ausschliesslich fuer freigegebene Inhalte. PATCH und DELETE erfordern discovery:manage plus nachgewiesenes Eigentum oder admin:*.");
md.AppendLine("- R287-PATCH akzeptiert nur benannte Anzeige-/Zeit-/Tag-Felder; Creator/Owner, UUID, Moderation und Publikationszustand duerfen damit nicht geaendert werden.");
md.AppendLine("- R287-POST Upsert: Einwohner duerfen ausschliesslich eigene Eintraege als Entwurf anlegen und fremde Inhalte nicht ersetzen. Publikationsstatus, Owner und Place koennen nicht mit normalen discovery:manage-Scopes eskaliert werden.");
md.AppendLine("- Unveraendert offen: allgemeiner Assetbrowser, Citizen Notifications, Konto-Inhaber-Nachweise, Event RSVP und externe Payment-Credits sind keine zugesicherten Live-Endpunkte.");
md.AppendLine("- security.apiKeyAuth (Header X-NexVerse-Api-Key) ist bei internen Viewer-Bridges explizit; normalen Bewohner-Bearer dort NICHT verwenden.");
md.AppendLine("- x-nexverse-scope: benoetigter Berechtigungsumfang.");
md.AppendLine("- x-nexverse-purpose: Zweck der Operation.");
+217 -2
View File
@@ -330,7 +330,37 @@ namespace NexVerse.Server.Api
try
{
NexEventRecord saved = m_Store.UpsertEvent(ReadBody<NexEventRecord>(request));
NexEventRecord incoming = ReadBody<NexEventRecord>(request);
NexEventRecord prior = incoming.EventId == Guid.Empty
? null : m_Store.GetEvent(incoming.EventId);
if (prior == null && incoming.EventId != Guid.Empty)
throw new KeyNotFoundException("Event was not found.");
if (!principal.HasScope(NexScopes.AdminAll))
{
// A service key scoped only to discovery:manage
// must never impersonate a resident. Publication
// and moderation remain admin-only on POST too.
Guid actor = RequireResidentActor(principal);
if (prior != null)
{
RequireContentOwner(principal, prior.OrganizerId);
if (incoming.OrganizerId != prior.OrganizerId ||
incoming.PlaceId != prior.PlaceId ||
incoming.State != prior.State)
throw new UnauthorizedAccessException(
"Event owner, place and publication state are protected.");
}
else
{
if (incoming.OrganizerId != Guid.Empty &&
incoming.OrganizerId != actor)
throw new UnauthorizedAccessException(
"Event organizer must be the authenticated resident.");
incoming.OrganizerId = actor;
incoming.State = NexDiscoveryPublicationState.Draft;
}
}
NexEventRecord saved = m_Store.UpsertEvent(incoming);
Audit(principal, "discovery.event.upserted", "event:" + saved.EventId, response);
WriteJson(response, new { @event = saved, correlation_id = Correlation(response) }, HttpStatusCode.Created);
}
@@ -366,7 +396,34 @@ namespace NexVerse.Server.Api
try
{
NexClassifiedRecord saved = m_Store.UpsertClassified(ReadBody<NexClassifiedRecord>(request));
NexClassifiedRecord incoming = ReadBody<NexClassifiedRecord>(request);
NexClassifiedRecord prior = incoming.ClassifiedId == Guid.Empty
? null : m_Store.GetClassified(incoming.ClassifiedId);
if (prior == null && incoming.ClassifiedId != Guid.Empty)
throw new KeyNotFoundException("Classified was not found.");
if (!principal.HasScope(NexScopes.AdminAll))
{
Guid actor = RequireResidentActor(principal);
if (prior != null)
{
RequireContentOwner(principal, prior.OwnerId);
if (incoming.OwnerId != prior.OwnerId ||
incoming.PlaceId != prior.PlaceId ||
incoming.State != prior.State)
throw new UnauthorizedAccessException(
"Classified owner, place and publication state are protected.");
}
else
{
if (incoming.OwnerId != Guid.Empty &&
incoming.OwnerId != actor)
throw new UnauthorizedAccessException(
"Classified owner must be the authenticated resident.");
incoming.OwnerId = actor;
incoming.State = NexDiscoveryPublicationState.Draft;
}
}
NexClassifiedRecord saved = m_Store.UpsertClassified(incoming);
Audit(principal, "discovery.classified.upserted", "classified:" + saved.ClassifiedId, response);
WriteJson(response, new { classified = saved, correlation_id = Correlation(response) }, HttpStatusCode.Created);
}
@@ -378,6 +435,144 @@ namespace NexVerse.Server.Api
}
}
// R287: dedicated detail APIs. Public GET must not reveal
// unpublished drafts even when their UUID is known.
if (TryResourceId(path, "/api/v1/events/", out Guid eventId))
{
NexEventRecord existing = m_Store.GetEvent(eventId);
if (method.Equals("GET", StringComparison.OrdinalIgnoreCase))
{
if (existing == null ||
existing.State != NexDiscoveryPublicationState.Approved)
{
NotFound(response, "event_not_found", "Published event was not found.");
return;
}
WriteJson(response, new
{
@event = existing,
correlation_id = Correlation(response)
});
return;
}
if (!method.Equals("PATCH", StringComparison.OrdinalIgnoreCase) &&
!method.Equals("DELETE", StringComparison.OrdinalIgnoreCase))
{
MethodNotAllowed(response, "GET, PATCH or DELETE");
return;
}
if (!Authenticate(request, response, NexScopes.DiscoveryManage,
out NexPrincipal principal, out _))
return;
try
{
if (existing == null)
throw new KeyNotFoundException("Event was not found.");
RequireContentOwner(principal, existing.OrganizerId);
if (method.Equals("DELETE", StringComparison.OrdinalIgnoreCase))
{
bool deleted = m_Store.DeleteEvent(eventId);
Audit(principal, "discovery.event.deleted", "event:" + eventId, response);
WriteJson(response, new { deleted, correlation_id = Correlation(response) });
return;
}
// PATCH accepts only mutable descriptive/schedule fields.
// Publication state, organizer identity, UUID, place and
// moderation cannot be escalated via this route.
using JsonDocument doc = JsonDocument.Parse(request.InputStream);
if (doc.RootElement.ValueKind != JsonValueKind.Object)
throw new ArgumentException("PATCH requires a JSON object.");
NexEventRecord next = existing;
foreach (JsonProperty prop in doc.RootElement.EnumerateObject())
{
switch (prop.Name)
{
case "name": next.Name = prop.Value.GetString(); break;
case "description": next.Description = prop.Value.GetString(); break;
case "image": next.Image = prop.Value.GetString(); break;
case "starts_at": next.StartsAt = prop.Value.GetDateTimeOffset(); break;
case "ends_at": next.EndsAt = prop.Value.GetDateTimeOffset(); break;
case "admission_price_minor": next.AdmissionPriceMinor = prop.Value.GetInt64(); break;
case "tags": next.Tags = JsonSerializer.Deserialize<List<string>>(
prop.Value.GetRawText(), s_Json); break;
default: throw new ArgumentException(
"Unsupported or protected event PATCH field: " + prop.Name);
}
}
NexEventRecord updated = m_Store.UpsertEvent(next);
Audit(principal, "discovery.event.updated", "event:" + eventId, response);
WriteJson(response, new { @event = updated, correlation_id = Correlation(response) });
}
catch (Exception e) { WriteFailure(response, e); }
return;
}
if (TryResourceId(path, "/api/v1/classifieds/", out Guid classifiedId))
{
NexClassifiedRecord existing = m_Store.GetClassified(classifiedId);
if (method.Equals("GET", StringComparison.OrdinalIgnoreCase))
{
if (existing == null ||
existing.State != NexDiscoveryPublicationState.Approved)
{
NotFound(response, "classified_not_found", "Published classified was not found.");
return;
}
WriteJson(response, new
{
classified = existing,
correlation_id = Correlation(response)
});
return;
}
if (!method.Equals("PATCH", StringComparison.OrdinalIgnoreCase) &&
!method.Equals("DELETE", StringComparison.OrdinalIgnoreCase))
{
MethodNotAllowed(response, "GET, PATCH or DELETE");
return;
}
if (!Authenticate(request, response, NexScopes.DiscoveryManage,
out NexPrincipal principal, out _))
return;
try
{
if (existing == null)
throw new KeyNotFoundException("Classified was not found.");
RequireContentOwner(principal, existing.OwnerId);
if (method.Equals("DELETE", StringComparison.OrdinalIgnoreCase))
{
bool deleted = m_Store.DeleteClassified(classifiedId);
Audit(principal, "discovery.classified.deleted", "classified:" + classifiedId, response);
WriteJson(response, new { deleted, correlation_id = Correlation(response) });
return;
}
using JsonDocument doc = JsonDocument.Parse(request.InputStream);
if (doc.RootElement.ValueKind != JsonValueKind.Object)
throw new ArgumentException("PATCH requires a JSON object.");
NexClassifiedRecord next = existing;
foreach (JsonProperty prop in doc.RootElement.EnumerateObject())
{
switch (prop.Name)
{
case "name": next.Name = prop.Value.GetString(); break;
case "description": next.Description = prop.Value.GetString(); break;
case "category": next.Category = prop.Value.GetString(); break;
case "image": next.Image = prop.Value.GetString(); break;
case "tags": next.Tags = JsonSerializer.Deserialize<List<string>>(
prop.Value.GetRawText(), s_Json); break;
default: throw new ArgumentException(
"Unsupported or protected classified PATCH field: " + prop.Name);
}
}
NexClassifiedRecord updated = m_Store.UpsertClassified(next);
Audit(principal, "discovery.classified.updated", "classified:" + classifiedId, response);
WriteJson(response, new { classified = updated, correlation_id = Correlation(response) });
}
catch (Exception e) { WriteFailure(response, e); }
return;
}
NotFound(response, "not_found", "Discovery content endpoint was not found.");
}
@@ -928,6 +1123,26 @@ namespace NexVerse.Server.Api
NexDiscoveryMaturity actual) =>
!maximum.HasValue || actual <= maximum.Value;
private static Guid RequireResidentActor(NexPrincipal principal)
{
if (principal == null ||
!Guid.TryParse(principal.Subject, out Guid actor) ||
actor == Guid.Empty)
throw new UnauthorizedAccessException(
"Only a resident or administrator may create or update content.");
return actor;
}
private static void RequireContentOwner(NexPrincipal principal, Guid ownerId)
{
if (principal != null && principal.HasScope(NexScopes.AdminAll))
return;
if (principal == null || !Guid.TryParse(principal.Subject, out Guid subject) ||
ownerId == Guid.Empty || subject != ownerId)
throw new UnauthorizedAccessException(
"Only the content owner or a grid administrator can modify this resource.");
}
private bool Authenticate(
IOSHttpRequest request,
IOSHttpResponse response,
+52
View File
@@ -132,6 +132,58 @@ namespace NexVerse.Server.Api
return;
}
// R287: own memberships are not a directory search. Bind the
// member to the authenticated resident, never a supplied agent_id.
if (path == "/api/v1/groups/mine")
{
if (!method.Equals("GET", StringComparison.OrdinalIgnoreCase))
{
MethodNotAllowed(response, "GET");
return;
}
if (!Authenticate(request, response, NexScopes.GroupsRead,
out NexPrincipal principal, out UserAccount account))
return;
if (account == null ||
!Guid.TryParse(principal.Subject, out Guid resident) ||
resident == Guid.Empty || resident != account.PrincipalID.Guid)
{
WriteError(response, HttpStatusCode.Forbidden, "resident_required",
"Own group memberships require an authenticated resident account.");
return;
}
try
{
string selfGroupRequester = resident.ToString("D");
List<GroupMembershipData> memberships =
m_Groups.GetAgentGroupMemberships(selfGroupRequester, selfGroupRequester) ??
new List<GroupMembershipData>();
int offset = int.TryParse(request?.QueryString?["offset"], out int off)
? Math.Clamp(off, 0, 1000000) : 0;
int limit = int.TryParse(request?.QueryString?["limit"], out int lim)
? Math.Clamp(lim, 1, 100) : 50;
WriteJson(response, new
{
groups = memberships.Skip(offset).Take(limit).Select(g => new
{
group_id = g.GroupID.ToString(),
name = g.GroupName,
title = g.GroupTitle,
active = g.Active,
role_id = g.ActiveRole.ToString(),
powers = g.GroupPowers.ToString(),
notices = g.AcceptNotices
}).ToArray(),
offset,
limit,
total = memberships.Count,
correlation_id = Correlation(response)
});
}
catch (Exception e) { WriteFailure(response, e); }
return;
}
const string prefix = "/api/v1/groups/";
if (!path.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
+37
View File
@@ -950,6 +950,43 @@ namespace NexVerse.Server.Api
return;
}
// R287: exact Region UUID lookup reuses the authoritative
// grid provider instead of scanning or overloading GET /regions.
if (path.StartsWith("/api/v1/regions/", StringComparison.OrdinalIgnoreCase))
{
if (!IsMethod(request, "GET"))
{
WriteError(response, HttpStatusCode.MethodNotAllowed,
"method_not_allowed", "GET is required.");
return;
}
if (!Authenticate(request, response, NexScopes.RegionsRead,
out NexPrincipal _, out UserAccount _))
return;
string tail = path.Substring("/api/v1/regions/".Length);
if (tail.Contains('/') || !Guid.TryParse(tail, out Guid regionId) ||
regionId == Guid.Empty)
{
WriteError(response, HttpStatusCode.BadRequest,
"invalid_region_id", "A valid region UUID is required.");
return;
}
NexRegionRecord region = m_Users.ResolveHomeRegion(
regionId.ToString("D"), null);
if (region == null)
{
WriteError(response, HttpStatusCode.NotFound,
"region_not_found", "Region does not exist.");
return;
}
WriteJson(response, new
{
region = RegionPayload(region),
correlation_id = NexApiRequestContext.Ensure(response)
});
return;
}
if (string.Equals(path, "/api/v1/users/me", StringComparison.OrdinalIgnoreCase))
{
HandleMe(request, response);
@@ -870,6 +870,7 @@ namespace NexVerse.Server.Api
new NexWebProfileV3Api(
userAccounts,
profilesData,
assets,
authenticator,
auditSink);
+544 -16
View File
@@ -222,10 +222,20 @@ namespace NexVerse.Server.Api
GetOperation("Veröffentlichte Discovery-Events durchsuchen"),
AuthenticatedOperations(
("post", "Discovery-Event anlegen oder aktualisieren", "discovery:manage", "201"))),
["/api/v1/events/{eventId}"] = MergeOperations(
GetOperation("Einzelne veröffentlichte Veranstaltung lesen; Entwürfe bleiben verborgen"),
AuthenticatedOperations(
("patch", "Eigene Veranstaltungsdaten/Schedule ohne Owner-/Statuswechsel ändern", "discovery:manage", "200"),
("delete", "Eigene Veranstaltung entfernen, mit Audit", "discovery:manage", "200"))),
["/api/v1/classifieds"] = MergeOperations(
GetOperation("Veröffentlichte Classifieds durchsuchen"),
AuthenticatedOperations(
("post", "Classified anlegen oder aktualisieren", "discovery:manage", "201"))),
["/api/v1/classifieds/{classifiedId}"] = MergeOperations(
GetOperation("Einzelne veröffentlichte Kleinanzeige lesen; Entwürfe bleiben verborgen"),
AuthenticatedOperations(
("patch", "Eigene Kleinanzeigendaten ohne Eigentums-/Statuswechsel ändern", "discovery:manage", "200"),
("delete", "Eigene Kleinanzeige entfernen, mit Audit", "discovery:manage", "200"))),
["/api/v1/land-portal"] = GetOperation(
"Aktive NV$-Landangebote als Landportal durchsuchen"),
["/api/v1/land-portal/owned"] = AuthenticatedOperations(
@@ -245,6 +255,8 @@ namespace NexVerse.Server.Api
["/api/v1/profiles/{principalId}"] = MergeOperations(
GetOperation("Öffentlich sichtbares Avatarprofil lesen; private Profile nur für Eigentümer oder Admin"),
AuthenticatedOperations(("patch", "Eigenes Avatarprofil einschließlich Bild-Asset-UUID, Interessen und Sichtbarkeit aktualisieren", "profile:write", "200"))),
["/api/v1/profiles/{principalId}/image"] = GetOperation(
"Browserfähige Profilbild-Bytes der aktuell verknüpften Avatar-Textur; privat nur Owner/Admin"),
["/api/v1/relationships/{principalId}"] = AuthenticatedOperations(
("get", "Eigene Freundesliste mit Anfragezustand, Online-Sichtbarkeit und Rechten lesen", "relationships:read", "200")),
["/api/v1/relationships/{principalId}/{targetId}"] = AuthenticatedOperations(
@@ -270,6 +282,8 @@ namespace NexVerse.Server.Api
["/api/v1/groups"] = AuthenticatedOperations(
("get", "NexGroups durchsuchen", "groups:read", "200"),
("post", "NexGroup erstellen", "groups:manage", "201")),
["/api/v1/groups/mine"] = AuthenticatedOperations(
("get", "Eigene Gruppenmitgliedschaften und Rollen des authentifizierten Einwohners, ohne Fremd-ID-Parameter", "groups:read", "200")),
["/api/v1/groups/{groupId}"] = AuthenticatedOperations(
("get", "NexGroup-Profil lesen", "groups:read", "200"),
("put", "NexGroup-Profil ändern", "groups:manage", "200"),
@@ -392,6 +406,8 @@ namespace NexVerse.Server.Api
["/api/v1/regions"] = AuthenticatedOperations(
("get", "Auswählbare Home-/Startregionen durchsuchen", "regions:read", "200"),
("post", "NexVerse-verwaltete Region auf einem Simulator-Node erstellen", "regions:manage", "202")),
["/api/v1/regions/{regionId}"] = AuthenticatedOperations(
("get", "Genau eine Grid-Region anhand UUID lesen", "regions:read", "200")),
["/api/v1/regions/{regionId}/placement"] = AuthenticatedOperations(
("patch", "NexVerse-verwaltete Region nach Placement-Prüfung verschieben", "regions:manage", "202")),
["/api/v1/regions/{regionId}/lifecycle"] = AuthenticatedOperations(
@@ -629,6 +645,59 @@ namespace NexVerse.Server.Api
ApplyJsonContract(paths, "/api/v1/groups/{groupId}/bans/{agentId}", "post", "Chapter11MutationRequest", "Chapter11ObjectResponse", "200");
ApplyJsonContract(paths, "/api/v1/groups/{groupId}/accounting", "get", null, "Chapter11ObjectResponse", "200");
ApplyJsonContract(paths, "/api/v1/groups/{groupId}/capabilities", "get", null, "Chapter11ObjectResponse", "200");
ApplyJsonContract(paths, "/api/v1/regions/{regionId}", "get", null, "RegionDetailResponse", "200");
AddOperationParameters(paths, "/api/v1/regions/{regionId}", "get",
PathParameter("regionId", "Grid-Region UUID"));
ApplyJsonContract(paths, "/api/v1/groups/mine", "get", null, "CitizenGroupMembershipsResponse", "200");
AddOperationParameters(paths, "/api/v1/groups/mine", "get",
PaginationParameter("offset", 0, 0, 1000000),
PaginationParameter("limit", 50, 1, 100));
ApplyJsonContract(paths, "/api/v1/events", "get", null, "DiscoveryEventListResponse", "200");
ApplyJsonContract(paths, "/api/v1/events", "post", "DiscoveryEventRecord", "DiscoveryEventResponse", "201");
ApplyJsonContract(paths, "/api/v1/events/{eventId}", "get", null, "DiscoveryEventResponse", "200");
ApplyJsonContract(paths, "/api/v1/events/{eventId}", "patch", "DiscoveryEventPatch", "DiscoveryEventResponse", "200");
ApplyJsonContract(paths, "/api/v1/events/{eventId}", "delete", null, "DiscoveryDeletedResponse", "200");
ApplyJsonContract(paths, "/api/v1/classifieds", "get", null, "DiscoveryClassifiedListResponse", "200");
ApplyJsonContract(paths, "/api/v1/classifieds", "post", "DiscoveryClassifiedRecord", "DiscoveryClassifiedResponse", "201");
ApplyJsonContract(paths, "/api/v1/classifieds/{classifiedId}", "get", null, "DiscoveryClassifiedResponse", "200");
ApplyJsonContract(paths, "/api/v1/classifieds/{classifiedId}", "patch", "DiscoveryClassifiedPatch", "DiscoveryClassifiedResponse", "200");
ApplyJsonContract(paths, "/api/v1/classifieds/{classifiedId}", "delete", null, "DiscoveryDeletedResponse", "200");
AddOperationParameters(paths, "/api/v1/events/{eventId}", "get",
PathParameter("eventId", "Event-UUID"));
AddOperationParameters(paths, "/api/v1/events/{eventId}", "patch",
PathParameter("eventId", "Event-UUID"));
AddOperationParameters(paths, "/api/v1/events/{eventId}", "delete",
PathParameter("eventId", "Event-UUID"));
AddOperationParameters(paths, "/api/v1/classifieds/{classifiedId}", "get",
PathParameter("classifiedId", "Classified-UUID"));
AddOperationParameters(paths, "/api/v1/classifieds/{classifiedId}", "patch",
PathParameter("classifiedId", "Classified-UUID"));
AddOperationParameters(paths, "/api/v1/classifieds/{classifiedId}", "delete",
PathParameter("classifiedId", "Classified-UUID"));
AddOperationParameters(paths, "/api/v1/profiles/{principalId}/image", "get",
PathParameter("principalId", "Avatar-UUID"));
// Image output is binary; do not advertise it as JSON.
if (paths["/api/v1/profiles/{principalId}/image"] is Dictionary<string, object> imagePath &&
imagePath["get"] is Dictionary<string, object> imageOperation)
{
imageOperation["x-nexverse-ai-instruction"] =
"Nur aktuell im Profil gesetztes Bild. Keine beliebige Asset-UUID; private Profile benoetigen Avatar-Owner oder Admin-Token.";
imageOperation["responses"] = new Dictionary<string, object>
{
["200"] = new
{
description = "Bilddaten (JPEG2000 wird zu PNG dekodiert)",
content = new Dictionary<string, object>
{
["image/png"] = new { schema = new { type = "string", format = "binary" } },
["image/jpeg"] = new { schema = new { type = "string", format = "binary" } }
}
},
["401"] = new { description = "Authentifizierung fuer privates Profil erforderlich" },
["404"] = new { description = "Bild nicht vorhanden oder nicht sichtbar" },
["503"] = new { description = "Assetdienst oder Codec nicht verfuegbar" }
};
}
ApplyJsonContract(paths, "/api/v1/experiences", "get", null, "ExperienceSearchResponse", "200");
ApplyJsonContract(paths, "/api/v1/experiences", "post", "NexExperienceCreateRequest", "ExperienceDetailsResponse", "201");
ApplyJsonContract(paths, "/api/v1/experiences/{experienceId}", "get", null, "ExperienceDetailsResponse", "200");
@@ -2957,14 +3026,158 @@ namespace NexVerse.Server.Api
["correlation_id"] = new { type = "string" }
}
},
// R287: real NexDiscoveryStore entities, including the
// exact snake_case JSON fields used by NexDiscoveryApi.
["DiscoveryEventRecord"] = new
{
type = "object",
required = new[] { "name", "place_id", "organizer_id", "starts_at", "ends_at" },
properties = new Dictionary<string, object>
{
["event_id"] = new { type = "string", format = "uuid" },
["place_id"] = new { type = "string", format = "uuid" },
["organizer_id"] = new { type = "string", format = "uuid" },
["name"] = new { type = "string", minLength = 1 },
["description"] = new { type = "string", maxLength = 8192 },
["image"] = new { type = "string" },
["maturity"] = new { type = "string", @enum = new[] { "general", "moderate", "adult" } },
["starts_at"] = new { type = "string", format = "date-time" },
["ends_at"] = new { type = "string", format = "date-time" },
["admission_price_minor"] = new { type = "integer", format = "int64", minimum = 0 },
["tags"] = new { type = "array", items = new { type = "string" } },
["state"] = new { type = "string", @enum = new[] { "draft", "submitted", "approved", "rejected" } },
["created_at"] = new { type = "string", format = "date-time" },
["updated_at"] = new { type = "string", format = "date-time" }
}
},
["DiscoveryEventPatch"] = new
{
type = "object",
additionalProperties = false,
properties = new Dictionary<string, object>
{
["name"] = new { type = "string", minLength = 1 },
["description"] = new { type = "string", maxLength = 8192 },
["image"] = new { type = "string" },
["starts_at"] = new { type = "string", format = "date-time" },
["ends_at"] = new { type = "string", format = "date-time" },
["admission_price_minor"] = new { type = "integer", format = "int64", minimum = 0 },
["tags"] = new { type = "array", items = new { type = "string" } }
}
},
["DiscoveryEventResponse"] = new
{
type = "object",
required = new[] { "event", "correlation_id" },
properties = new Dictionary<string, object>
{
["event"] = SchemaRef("DiscoveryEventRecord"),
["correlation_id"] = new { type = "string" }
}
},
["DiscoveryEventListResponse"] = new
{
type = "object",
required = new[] { "events", "correlation_id" },
properties = new Dictionary<string, object>
{
["events"] = new { type = "array", items = SchemaRef("DiscoveryEventRecord") },
["correlation_id"] = new { type = "string" }
}
},
["DiscoveryClassifiedRecord"] = new
{
type = "object",
required = new[] { "name", "owner_id" },
properties = new Dictionary<string, object>
{
["classified_id"] = new { type = "string", format = "uuid" },
["owner_id"] = new { type = "string", format = "uuid" },
["place_id"] = new { type = "string", format = "uuid" },
["name"] = new { type = "string" },
["description"] = new { type = "string", maxLength = 8192 },
["category"] = new { type = "string", maxLength = 128 },
["image"] = new { type = "string" },
["maturity"] = new { type = "string", @enum = new[] { "general", "moderate", "adult" } },
["tags"] = new { type = "array", items = new { type = "string" } },
["state"] = new { type = "string", @enum = new[] { "draft", "submitted", "approved", "rejected" } },
["created_at"] = new { type = "string", format = "date-time" },
["updated_at"] = new { type = "string", format = "date-time" }
}
},
["DiscoveryClassifiedPatch"] = new
{
type = "object",
additionalProperties = false,
properties = new Dictionary<string, object>
{
["name"] = new { type = "string", minLength = 1 },
["description"] = new { type = "string", maxLength = 8192 },
["category"] = new { type = "string", maxLength = 128 },
["image"] = new { type = "string" },
["tags"] = new { type = "array", items = new { type = "string" } }
}
},
["DiscoveryClassifiedResponse"] = new
{
type = "object",
required = new[] { "classified", "correlation_id" },
properties = new Dictionary<string, object>
{
["classified"] = SchemaRef("DiscoveryClassifiedRecord"),
["correlation_id"] = new { type = "string" }
}
},
["DiscoveryClassifiedListResponse"] = new
{
type = "object",
required = new[] { "classifieds", "correlation_id" },
properties = new Dictionary<string, object>
{
["classifieds"] = new { type = "array", items = SchemaRef("DiscoveryClassifiedRecord") },
["correlation_id"] = new { type = "string" }
}
},
["DiscoveryDeletedResponse"] = new
{
type = "object",
required = new[] { "deleted", "correlation_id" },
properties = new Dictionary<string, object>
{
["deleted"] = new { type = "boolean" },
["correlation_id"] = new { type = "string" }
}
},
["DiscoveryObjectResponse"] = new
{
type = "object"
type = "object",
description = "Mehrzweck-Discovery-Envelope. Konkrete Event-/Classified-Routen besitzen eigene typisierte Responses.",
additionalProperties = true,
properties = new Dictionary<string, object>
{
["place"] = new { type = "object" },
["destination"] = new { type = "object" },
["places"] = new { type = "array", items = new { type = "object" } },
["destinations"] = new { type = "array", items = new { type = "object" } },
["deleted"] = new { type = "boolean" },
["correlation_id"] = new { type = "string" }
}
},
["DiscoveryMutationRequest"] = new
{
type = "object",
additionalProperties = true
description = "Nur dort verwenden, wo noch kein spezifischer Place-/Destination-Request vorhanden ist; Management-Scopes und Ownership gelten zusätzlich.",
additionalProperties = true,
properties = new Dictionary<string, object>
{
["place_id"] = new { type = "string", format = "uuid" },
["destination_id"] = new { type = "string", format = "uuid" },
["name"] = new { type = "string" },
["description"] = new { type = "string" },
["category"] = new { type = "string" },
["subcategory"] = new { type = "string" },
["tags"] = new { type = "array", items = new { type = "string" } }
}
},
["DiscoveryPlaceRequest"] = new
{
@@ -3019,12 +3232,77 @@ namespace NexVerse.Server.Api
},
["Chapter11ObjectResponse"] = new
{
type = "object"
type = "object",
description = "Legacy Chapter11 Mehrzweck-Envelope; konkrete Viewer Experience-Operationen sind separat typisiert.",
additionalProperties = true,
properties = new Dictionary<string, object>
{
["group"] = new { type = "object" },
["groups"] = new { type = "array", items = new { type = "object" } },
["members"] = new { type = "array", items = new { type = "object" } },
["roles"] = new { type = "array", items = new { type = "object" } },
["notices"] = new { type = "array", items = new { type = "object" } },
["experience"] = SchemaRef("ExperienceApiRecord"),
["experiences"] = new { type = "array", items = SchemaRef("ExperienceApiRecord") },
["deleted"] = new { type = "boolean" },
["correlation_id"] = new { type = "string" }
}
},
["Chapter11MutationRequest"] = new
{
type = "object",
additionalProperties = true
description = "Legacy Chapter11 Mutation; konkrete NexGroups-/Experience-Routen verwenden eigene Request-Modelle, wo implementiert.",
additionalProperties = true,
properties = new Dictionary<string, object>
{
["name"] = new { type = "string" },
["charter"] = new { type = "string" },
["group_id"] = new { type = "string", format = "uuid" },
["role_id"] = new { type = "string", format = "uuid" },
["agent_id"] = new { type = "string", format = "uuid" },
["experience_id"] = new { type = "string", format = "uuid" },
["description"] = new { type = "string" },
["enabled"] = new { type = "boolean" },
["status"] = new { type = "string" }
}
},
["RegionDetailResponse"] = new
{
type = "object",
required = new[] { "region", "correlation_id" },
properties = new Dictionary<string, object>
{
["region"] = SchemaRef("Region"),
["correlation_id"] = new { type = "string" }
}
},
["CitizenGroupMembershipRecord"] = new
{
type = "object",
required = new[] { "group_id", "name", "title", "active", "role_id", "powers", "notices" },
properties = new Dictionary<string, object>
{
["group_id"] = new { type = "string", format = "uuid" },
["name"] = new { type = "string" },
["title"] = new { type = "string" },
["active"] = new { type = "boolean" },
["role_id"] = new { type = "string", format = "uuid" },
["powers"] = new { type = "string", description = "64-Bit-Gruppenrechte als dezimale Zeichenkette" },
["notices"] = new { type = "boolean" }
}
},
["CitizenGroupMembershipsResponse"] = new
{
type = "object",
required = new[] { "groups", "offset", "limit", "total", "correlation_id" },
properties = new Dictionary<string, object>
{
["groups"] = new { type = "array", items = SchemaRef("CitizenGroupMembershipRecord") },
["offset"] = new { type = "integer", minimum = 0 },
["limit"] = new { type = "integer", minimum = 1, maximum = 100 },
["total"] = new { type = "integer", minimum = 0 },
["correlation_id"] = new { type = "string" }
}
},
["NexGroupCreateRequest"] = new
{
@@ -3445,18 +3723,268 @@ namespace NexVerse.Server.Api
["order_id"] = new { type = "string", format = "uuid" }
}
},
["BankingTransactionsResponse"] = new { type = "object" },
["BankingStatementResponse"] = new { type = "object" },
["BankingReconciliationResponse"] = new { type = "object" },
["PaymentRequestListResponse"] = new { type = "object" },
["PaymentRequestResponse"] = new { type = "object" },
["BankingPolicyResponse"] = new { type = "object" },
["CommerceOrderListResponse"] = new { type = "object" },
["CommerceOrderResponse"] = new { type = "object" },
["LandListingListResponse"] = new { type = "object" },
["LandListingResponse"] = new { type = "object" },
["LandLeaseListResponse"] = new { type = "object" },
["LandLeaseResponse"] = new { type = "object" },
["BankingLedgerPosting"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["posting_id"] = new { type = "string", format = "uuid" },
["account_id"] = new { type = "string", format = "uuid" },
["side"] = new { type = "string" },
["amount"] = new { type = "integer", format = "int64" },
["memo"] = new { type = "string" },
}
},
["BankingLedgerTransaction"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["transaction_id"] = new { type = "string", format = "uuid" },
["kind"] = new { type = "string" },
["reference"] = new { type = "string" },
["correlation_id"] = new { type = "string" },
["currency_code"] = new { type = "string" },
["occurred_at"] = new { type = "string", format = "date-time" },
["metadata"] = new { type = "object", additionalProperties = true },
["postings"] = new { type = "array", items = SchemaRef("BankingLedgerPosting") },
}
},
["BankingCurrency"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["code"] = new { type = "string" },
["symbol"] = new { type = "string" },
["minor_units"] = new { type = "integer", minimum = 0 },
}
},
["BankingStatement"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["account_id"] = new { type = "string", format = "uuid" },
["from"] = new { type = "string", format = "date-time" },
["to"] = new { type = "string", format = "date-time" },
["opening_balance"] = new { type = "integer", format = "int64" },
["closing_balance"] = new { type = "integer", format = "int64" },
["transactions"] = new { type = "array", items = SchemaRef("BankingLedgerTransaction") },
}
},
["BankingReconciliation"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["account_id"] = new { type = "string", format = "uuid" },
["derived_balance"] = new { type = "integer", format = "int64" },
["recomputed_balance"] = new { type = "integer", format = "int64" },
["transaction_count"] = new { type = "integer", format = "int64" },
["balanced"] = new { type = "boolean" },
}
},
["BankingPaymentRequest"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["request_id"] = new { type = "string", format = "uuid" },
["payee_account_id"] = new { type = "string", format = "uuid" },
["payer_account_id"] = new { type = "string", format = "uuid" },
["amount"] = new { type = "integer", format = "int64" },
["reference"] = new { type = "string" },
["status"] = new { type = "string" },
["created_at"] = new { type = "string", format = "date-time" },
["expires_at"] = new { type = "string", format = "date-time" },
["payment_transaction_id"] = new { type = new[] { "string", "null" }, format = "uuid" },
}
},
["BankingTransferPolicy"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["account_id"] = new { type = "string", format = "uuid" },
["max_per_transfer"] = new { type = "integer", format = "int64" },
["daily_outgoing_limit"] = new { type = "integer", format = "int64" },
["flat_fee"] = new { type = "integer", format = "int64" },
["fee_account_id"] = new { type = new[] { "string", "null" }, format = "uuid" },
}
},
["CommerceOrderRecord"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["order_id"] = new { type = "string", format = "uuid" },
["kind"] = new { type = "string" },
["buyer_account_id"] = new { type = "string", format = "uuid" },
["seller_account_id"] = new { type = "string", format = "uuid" },
["amount"] = new { type = "integer", format = "int64" },
["reference"] = new { type = "string" },
["external_reference"] = new { type = "string" },
["status"] = new { type = "string" },
["payment_transaction_id"] = new { type = new[] { "string", "null" }, format = "uuid" },
["refund_transaction_id"] = new { type = new[] { "string", "null" }, format = "uuid" },
["created_at"] = new { type = "string", format = "date-time" },
["completed_at"] = new { type = "string", format = "date-time" },
}
},
["LandListingRecord"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["listing_id"] = new { type = "string", format = "uuid" },
["type"] = new { type = "string" },
["region_id"] = new { type = "string", format = "uuid" },
["region_name"] = new { type = "string" },
["parcel_id"] = new { type = "string", format = "uuid" },
["parcel_local_id"] = new { type = "integer" },
["parcel_name"] = new { type = "string" },
["seller_account_id"] = new { type = "string", format = "uuid" },
["estate_id"] = new { type = new[] { "string", "null" }, format = "uuid" },
["area"] = new { type = "integer" },
["price"] = new { type = "integer", format = "int64" },
["rental_period_days"] = new { type = "integer" },
["active"] = new { type = "boolean" },
["created_at"] = new { type = "string", format = "date-time" },
}
},
["LandLeaseRecord"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["lease_id"] = new { type = "string", format = "uuid" },
["listing_id"] = new { type = "string", format = "uuid" },
["tenant_account_id"] = new { type = "string", format = "uuid" },
["landlord_account_id"] = new { type = "string", format = "uuid" },
["rent"] = new { type = "integer", format = "int64" },
["period_days"] = new { type = "integer" },
["starts_at"] = new { type = "string", format = "date-time" },
["ends_at"] = new { type = "string", format = "date-time" },
["next_due_at"] = new { type = "string", format = "date-time" },
["active"] = new { type = "boolean" },
["last_payment_transaction_id"] = new { type = new[] { "string", "null" }, format = "uuid" },
}
},
["BankingTransactionsResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["account_id"] = new { type = "string", format = "uuid" },
["transactions"] = new { type = "array", items = SchemaRef("BankingLedgerTransaction") },
["offset"] = new { type = "integer", minimum = 0 },
["limit"] = new { type = "integer", minimum = 1, maximum = 1000 },
["correlation_id"] = new { type = "string" },
}
},
["BankingStatementResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["statement"] = SchemaRef("BankingStatement"),
["currency"] = SchemaRef("BankingCurrency"),
["correlation_id"] = new { type = "string" },
}
},
["BankingReconciliationResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["reconciliation"] = SchemaRef("BankingReconciliation"),
["correlation_id"] = new { type = "string" },
}
},
["PaymentRequestListResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["account_id"] = new { type = "string", format = "uuid" },
["payment_requests"] = new { type = "array", items = SchemaRef("BankingPaymentRequest") },
["correlation_id"] = new { type = "string" },
}
},
["PaymentRequestResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["payment_request"] = SchemaRef("BankingPaymentRequest"),
["correlation_id"] = new { type = "string" },
}
},
["BankingPolicyResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["policy"] = SchemaRef("BankingTransferPolicy"),
["correlation_id"] = new { type = "string" },
}
},
["CommerceOrderListResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["account_id"] = new { type = "string", format = "uuid" },
["orders"] = new { type = "array", items = SchemaRef("CommerceOrderRecord") },
["correlation_id"] = new { type = "string" },
}
},
["CommerceOrderResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["order"] = SchemaRef("CommerceOrderRecord"),
["correlation_id"] = new { type = "string" },
}
},
["LandListingListResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["listings"] = new { type = "array", items = SchemaRef("LandListingRecord") },
["correlation_id"] = new { type = "string" },
}
},
["LandListingResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["listing"] = SchemaRef("LandListingRecord"),
["correlation_id"] = new { type = "string" },
}
},
["LandLeaseListResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["leases"] = new { type = "array", items = SchemaRef("LandLeaseRecord") },
["correlation_id"] = new { type = "string" },
}
},
["LandLeaseResponse"] = new
{
type = "object",
properties = new Dictionary<string, object>
{
["lease"] = SchemaRef("LandLeaseRecord"),
["correlation_id"] = new { type = "string" },
}
},
["EconomyTransferRequest"] = new
{
type = "object",
+176 -2
View File
@@ -2,6 +2,9 @@
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using OpenMetaverse.Imaging;
using System.Net;
using System.Text;
using System.Text.Json;
@@ -25,17 +28,22 @@ namespace NexVerse.Server.Api
{
private readonly IUserAccountService m_Accounts;
private readonly IProfilesData m_Profiles;
private readonly IAssetService m_Assets;
private const int MaxProfileAssetBytes = 8 * 1024 * 1024;
private const int MaxProfileImageWidth = 2048;
private readonly NexApiAuthenticator m_Authenticator;
private readonly INexAuditSink m_Audit;
public NexWebProfileV3Api(
IUserAccountService accounts,
IProfilesData profiles,
IAssetService assets,
NexApiAuthenticator authenticator,
INexAuditSink audit = null)
{
m_Accounts = accounts ?? throw new ArgumentNullException(nameof(accounts));
m_Profiles = profiles ?? throw new ArgumentNullException(nameof(profiles));
m_Assets = assets;
m_Authenticator = authenticator ?? throw new ArgumentNullException(nameof(authenticator));
m_Audit = audit ?? NullNexAuditSink.Instance;
}
@@ -43,8 +51,11 @@ namespace NexVerse.Server.Api
public void Handle(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
string[] segments = (httpRequest?.UriPath ?? string.Empty).Trim('/').Split('/');
// /api/v1/profiles/{uuid}
if (segments.Length != 4 ||
// /api/v1/profiles/{uuid} and profile-bound binary image:
// /api/v1/profiles/{uuid}/image. Never accept arbitrary asset IDs.
bool imageRequest = segments.Length == 5 &&
segments[4].Equals("image", StringComparison.OrdinalIgnoreCase);
if ((segments.Length != 4 && !imageRequest) ||
!segments[0].Equals("api", StringComparison.OrdinalIgnoreCase) ||
!segments[1].Equals("v1", StringComparison.OrdinalIgnoreCase) ||
!segments[2].Equals("profiles", StringComparison.OrdinalIgnoreCase) ||
@@ -61,6 +72,18 @@ namespace NexVerse.Server.Api
return;
}
if (imageRequest)
{
if (string.Equals(httpRequest.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
GetImage(account, httpRequest, httpResponse);
else
{
httpResponse.AddHeader("Allow", "GET");
WriteJson(httpResponse, HttpStatusCode.MethodNotAllowed, new { error = "method_not_allowed" });
}
return;
}
if (string.Equals(httpRequest.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
{
Get(account, httpRequest, httpResponse);
@@ -107,6 +130,8 @@ namespace NexVerse.Server.Api
username = account.Username,
display_name = account.EffectiveDisplayName,
profile_image = profile.ImageId.ToString(),
profile_image_url = profile.ImageId.IsZero() || m_Assets == null
? null : "/api/v1/profiles/" + account.PrincipalID + "/image",
about = profile.AboutText ?? string.Empty,
web_url = profile.WebUrl ?? string.Empty,
interests = new
@@ -128,6 +153,155 @@ namespace NexVerse.Server.Api
});
}
/// <summary>
/// Only the avatar's *current profile picture* can be retrieved.
/// OpenSim asset IDs alone never confer authority. Published profiles
/// may be read anonymously; private pictures require owner/admin.
/// In particular scripts, inventory textures and friends-only assets
/// can never be enumerated through this route.
/// </summary>
private void GetImage(UserAccount account, IOSHttpRequest request,
IOSHttpResponse response)
{
if (m_Assets == null)
{
WriteJson(response, HttpStatusCode.ServiceUnavailable,
new { error = "profile_image_service_unavailable" });
return;
}
UserProfileProperties profile =
new UserProfileProperties { UserId = account.PrincipalID };
string error = string.Empty;
if (!m_Profiles.GetAvatarProperties(ref profile, ref error))
{
WriteJson(response, HttpStatusCode.NotFound,
new { error = "profile_image_not_found" });
return;
}
if (!profile.PublishProfile)
{
if (!m_Authenticator.TryAuthenticate(request, NexScopes.ProfileRead,
out NexPrincipal principal, out UserAccount _,
out int status, out string authError))
{
WriteJson(response, (HttpStatusCode)status,
new { error = authError });
return;
}
if ((!UUID.TryParse(principal.Subject, out UUID subject) ||
subject != account.PrincipalID) &&
!principal.HasScope(NexScopes.AdminAll))
{
WriteJson(response, HttpStatusCode.NotFound,
new { error = "profile_image_not_found" });
return;
}
}
if (profile.ImageId.IsZero())
{
WriteJson(response, HttpStatusCode.NotFound,
new { error = "profile_image_not_found" });
return;
}
try
{
// Asset origin, MIME metadata and the image extension from a
// browser request are untrusted. Validate the actual bytes.
AssetBase asset = m_Assets.Get(profile.ImageId.ToString());
if (asset == null || asset.Data == null ||
asset.Data.Length == 0 ||
asset.Data.Length > MaxProfileAssetBytes ||
(asset.Type != (sbyte)AssetType.Texture &&
asset.Type != (sbyte)AssetType.ImageJPEG &&
asset.Type != (sbyte)AssetType.TextureTGA &&
asset.Type != (sbyte)AssetType.ImageTGA))
{
WriteJson(response, HttpStatusCode.NotFound,
new { error = "profile_image_not_found" });
return;
}
// Profile ownership is not itself proof that a random asset
// UUID is public. Without a separate verified inventory
// license/ACL, only the profile owner's own uploads may be
// exposed. This intentionally rejects third-party pictures.
if (!UUID.TryParse(asset.CreatorID, out UUID creator) ||
creator != account.PrincipalID)
{
WriteJson(response, HttpStatusCode.NotFound,
new { error = "profile_image_not_found" });
return;
}
byte[] raw = asset.Data;
byte[] result;
string mime;
if (raw.Length >= 8 && raw[0] == 0x89 && raw[1] == 0x50 &&
raw[2] == 0x4e && raw[3] == 0x47 &&
raw[4] == 0x0d && raw[5] == 0x0a &&
raw[6] == 0x1a && raw[7] == 0x0a)
{
result = raw;
mime = "image/png";
}
else if (raw.Length >= 3 && raw[0] == 0xff &&
raw[1] == 0xd8 && raw[2] == 0xff)
{
result = raw;
mime = "image/jpeg";
}
else
{
// OpenSim profile textures are commonly JPEG2000. Decode
// to a browser-supported image; do not forward raw J2K.
ManagedImage managedImage;
Image image;
if (!OpenJPEG.DecodeToImage(raw, out managedImage, out image) ||
image == null)
{
WriteJson(response, HttpStatusCode.UnsupportedMediaType,
new { error = "profile_image_decode_failed" });
return;
}
using (image)
{
if (image.Width <= 0 || image.Height <= 0 ||
image.Width > MaxProfileImageWidth ||
image.Height > MaxProfileImageWidth)
{
WriteJson(response, HttpStatusCode.RequestEntityTooLarge,
new { error = "profile_image_too_large" });
return;
}
using MemoryStream buffer = new MemoryStream();
image.Save(buffer, ImageFormat.Png);
if (buffer.Length > MaxProfileAssetBytes)
{
WriteJson(response, HttpStatusCode.RequestEntityTooLarge,
new { error = "profile_image_too_large" });
return;
}
result = buffer.ToArray();
mime = "image/png";
}
}
response.StatusCode = (int)HttpStatusCode.OK;
response.ContentType = mime;
response.AddHeader("X-Content-Type-Options", "nosniff");
// Conservative cache policy: an avatar may revoke public
// visibility immediately without old CDN/profile copies.
response.AddHeader("Cache-Control", "private, no-store");
response.KeepAlive = false;
response.RawBuffer = result;
}
catch (Exception)
{
// Do not disclose backend URLs, raw asset metadata or IDs.
WriteJson(response, HttpStatusCode.ServiceUnavailable,
new { error = "profile_image_service_unavailable" });
}
}
private void Patch(
UserAccount account,
Stream body,
+136
View File
@@ -0,0 +1,136 @@
# R287: Portal-World-API – tatsächliche Umsetzung und Abnahme
**Release-Zweig:** 0.9.3.10 Dev · **Quelle:** WORLD_API_FEHLENDE_ENDPUNKTE_R287.md
· keine Stable-Freigabe. Das R287-Dokument beschreibt Vorschläge, nicht
automatisch 16 bestehende Routen oder eine bereits erfolgte Betriebsabnahme.
Die dortigen Zählungen 135/182/139 sind Momentaufnahmen des Go-Portals,
nicht der aktuelle API-Gesamtvertrag.
## Implementiert (dieser Entwicklungs-Pull-Request)
| R287-Punkt | World API | Sicherheit |
| --- | --- | --- |
| P0: Avatarbild | GET `/api/v1/profiles/{principalId}/image` | Bild nur aus demselben Profil; öffentlich nur bei `PublishProfile`, sonst ProfileRead und Avatar-Owner/Admin. Vorläufig nur vom Avatar selbst erstellte Assettexturen; fremde Creator ohne nachgewiesene Assetrechte nicht ausliefern |
| P1: Event-Details | GET `/api/v1/events/{eventId}` | Öffentlich nur `Approved`, fremde Draft-UUID ergibt 404 |
| P1: Event-Korrektur | PATCH/DELETE `/api/v1/events/{eventId}` | `discovery:manage` plus Owner oder `admin:*`, Audit |
| P1: Classified-Details | GET `/api/v1/classifieds/{classifiedId}` | Öffentlich nur `Approved` |
| P1: Classified-Korrektur | PATCH/DELETE `/api/v1/classifieds/{classifiedId}` | `discovery:manage` plus Owner oder `admin:*`, Audit |
| P2: Eigene Gruppen | GET `/api/v1/groups/mine` | Authentifizierter Einwohner, `groups:read`, keine `agent_id`-Fremdabfrage, begrenzte Pagination |
Die bestehenden Event-/Classified-POST-Upsert-Routen sind zusätzlich gegen
Fremd-Owner, Eintragsübernahme und Status-Eskalation geschützt: normale
Einwohner erzeugen eigene Entwürfe; eine beliebig mitgesendete UUID,
`organizer_id`/`owner_id` oder `state=approved` ist keine Autorisierung.
Administrative Freigaben benötigen ausdrücklich `admin:*`.
PATCH ist absichtlich eng begrenzt: Name, Beschreibung, Bild, Tags, Eventzeiten
und Veranstaltungs-Eintrittspreis bzw. Classified-Kategorie. Änderungen an
Owner, Place-ID, UUID, Veröffentlichungsstatus und Moderationsdaten werden
nicht stillschweigend angenommen. Existierende POST-Upsert-Routen erzwingen ebenfalls Owner-/Statusschutz.
### Avatar-Bild-Bytes und Einschränkungen
Profilbilder im OpenSim-Assetstore sind häufig JPEG2000 (J2K), nicht PNG/JPEG.
Der neue Profil-Endpunkt liest die Referenz ausschließlich aus den aktuellen
`IProfilesData`-Daten, lädt die Bytes aus dem vorhandenen `IAssetService`,
prüft Typ/Creator und Größe, transkodiert J2K bei vorhandener OpenJPEG-
Runtime in PNG, setzt `X-Content-Type-Options: nosniff` sowie
`Cache-Control: private, no-store`. Bei fehlendem Codec/Assetservice
werden Fehler statt einer fremden Textur ausgeliefert.
Die Überprüfung der Creator-ID ist strenger als übliche OpenSim-Assetnutzung:
Ein von einem Fotografen hochgeladenes Porträt bleibt **vorerst** gesperrt,
bis ein expliziter Asset-Lizenz-/Public-Berechtigungsbeweis implementiert ist.
Dies ist ein bewusster Datenschutzvorrang, kein Beleg vollständiger Viewer-
Asset-Permissions-Parität. Ein Upload oder ein generischer Asset-Browser
gehört nicht zu diesem Endpunkt.
Profile-JSON enthält weiter `profile_image` als UUID und neu optional
`profile_image_url` als *relativen* Pfad. Die URL garantiert weder eine
Bilddatei noch Berechtigung. Ein privates Profil benötigt weiterhin Auth.
Keine API-Keys in Bild-URLs und keine fremden Texture-UUIDs ausprobieren.
## R287: Einzelstatus aller 16 vorgeschlagenen Operationen
Die Nummern entsprechen der Quell-Anforderung
`WORLD_API_FEHLENDE_ENDPUNKTE_R287.md`. Diese Tabelle unterscheidet
implementierte API-Routen von noch nicht freigegebenen Produktideen.
| Nr. | Angefragte Operation | Stand | Umsetzung / Begründung |
| --- | --- | --- | --- |
| 01 | `GET /assets/{assetId}/image` | **Alternative implementiert, Live offen** | `GET /profiles/{principalId}/image` bindet Asset an Avatar und Sichtbarkeit; kein Zugriff auf beliebige Asset-UUID |
| 02 | `GET /assets/{assetId}/metadata` | **Offen** | Eigentums-/Inventarrechte für generische Assets noch nicht nachgewiesen |
| 03 | `GET /notifications` | **Offen** | Echte Quellen, per-User-Persistenz und Berechtigungsmodell fehlen |
| 04 | `PATCH /notifications/{notificationId}/read` | **Offen** | Abhängig vom Notification-Datenmodell und Owner-Check |
| 05 | `POST /notifications/read-all` | **Offen** | Abhängig von Inbox-Persistenz und Zustimmung |
| 06 | `GET /events/{eventId}` | **Implementiert, Live offen** | Nur veröffentlichte Datensätze |
| 07 | `PATCH /events/{eventId}` | **Implementiert, Live offen** | `discovery:manage`, Owner/Admin, Whitelist, Audit |
| 08 | `DELETE /events/{eventId}` | **Implementiert, Live offen** | `discovery:manage`, Owner/Admin, Audit |
| 09 | `GET /classifieds/{classifiedId}` | **Implementiert, Live offen** | Nur veröffentlichte Datensätze |
| 10 | `PATCH /classifieds/{classifiedId}` | **Implementiert, Live offen** | `discovery:manage`, Owner/Admin, Whitelist, Audit |
| 11 | `DELETE /classifieds/{classifiedId}` | **Implementiert, Live offen** | `discovery:manage`, Owner/Admin, Audit |
| 12 | `GET /regions/{regionId}` | **Implementiert, Live offen** | `regions:read`, Grid-UUID-Einzelabfrage |
| 13 | `GET /groups/mine` | **Implementiert, Live offen** | `groups:read`, nur aktuell authentifizierter Einwohner |
| 14 | `GET /banking/accounts/{accountId}/owner` | **Offen** | Belegbare Ledger-Owner-Zuordnung und differenzierte Sichtbarkeit erforderlich |
| 15 | `POST /events/{eventId}/rsvp` | **Zurückgestellt** | Fakultativ; Teilnehmer-/Widerrufs- und Spam-Schutzmodell fehlt |
| 16 | `POST /economy/credits` | **Nicht freigegeben** | Payment-Webhook-Verifikation, Pflicht-Idempotenz, Ledger-Reconciliation und ausdrücklicher Zahlungsauftrag fehlen |
Damit sind **neun** der sechzehn Vorschläge technisch bearbeitet (einer
über eine bewusst sicherere alternative Route); **sieben** bleiben offen
oder absichtlich zurückgestellt. Der Anteil bezeichnet weder produktive
Freigabe noch vollständige End-to-End-Abnahme.
### Schemas und übrige Vertragslücken
Die **zwölf** zuvor leeren Banking-/Commerce-/Land-Response-Schemas
sind auf Basis des tatsächlich serialisierten C#-Payloads typisiert.
**Vier** Legacy-Discovery-/Chapter11-Sammelverträge enthalten nun
konkrete gemeinsame `properties`, sind wegen polymorpher Responses
jedoch weiterhin nicht als vollständig typisierte per-Route-DTOs zu
verstehen. Auth-Clients, Inventory-Outfits, Economy-Account-Owner und
einige andere im R287 genannten operativen Schemas benötigen weiterhin
gezielte Vertrags- und Berechtigungstests.
## Noch NICHT als fertig freigegeben
- Notifications: keine zentrale Inbox/Producer-, Persistenz- und Owner-
Read-Architektur in der geprüften World-API; nicht als leeres Fake-API
bereitstellen.
- Allgemeines GET `/assets/{assetId}/metadata`: würde Asset-/Inventory-
Eigentumsgrenzen betreffen; nicht ohne Autorisierung via Assetdienst öffnen.
- Einzelregion `GET /regions/{regionId}` und persönliche Bank-Account-
Owner-Auflösung: sichere Provider und Berechtigungsmodelle prüfen.
- Banking/Commerce/Land-Commerce: die zwölf bisher komplett leeren
Banking-/Payment-/Commerce-/Land-Response-Schemas sind anhand der
C#-Payloads jetzt konkret mit Ledger-Postings, Kontoauszügen, Salden,
Payment-Requests, Orders, Listings und Leases typisiert. Zehn
wiederverwendbare Record-Schemas wurden ergänzt. Bei Sammel-Operationen
bleiben weitere Pagination-/Owner-Erweiterungen gesondert zu prüfen.
- Die vier Legacy-Sammel-Schemas für Discovery und Chapter11 deklarieren
nun ihre gemeinsamen möglichen Felder; wegen polymorpher Antworttypen
sind sie ausdrücklich keine vollständigen per-Route-DTOs.
- Optionales RSVP und Payment-/Credits-POST: **keine API ohne ausdrückliche
Produkt-/Zahlungs- und Ledger-Idempotenzentscheidung**.
- Die Live-Abnahme, JPEG2000-Runtime-Konvertierung und echte private
Zweitavatar-Tests sind auf dem Betreibergrid noch nicht erbracht.
## Operator-Akzeptanz
1. Backup von Robust, Profile/Assetservice und `NexDiscoveryStore`; Pull,
Build und geordneten Start zuerst auf isolierter Testinstanz.
2. Viewer mit öffentlichem Besitzerprofil, privatem Fremdprofil, eigenem
privaten Profil und fremder Asset-Creator-ID testen. Verifizieren:
öffentlich erlaubtes Bild → PNG/JPEG-Bytes; private UUID → 404/401;
Besitzer-Token → richtige Bytes; falsche UUID → 404.
3. Mindestens eine echte J2K-Avatartextur mit Linux-Laufzeit prüfen;
keine Annahme, dass jedes libgdiplus/OpenJPEG-System gleich ist.
4. Event und Classified: öffentlich freigegeben GET 200; Entwurf GET 404;
fremder PATCH/DELETE 403; Owner-Änderung/Audit; nur erlaubte Felder.
5. Gruppenausgabe: eigenes `groups/mine`; Service-Principal, fremde
Avatar-UUID und abgelaufener Einwohner-Token dürfen nicht fremde
Gruppendaten offenlegen.
6. `GET /api/v1/openapi.json`, alle drei ChatGPT-MD-Downloads und
`tools/ci/verify_r287_portal_api.py` gegen denselben Commit prüfen.
**Keine produktiven NV$-Transfers, administrativen Schlüsselrotationen oder
Echtgeld-Transaktionen für diese Tests auslösen.**
+1
View File
@@ -1996,6 +1996,7 @@
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System.Drawing.Common"/>
<Reference name="NexVerse.Core"/>
<Reference name="OpenMetaverse"/>
<Reference name="OpenMetaverseTypes"/>
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
"""R287 portal coverage gates: authenticated image projection and Discovery CRUD."""
from pathlib import Path
root = Path(__file__).resolve().parents[2]
profile = (root / "NexVerse/Server/Api/NexWebProfileV3Api.cs").read_text()
connector = (root / "NexVerse/Server/Api/NexVerseWorldApiConnector.cs").read_text()
discovery = (root / "NexVerse/Server/Api/NexDiscoveryApi.cs").read_text()
groups = (root / "NexVerse/Server/Api/NexGroupsApi.cs").read_text()
api = (root / "NexVerse/Server/Api/NexVerseWorldApiHandlers.cs").read_text()
for x in ("GetImage(UserAccount", "profile.PublishProfile",
"NexScopes.ProfileRead", "creator != account.PrincipalID",
"OpenJPEG.DecodeToImage", '"image/png"', "profile_image_url",
"MaxProfileAssetBytes", "private, no-store"):
assert x in profile, "profile image security or transcode missing: " + x
assert "profilesData,\n assets," in connector, "asset service not wired"
for name in ("/api/v1/events/", "/api/v1/classifieds/"):
assert f'TryResourceId(path, "{name}"' in discovery
for x in ("RequireContentOwner(principal, existing.OrganizerId)",
"RequireContentOwner(principal, existing.OwnerId)",
"NexDiscoveryPublicationState.Approved",
'"discovery.event.deleted"', '"discovery.classified.updated"',
"RequireResidentActor(principal)",
"incoming.OrganizerId = actor", "incoming.OwnerId = actor",
"incoming.State = NexDiscoveryPublicationState.Draft",
"incoming.State != prior.State",
"incoming.PlaceId != prior.PlaceId",
"Unsupported or protected event PATCH field",
"Unsupported or protected classified PATCH field"):
assert x in discovery, "Discovery access control missing: " + x
for x in ('path == "/api/v1/groups/mine"',
"NexScopes.GroupsRead", "resident != account.PrincipalID.Guid",
"GetAgentGroupMemberships(selfGroupRequester, selfGroupRequester)"):
assert x in groups, "membership privacy missing: " + x
for path in ("/api/v1/profiles/{principalId}/image",
"/api/v1/events/{eventId}", "/api/v1/classifieds/{classifiedId}",
"/api/v1/groups/mine"):
assert f'["{path}"] =' in api, "missing OpenAPI: " + path
for schema in ("DiscoveryEventRecord", "DiscoveryEventPatch", "DiscoveryEventResponse",
"DiscoveryEventListResponse", "DiscoveryClassifiedRecord",
"DiscoveryClassifiedPatch", "DiscoveryClassifiedResponse",
"DiscoveryClassifiedListResponse", "DiscoveryDeletedResponse",
"CitizenGroupMembershipRecord", "CitizenGroupMembershipsResponse"):
assert f'["{schema}"] = new' in api, "missing JSON schema: " + schema
assert '["image/png"] = new' in api and 'format = "binary"' in api
# R287 originally named 16 response schemas that used empty opaque
# type=object entries. All 12 Banking/Commerce/Land envelopes now declare
# their real fields; the four polymorphic Discovery/Groups envelopes declare
# a documented subset and are not falsely advertised as complete DTOs.
for name, required in {
"BankingTransactionsResponse": ("account_id", "transactions", "limit"),
"BankingStatementResponse": ("statement", "currency", "correlation_id"),
"BankingReconciliationResponse": ("reconciliation",),
"PaymentRequestListResponse": ("payment_requests",),
"PaymentRequestResponse": ("payment_request",),
"BankingPolicyResponse": ("policy",),
"CommerceOrderListResponse": ("orders",),
"CommerceOrderResponse": ("order",),
"LandListingListResponse": ("listings",),
"LandListingResponse": ("listing",),
"LandLeaseListResponse": ("leases",),
"LandLeaseResponse": ("lease",),
"DiscoveryObjectResponse": ("place", "correlation_id"),
"DiscoveryMutationRequest": ("place_id", "name"),
"Chapter11ObjectResponse": ("group", "members", "correlation_id"),
"Chapter11MutationRequest": ("agent_id", "role_id"),
}.items():
start = api.index(f'["{name}"] = new')
segment = api[start: api.find("\n },", start) + 20]
assert "properties = new Dictionary<string, object>" in segment, name
for prop in required:
assert f'["{prop}"]' in segment, f"{name} lacks {prop}"
for x in ("RegionDetailResponse", "DiscoveryEventRecord",
"DiscoveryClassifiedRecord", "CitizenGroupMembershipsResponse"):
assert f'["{x}"] = new' in api
assert "no-store" in profile
print("R287 portal API owner isolation, 16 previously-empty schema names and live route contract: OK")