using ZB.MOM.WW.MxGateway.Server.Security.Authentication;

namespace ZB.MOM.WW.MxGateway.Server.Security.Authorization;

/// <summary>Provides scoped access to the current request's API key identity within a gRPC call context.</summary>
public interface IGatewayRequestIdentityAccessor
{
    /// <summary>The API key identity of the current request, or null if not set.</summary>
    ApiKeyIdentity? Current { get; }

    /// <summary>Temporarily pushes an identity onto the scope stack, returning a handle to restore the previous state.</summary>
    /// <param name="identity">API key identity to push.</param>
    /// <returns>A disposable handle that restores the previous identity when disposed.</returns>
    IDisposable Push(ApiKeyIdentity identity);
}
