Table of Contents

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

Code string

Identifier of the policy that denied access; also the machine-readable code a client sees.

Resource ResourceRef?

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

string

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

string

Resource

Optional resource the policy was evaluated against.

public ResourceRef? Resource { get; init; }

Property Value

ResourceRef?

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

code string

Non-blank identifier of the policy that denied access.

resource ResourceRef

The resource the policy was evaluated against.

detail string

Optional 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

code string

Non-blank identifier of the policy that denied access.

detail string

Optional 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

code string

Non-blank identifier of the policy that denied access.

id object

Optional identifier of the specific instance.

detail string

Optional human-readable detail.

Returns

Error.Forbidden

A Error.Forbidden carrying the policy and resource.

Type Parameters

TResource

The resource the policy was evaluated against.