RynthDreamWeave: pin the profile-key format and enforce its contract
Golden pins for dreamweave/coldeve alice keys, a Busy-Begin stale-window pin, and Key returns null when the result fails ServerWebOpen.IsValidProfileKey. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2522534979
commit
acfd04fa46
2 changed files with 17 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
|
||||
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||
|
||||
|
|
@ -11,13 +12,14 @@ internal static class WebProfile
|
|||
/// <summary>
|
||||
/// "serverId/" plus the first 32 lowercase hex chars of SHA-256(UTF-8(serverId + "\n" + the trimmed,
|
||||
/// lower-cased account)); null when there is no account. The server id (not the world name) keeps
|
||||
/// one site's cookies together. The hash keeps the account name out of the folder name. The result
|
||||
/// passes ServerWebOpen.IsValidProfileKey when serverId matches ^[a-z0-9-]{1,32}$.
|
||||
/// one site's cookies together. The hash keeps the account name out of the folder name. A result that fails
|
||||
/// ServerWebOpen.IsValidProfileKey (a serverId outside ^[a-z0-9-]{1,32}$) is null, never a bad key.
|
||||
/// </summary>
|
||||
public static string? Key(string serverId, string? account)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(account)) return null;
|
||||
byte[] hash = SHA256.HashData(Encoding.UTF8.GetBytes(serverId + "\n" + account.Trim().ToLowerInvariant()));
|
||||
return serverId + "/" + Convert.ToHexString(hash).ToLowerInvariant().Substring(0, 32);
|
||||
string key = serverId + "/" + Convert.ToHexString(hash).ToLowerInvariant().Substring(0, 32);
|
||||
return ServerWebOpen.IsValidProfileKey(key) ? key : null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue