feat(sessions): record OwnerKeyId on session creation
Add a nullable string? OwnerKeyId property to GatewaySession that captures the API key identifier (KeyId) of the authenticated caller that opened the session. Wire it through ISessionManager.OpenSessionAsync → SessionManager → GatewaySession constructor. The gRPC service passes identityAccessor .Current?.KeyId; internal callers (GatewayAlarmMonitor, DashboardLiveDataService) pass null. Covers the positive and null cases with two new TDD-first tests.
This commit is contained in:
@@ -48,6 +48,7 @@ public sealed class GatewaySession
|
||||
pipeName,
|
||||
nonce,
|
||||
clientIdentity,
|
||||
ownerKeyId: null,
|
||||
clientSessionName,
|
||||
clientCorrelationId,
|
||||
commandTimeout,
|
||||
@@ -66,6 +67,7 @@ public sealed class GatewaySession
|
||||
/// <param name="pipeName">Name of the named pipe for gateway-worker IPC.</param>
|
||||
/// <param name="nonce">Security nonce for worker validation.</param>
|
||||
/// <param name="clientIdentity">Client identity from the authentication context.</param>
|
||||
/// <param name="ownerKeyId">API key identifier of the caller that created this session.</param>
|
||||
/// <param name="clientSessionName">Client-supplied session name.</param>
|
||||
/// <param name="clientCorrelationId">Client-supplied correlation identifier.</param>
|
||||
/// <param name="commandTimeout">Timeout for command invocation.</param>
|
||||
@@ -79,6 +81,7 @@ public sealed class GatewaySession
|
||||
string pipeName,
|
||||
string nonce,
|
||||
string? clientIdentity,
|
||||
string? ownerKeyId,
|
||||
string? clientSessionName,
|
||||
string? clientCorrelationId,
|
||||
TimeSpan commandTimeout,
|
||||
@@ -112,6 +115,7 @@ public sealed class GatewaySession
|
||||
PipeName = pipeName;
|
||||
Nonce = nonce;
|
||||
ClientIdentity = clientIdentity;
|
||||
OwnerKeyId = ownerKeyId;
|
||||
ClientSessionName = clientSessionName;
|
||||
ClientCorrelationId = clientCorrelationId;
|
||||
CommandTimeout = commandTimeout;
|
||||
@@ -148,6 +152,11 @@ public sealed class GatewaySession
|
||||
/// </summary>
|
||||
public string? ClientIdentity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the API key identifier of the caller that created this session.
|
||||
/// </summary>
|
||||
public string? OwnerKeyId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client-supplied session name.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user