Class AuthorizationRequirement
- Namespace
- Cratis.Arc.Authorization
- Assembly
- Cratis.Arc.Core.dll
Represents one authorization requirement declared on a type or method: the caller must be authenticated and, when roles are given, hold at least one of them.
public record AuthorizationRequirement : IEquatable<AuthorizationRequirement>
- Inheritance
-
AuthorizationRequirement
- Implements
- Inherited Members
- Extension Methods
Remarks
Every requirement declared on a member must be satisfied, so two stacked authorization attributes require both,
which matches how ASP.NET Core combines its own [Authorize] attributes.
Constructors
AuthorizationRequirement(AuthorizationRequirement)
protected AuthorizationRequirement(AuthorizationRequirement original)
Parameters
originalAuthorizationRequirement
AuthorizationRequirement(IReadOnlyList<string>)
Represents one authorization requirement declared on a type or method: the caller must be authenticated and, when roles are given, hold at least one of them.
public AuthorizationRequirement(IReadOnlyList<string> AnyOfRoles)
Parameters
AnyOfRolesIReadOnlyList<string>The roles the caller must hold at least one of, or empty when authentication alone suffices.
Remarks
Every requirement declared on a member must be satisfied, so two stacked authorization attributes require both,
which matches how ASP.NET Core combines its own [Authorize] attributes.
Properties
AnyOfRoles
The roles the caller must hold at least one of, or empty when authentication alone suffices.
public IReadOnlyList<string> AnyOfRoles { get; init; }
Property Value
AuthenticationSchemes
Gets the explicitly requested authentication schemes.
public IReadOnlyList<string> AuthenticationSchemes { get; init; }
Property Value
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
Policy
Gets the named policy, if any.
public string? Policy { get; init; }
Property Value
Methods
Deconstruct(out IReadOnlyList<string>)
public void Deconstruct(out IReadOnlyList<string> AnyOfRoles)
Parameters
AnyOfRolesIReadOnlyList<string>
Equals(AuthorizationRequirement?)
public virtual bool Equals(AuthorizationRequirement? other)
Parameters
otherAuthorizationRequirement
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
FromAttribute(string?, string?, string?)
Creates a requirement from the settings of an authorization attribute.
public static AuthorizationRequirement FromAttribute(string? roles, string? policy, string? schemes)
Parameters
rolesstringComma-separated roles.
policystringThe named policy.
schemesstringComma-separated authentication schemes.
Returns
- AuthorizationRequirement
The complete requirement.
Exceptions
- InvalidAuthorizationConfiguration
A policy name is whitespace or a scheme name in the list is empty.
FromRoles(string?)
Creates a requirement from a comma-separated roles value as carried by an authorization attribute.
public static AuthorizationRequirement FromRoles(string? roles)
Parameters
rolesstringThe comma-separated roles, or null or empty when authentication alone suffices.
Returns
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(AuthorizationRequirement?, AuthorizationRequirement?)
public static bool operator ==(AuthorizationRequirement? left, AuthorizationRequirement? right)
Parameters
leftAuthorizationRequirementrightAuthorizationRequirement
Returns
operator !=(AuthorizationRequirement?, AuthorizationRequirement?)
public static bool operator !=(AuthorizationRequirement? left, AuthorizationRequirement? right)
Parameters
leftAuthorizationRequirementrightAuthorizationRequirement