Class Error.Forbidden
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Authorization policy refused the request.
public sealed record Error.Forbidden : Error, IEquatable<Error>, IEquatable<Error.Forbidden>
- Inheritance
-
Error.Forbidden
- Implements
- Inherited Members
- Extension Methods
Constructors
Forbidden(string, ResourceRef?)
Authorization policy refused the request.
public Forbidden(string Code, ResourceRef? Resource = null)
Parameters
CodestringIdentifier of the policy that denied access; also the machine-readable code a client sees.
ResourceResourceRef?Optional resource the policy was evaluated against.
Properties
Kind
Gets the stable domain slug for this case (e.g. "not-found",
"invalid-input"). Suitable for telemetry, observability dimensions, and as
the durable identifier that boundary layers translate into transport-specific
type identifiers.
public override string Kind { get; }
Property Value
PolicyId
Gets the identifier of the policy that denied access. A reading alias over Code rather than a second field, so the policy that refused the request and the code the client is told cannot drift apart.
public string PolicyId { get; }
Property Value
Resource
Optional resource the policy was evaluated against.
public ResourceRef? Resource { get; init; }
Property Value
Methods
For(string, ResourceRef, string?)
Creates a policy denial against an explicit resource reference.
public static Error.Forbidden For(string code, ResourceRef resource, string? detail = null)
Parameters
codestringNon-blank identifier of the policy that denied access.
resourceResourceRefThe resource the policy was evaluated against.
detailstringOptional human-readable detail.
Returns
- Error.Forbidden
A Error.Forbidden carrying the policy and resource.
ForPolicy(string, string?)
Convenience factory for a policy denial with no specific resource context.
public static Error.Forbidden ForPolicy(string code, string? detail = null)
Parameters
codestringNon-blank identifier of the policy that denied access.
detailstringOptional human-readable detail.
Returns
- Error.Forbidden
A resourceless Error.Forbidden.
For<TResource>(string, object?, string?)
Convenience factory that builds a Error.Forbidden for code
against the resource type TResource (its CLR name becomes the resource name).
public static Error.Forbidden For<TResource>(string code, object? id = null, string? detail = null)
Parameters
codestringNon-blank identifier of the policy that denied access.
idobjectOptional identifier of the specific instance.
detailstringOptional human-readable detail.
Returns
- Error.Forbidden
A Error.Forbidden carrying the policy and resource.
Type Parameters
TResourceThe resource the policy was evaluated against.