DotNetBrightener.Infrastructure.Security
                              
                            
                                2025.0.9-preview-535
                            
                        
                    See the version list below for details.
dotnet add package DotNetBrightener.Infrastructure.Security --version 2025.0.9-preview-535
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2025.0.9-preview-535
<PackageReference Include="DotNetBrightener.Infrastructure.Security" Version="2025.0.9-preview-535" />
<PackageVersion Include="DotNetBrightener.Infrastructure.Security" Version="2025.0.9-preview-535" />
<PackageReference Include="DotNetBrightener.Infrastructure.Security" />
paket add DotNetBrightener.Infrastructure.Security --version 2025.0.9-preview-535
#r "nuget: DotNetBrightener.Infrastructure.Security, 2025.0.9-preview-535"
#:package DotNetBrightener.Infrastructure.Security@2025.0.9-preview-535
#addin nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.9-preview-535&prerelease
#tool nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.9-preview-535&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-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 was computed. 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. | 
- 
                                                    net9.0- DotNetBrightener.CryptoEngine (>= 2025.0.9-preview-535)
- Newtonsoft.Json (>= 13.0.4)
 
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