-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
namespace Privileged; | ||
|
||
/// <summary> | ||
/// Authorization action defaults | ||
/// </summary> | ||
public static class AuthorizationActions | ||
{ | ||
/// <summary> | ||
/// Special keyword represents any action will be matched | ||
/// </summary> | ||
public const string All = "all"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
namespace Privileged; | ||
|
||
/// <summary> | ||
/// Authorization subject defaults | ||
/// </summary> | ||
public static class AuthorizationSubjects | ||
{ | ||
/// <summary> | ||
/// Special keyword represents any subjects will be matched | ||
/// </summary> | ||
public const string All = "all"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Privileged; | ||
|
||
/// <summary> | ||
/// The authorization context definition used to check privileges | ||
/// </summary> | ||
public interface IAuthorizationContext | ||
{ | ||
/// <summary> | ||
/// Gets the authorization rules for this context. | ||
/// </summary> | ||
/// <value> | ||
/// The authorization rules for this context. | ||
/// </value> | ||
IReadOnlyCollection<AuthorizationRule> Rules { get; } | ||
|
||
/// <summary> | ||
/// Check if the specified <paramref name="action"/>, <paramref name="subject"/> and <paramref name="field"/> are authorized. | ||
/// </summary> | ||
/// <param name="action">The action to authorize.</param> | ||
/// <param name="subject">The subject to authorize.</param> | ||
/// <param name="field">The optional field to authorize.</param> | ||
/// <returns>true if the specified <paramref name="action"/>, <paramref name="subject"/> and <paramref name="field"/> are authorized; otherwise false</returns> | ||
bool Authorized(string? action, string? subject, string? field = null); | ||
|
||
/// <summary> | ||
/// Check if the specified <paramref name="action"/>, <paramref name="subject"/> and <paramref name="field"/> are unauthorized. | ||
/// </summary> | ||
/// <param name="action">The action to authorize.</param> | ||
/// <param name="subject">The subject to authorize.</param> | ||
/// <param name="field">The optional field to authorize.</param> | ||
/// <returns>true if the specified <paramref name="action"/>, <paramref name="subject"/> and <paramref name="field"/> are unauthorized; otherwise false</returns> | ||
bool Unauthorized(string? action, string? subject, string? field = null); | ||
|
||
/// <summary> | ||
/// Find the rules for the specified <paramref name="action"/>, <paramref name="subject"/> and <paramref name="field"/> | ||
/// </summary> | ||
/// <param name="action">The action to match.</param> | ||
/// <param name="subject">The subject to match.</param> | ||
/// <param name="field">The optional field to match.</param> | ||
/// <returns>The rules for the specified <paramref name="action"/>, <paramref name="subject"/> and <paramref name="field"/></returns> | ||
IEnumerable<AuthorizationRule> MatchRules(string? action, string? subject, string? field = null); | ||
} |