DotNetBrightener.Infrastructure.Security
2024.0.14.6-preview-2730501
See the version list below for details.
dotnet add package DotNetBrightener.Infrastructure.Security --version 2024.0.14.6-preview-2730501
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2024.0.14.6-preview-2730501
<PackageReference Include="DotNetBrightener.Infrastructure.Security" Version="2024.0.14.6-preview-2730501" />
paket add DotNetBrightener.Infrastructure.Security --version 2024.0.14.6-preview-2730501
#r "nuget: DotNetBrightener.Infrastructure.Security, 2024.0.14.6-preview-2730501"
// Install DotNetBrightener.Infrastructure.Security as a Cake Addin #addin nuget:?package=DotNetBrightener.Infrastructure.Security&version=2024.0.14.6-preview-2730501&prerelease // Install DotNetBrightener.Infrastructure.Security as a Cake Tool #tool nuget:?package=DotNetBrightener.Infrastructure.Security&version=2024.0.14.6-preview-2730501&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 | 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. |
-
net8.0
- DotNetBrightener.CryptoEngine (>= 2024.0.14.6-preview-2730501)
- 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