Class GrantKey
- Namespace
- Excalibur.A3.Authorization.Grants
- Assembly
- Excalibur.A3.Core.dll
Utility class for representing and managing unique keys associated with grants in a system. A grant key is composed of a userId and a GrantScope, where the GrantScope encapsulates the tenantId, grantType, and qualifier. This class ensures consistent construction, parsing, and serialization of grant keys.
public sealed class GrantKey
- Inheritance
-
GrantKey
- Inherited Members
Constructors
GrantKey(string)
Initializes a new instance of the GrantKey class from a serialized key string.
public GrantKey(string key)
Parameters
keystringThe serialized grant key in the format {userId}:{tenant}:{type}:{qualifier}.
Exceptions
- ArgumentException
Thrown if the key is null, empty, or improperly formatted.
GrantKey(string?, string?, string?, string?)
Initializes a new instance of the GrantKey class.
public GrantKey(string? userId, string? tenantId, string? grantType, string? qualifier)
Parameters
userIdstringThe user ID associated with the grant.
tenantIdstringThe tenant ID for the grant.
grantTypestringThe type of the grant.
qualifierstringThe qualifier for the grant.
Exceptions
- ArgumentException
Thrown if any argument is null or empty.
Properties
Scope
Gets the scope of the grant, which includes tenant, type, and qualifier.
public GrantScope Scope { get; init; }
Property Value
- GrantScope
The scope of the grant.
UserId
Gets the user ID associated with the grant.
public string UserId { get; init; }
Property Value
- string
The user ID.
Methods
ToString()
Converts the GrantKey instance to its string representation.
public override string ToString()
Returns
- string
A string representation of the grant key in the format {userId}:{tenant}:{type}:{qualifier}.