w4c-workflows-api/Services/Security/EgressDecision.cs
2026-09-12 01:02:46 +03:00

23 lines
838 B
C#

namespace w4c_workflows.Services.Security;
/// <summary>
/// Result of evaluating an outbound target against the egress policy. A denied
/// decision carries a stable <see cref="Code"/> for failure routing and a
/// human-readable <see cref="Reason"/> for the run log.
/// </summary>
public sealed record EgressDecision
{
public required bool Allowed { get; init; }
/// <summary>Stable machine code, e.g. <c>scheme_not_allowed</c>.</summary>
public string? Code { get; init; }
/// <summary>Human-readable explanation, safe to surface to the workflow author.</summary>
public string? Reason { get; init; }
public static EgressDecision Permit() => new() { Allowed = true };
public static EgressDecision Block(string code, string reason)
=> new() { Allowed = false, Code = code, Reason = reason };
}