DotNetBrightener.Infrastructure.Security
2025.0.2-preview-277
dotnet add package DotNetBrightener.Infrastructure.Security --version 2025.0.2-preview-277
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2025.0.2-preview-277
<PackageReference Include="DotNetBrightener.Infrastructure.Security" Version="2025.0.2-preview-277" />
paket add DotNetBrightener.Infrastructure.Security --version 2025.0.2-preview-277
#r "nuget: DotNetBrightener.Infrastructure.Security, 2025.0.2-preview-277"
// Install DotNetBrightener.Infrastructure.Security as a Cake Addin #addin nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.2-preview-277&prerelease // Install DotNetBrightener.Infrastructure.Security as a Cake Tool #tool nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.2-preview-277&prerelease
Security Infratructure Library
© DotNet Brightener
Installation
Run this in command line:
dotnet add package DotNetBrightener.Infrastructure.Security
Or add the following to .csproj
file
<PackageReference Include="DotNetBrightener.Infrastructure.Security" Version="2022.10.0" />
You should check the latest version from Nuget Site
Adding Permission System
- Register the Permission System to
IServiceCollection
serviceCollection.AddPermissionAuthorization();
- Calling the following before application starts.
var app = builder.Build();
// call this before app.Run()
app.LoadAndValidatePermissions();
app.Run();
If you use legacy Startup.cs
file then the app.LoadAndValidatePermissions()
should be called in Configure()
method
Authorization Extensions
- Authorize with
IAuthorizationService
var authorizationResult = await IAuthorizationService.AuthorizePermissionAsync(user, permissionKey);
- Authorize with
[PermissionAuthorize]
attribute
public class SomeController: Controller
{
[PermissionAuthorize("<your_permission_key>")]
public async Task<IActionResult> SomeAction()
{
// your action implementation
}
}
Automatically Register Permissions
Given the following class for defining permissions
public class SomePermissionsList: AutomaticPermissionProvider
{
/// <summary>
/// Description for Permission 1
/// </summary>
public const string Permission1 = "ThisIsKey.OfThePermission";
/// <summary>
/// Description for Permission 2
/// </summary>
public const string Permission2 = "Permission.Permission2";
}
You can register the permissions defined in this class into service collection by doing the following:
// with SomePermissionsList is the type of permission provider
serviceCollection.RegisterPermissionProvider<SomePermissionsList>();
The app.LoadAndValidatePermissions()
call above should automatically register the permissions you defined in the class provided
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- DotNetBrightener.CryptoEngine (>= 2025.0.2-preview-277)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on DotNetBrightener.Infrastructure.Security:
Package | Downloads |
---|---|
DotNetBrightener.Infrastructure.JwtAuthentication
Package Description |
|
DotNetBrightener.WebApp.CommonShared
Package Description |
|
DotNetBrightener.Infrastructure.ApiKeyAuthentication
Package Description |
|
DotNetBrightener.MultiTenancy
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Basic infrastructure provided for authorizing User with given permission