Table of Contents

Class LoginServerSigningKeyEntity

Namespace
FishMMO.Database.Npgsql.Entities
Assembly
FishMMO-DB.dll

Stores the HMAC-SHA256 signing key for a specific LoginServer instance. WorldServers and SceneServers look up this key by LoginServerId to validate auth tokens.

public class LoginServerSigningKeyEntity
Inheritance
LoginServerSigningKeyEntity
Inherited Members

Properties

ActivatedAtUtc

UTC timestamp at which the key became active (typically equals TimeCreated).

public DateTime ActivatedAtUtc { get; set; }

Property Value

DateTime

HmacKey

HMAC-SHA256 key used to sign and verify auth tokens.

The raw key material is stored as a PostgreSQL bytea column. On read, the column is returned as a byte[] that callers can zero out after use.

SERIALIZATION: The byte array is written and read directly via EF Core / Npgsql's bytea handling — no encoding, no envelope. The column width accommodates keys up to 64 bytes (SHA-512 half-length); callers generating 32-byte (SHA-256 half-length) keys are within range.

KEK ENVELOPE: In production, this value should be the ciphertext of the actual HMAC key encrypted under a Key Encryption Key (KEK) stored outside the database (e.g., AWS KMS, Azure Key Vault, or a local HSM). The LoginServer decrypts the envelope at startup to obtain the raw signing key in memory. This entity schema stores only the wrapped key; the KEK itself never touches the database.

public byte[] HmacKey { get; set; }

Property Value

byte[]

ID

Primary key (auto-increment).

public long ID { get; set; }

Property Value

long

IsActive

Whether this key is currently the active key used to sign new tokens. Old keys remain in the table (IsActive=false) so in-flight tokens can still be verified during the rotation overlap window.

public bool IsActive { get; set; }

Property Value

bool

LoginServer

public LoginServerEntity LoginServer { get; set; }

Property Value

LoginServerEntity

LoginServerId

Foreign key to the LoginServer that owns this signing key.

public long LoginServerId { get; set; }

Property Value

long

RotatedAtUtc

UTC timestamp at which the key was rotated out (became inactive). Null while active. Used to bound the verification overlap window and to identify which keys are safe to delete.

public DateTime? RotatedAtUtc { get; set; }

Property Value

DateTime?

TimeCreated

UTC timestamp when this key was first persisted.

public DateTime TimeCreated { get; set; }

Property Value

DateTime

Version

PostgreSQL xmin system column exposed as an EF Core concurrency token to detect concurrent rotations writing the same row. Updated automatically by the database on every row change.

public uint Version { get; set; }

Property Value

uint