Table of Contents

Class GrantScope

Namespace
Excalibur.A3.Authorization.Grants
Assembly
Excalibur.A3.Core.dll

Represents the scope of a grant, including tenant ID, grant type, and qualifier.

public record GrantScope : IEquatable<GrantScope>
Inheritance
GrantScope
Implements
Inherited Members

Constructors

GrantScope(string, string, string)

Represents the scope of a grant, including tenant ID, grant type, and qualifier.

public GrantScope(string TenantId, string GrantType, string Qualifier)

Parameters

TenantId string

The tenant ID associated with the scope.

GrantType string

The type of the grant.

Qualifier string

A qualifier providing additional context for the grant type.

Exceptions

ArgumentNullException

Thrown if any parameter is null or empty.

Properties

GrantType

Gets or sets the type of the grant.

public string GrantType { get; init; }

Property Value

string

The type of the grant.

Exceptions

ArgumentNullException

Thrown if any parameter is null or empty.

Qualifier

Gets or sets the qualifier providing additional context for the grant type.

public string Qualifier { get; init; }

Property Value

string

The qualifier for the grant type.

Exceptions

ArgumentNullException

Thrown if any parameter is null or empty.

TenantId

Gets or sets the tenant ID associated with the scope.

public string TenantId { get; init; }

Property Value

string

The tenant ID.

Exceptions

ArgumentNullException

Thrown if any parameter is null or empty.

Methods

FromString(string)

Creates a GrantScope instance from a string in the format '[TenantId]:[GrantType]:[Qualifier]'.

public static GrantScope FromString(string scope)

Parameters

scope string

The scope string to parse.

Returns

GrantScope

A new GrantScope instance.

Exceptions

ArgumentNullException

Thrown if scope is null.

ArgumentException

Thrown if the format of scope is invalid.

ToString()

Returns a string representation of the scope in the format '[TenantId]:[GrantType]:[Qualifier]'.

public override string ToString()

Returns

string

A string representation of the scope.

Exceptions

ArgumentNullException

Thrown if any parameter is null or empty.

Validate(string, string, string, out string?)

Validates whether the specified scope string contains valid wildcard patterns. Wildcards must be a full segment for TenantId/GrantType, or , {prefix}., or {prefix}/ for the Qualifier. Patterns like **, *partial, or mid-qualifier wildcards are rejected.

public static bool Validate(string tenantId, string grantType, string qualifier, out string? error)

Parameters

tenantId string

The tenant ID segment.

grantType string

The grant type segment.

qualifier string

The qualifier segment.

error string

When the method returns false, contains a description of the validation failure.

Returns

bool

true if the wildcard patterns are valid; otherwise, false.

Exceptions

ArgumentNullException

Thrown if any parameter is null or empty.