fix: allow Experiences simulator machine credentials (#104)
* fix(auth): permit dedicated Experiences script machine scope * test(auth): cover Experiences machine key and management scope rejection * docs(auth): clarify Experiences script machine-key permissions
This commit is contained in:
1 parent
69e5c8bf56
commit
df7a6b8464
3 files changed
+44
-2
No files matched your search
@@ -99,7 +99,8 @@ namespace NexVerse.Core.Security
|
||||
NexScopes.EstatesRead,
|
||||
NexScopes.EstatesManage,
|
||||
NexScopes.EconomyRead,
|
||||
NexScopes.EconomyTransfer
|
||||
NexScopes.EconomyTransfer,
|
||||
NexScopes.ExperiencesScript
|
||||
},
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -582,7 +582,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.
|
||||
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 may receive only the `experiences:script` machine scope for Experience script operations; `experiences:manage` and administrator permissions remain unavailable to machine API keys.
|
||||
|
||||
API-key principals use subjects in the form `api-key:<key_id>`. Disabling a key takes effect immediately because validation is performed against the persistent key store on every request.
|
||||
|
||||
|
||||
@@ -98,6 +98,47 @@ internal static class Program
|
||||
rejectedAdmin,
|
||||
"API key store accepted admin:* scope");
|
||||
|
||||
NexApiKeyRegistration experienceRegistration =
|
||||
reloaded.Create(
|
||||
"Simulator Experiences adapter",
|
||||
new[] { NexScopes.ExperiencesScript });
|
||||
|
||||
Require(
|
||||
reloaded.TryValidate(
|
||||
experienceRegistration.ApiKey,
|
||||
out NexApiKeyRecord experienceKey) &&
|
||||
experienceKey.Scopes.Length == 1 &&
|
||||
string.Equals(
|
||||
experienceKey.Scopes[0],
|
||||
NexScopes.ExperiencesScript,
|
||||
StringComparison.OrdinalIgnoreCase),
|
||||
"Experiences script machine key could not be issued or validated");
|
||||
|
||||
PersistentNexApiKeyStore experiencesReloaded =
|
||||
new PersistentNexApiKeyStore(path);
|
||||
|
||||
Require(
|
||||
experiencesReloaded.TryValidate(
|
||||
experienceRegistration.ApiKey,
|
||||
out _),
|
||||
"Experiences script machine key did not survive a restart");
|
||||
|
||||
bool rejectedExperienceManagement = false;
|
||||
try
|
||||
{
|
||||
experiencesReloaded.Create(
|
||||
"unsafe Experiences management",
|
||||
new[] { NexScopes.ExperiencesManage });
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
rejectedExperienceManagement = true;
|
||||
}
|
||||
|
||||
Require(
|
||||
rejectedExperienceManagement,
|
||||
"Machine API keys must not receive experiences:manage");
|
||||
|
||||
Console.WriteLine(
|
||||
"NexVerse scoped API key regression: OK");
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user