AnubisScales.Authorization.AspNetCore
0.1.0
dotnet add package AnubisScales.Authorization.AspNetCore --version 0.1.0
NuGet\Install-Package AnubisScales.Authorization.AspNetCore -Version 0.1.0
<PackageReference Include="AnubisScales.Authorization.AspNetCore" Version="0.1.0" />
<PackageVersion Include="AnubisScales.Authorization.AspNetCore" Version="0.1.0" />
<PackageReference Include="AnubisScales.Authorization.AspNetCore" />
paket add AnubisScales.Authorization.AspNetCore --version 0.1.0
#r "nuget: AnubisScales.Authorization.AspNetCore, 0.1.0"
#:package AnubisScales.Authorization.AspNetCore@0.1.0
#addin nuget:?package=AnubisScales.Authorization.AspNetCore&version=0.1.0
#tool nuget:?package=AnubisScales.Authorization.AspNetCore&version=0.1.0
AnubisScales
AnubisScales is a .NET library for handling authorization.
Features
- Defines an abstraction layer for authorization behavior
- Implements Web API authorization handling behavior
Installation
Install AnubisScales using NuGet:
Usage
1. Register Services
In your Program.cs or Startup.cs, register AnubisScales services using the Fluent Builder pattern:
builder.Services.AddAnubisScales("YourSystemName")
.RegisterAuthorizationDataStore<YourAuthorizationDataStore>()
.RegisterIdentityResolveProvider<YourIdentityProvider>();
builder.Services.AddWebApiAuthorizationMiddlewareResultHandler();
2. Implement Required Interfaces
You need to implement two interfaces:
IAuthorizationDataStore - Manages authorization data:
public class YourAuthorizationDataStore : IAuthorizationDataStore
{
public ValueTask<bool> CheckHasPermissionAsync(
string systemName,
IAuthorizationFunction function,
IEnumerable<IAuthorizationIdentity> identities,
CancellationToken cancellationToken = default)
{
// Your permission checking logic
}
public IAsyncEnumerable<IAuthorizationFunction> GetFunctionsAsync(
string systemName,
CancellationToken cancellationToken = default)
{
// Return all functions
}
public ValueTask<IAuthorizationFunction?> FindFunctionAsync(
string systemName,
string functionName,
CancellationToken cancellationToken = default)
{
// Find function by name
}
}
IAuthorizationIdentityResolveProvider - Resolves user identities:
public class YourIdentityProvider : IAuthorizationIdentityResolveProvider
{
public IAsyncEnumerable<IAuthorizationIdentity> GetIdentitiesAsync(
CancellationToken cancellationToken = default)
{
// Return current user's identities
}
}
3. Define HTTP Functions
Create authorization functions for your API endpoints:
var getUserFunction = new HttpFunction(
Guid.NewGuid(),
"GetUser",
allowAnonymous: false,
new HttpMethodFeature("GET"),
new HttpPathFeature("/api/users/{id:int}", serviceProvider)
);
License
This project is licensed under the MIT License. For more details, please refer to the LICENSE file.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AnubisScales.Authorization.Abstractions (>= 0.1.0)
- AsyncMethodNameFixer (>= 2.3.0)
-
net8.0
- AnubisScales.Authorization.Abstractions (>= 0.1.0)
- AsyncMethodNameFixer (>= 2.3.0)
- Microsoft.AspNetCore.Authorization (>= 10.0.2)
-
net9.0
- AnubisScales.Authorization.Abstractions (>= 0.1.0)
- AsyncMethodNameFixer (>= 2.3.0)
- Microsoft.AspNetCore.Authorization (>= 10.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.