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
TenantIdstringThe tenant ID associated with the scope.
GrantTypestringThe type of the grant.
QualifierstringA 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
scopestringThe scope string to parse.
Returns
- GrantScope
A new GrantScope instance.
Exceptions
- ArgumentNullException
Thrown if
scopeis null.- ArgumentException
Thrown if the format of
scopeis 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
tenantIdstringThe tenant ID segment.
grantTypestringThe grant type segment.
qualifierstringThe qualifier segment.
errorstringWhen the method returns false, contains a description of the validation failure.
Returns
Exceptions
- ArgumentNullException
Thrown if any parameter is null or empty.