DotNetBrightener.Infrastructure.Security 2025.0.1-rc-243301701

This is a prerelease version of DotNetBrightener.Infrastructure.Security.
dotnet add package DotNetBrightener.Infrastructure.Security --version 2025.0.1-rc-243301701                
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2025.0.1-rc-243301701                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetBrightener.Infrastructure.Security" Version="2025.0.1-rc-243301701" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.Infrastructure.Security --version 2025.0.1-rc-243301701                
#r "nuget: DotNetBrightener.Infrastructure.Security, 2025.0.1-rc-243301701"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DotNetBrightener.Infrastructure.Security as a Cake Addin
#addin nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.1-rc-243301701&prerelease

// Install DotNetBrightener.Infrastructure.Security as a Cake Tool
#tool nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.1-rc-243301701&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

  1. Register the Permission System to IServiceCollection
serviceCollection.AddPermissionAuthorization();
  1. 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

  1. Authorize with IAuthorizationService
var authorizationResult = await IAuthorizationService.AuthorizePermissionAsync(user, permissionKey);
  1. 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 Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
2025.0.1-rc-243301701 36 11/25/2024
2024.0.14.6 28 11/25/2024
2024.0.14.6-rc-243031001 150 10/29/2024
2024.0.14.6-rc-243030701 113 10/29/2024
2024.0.14.6-rc-242840501 105 10/10/2024
2024.0.14.6-rc-242820305 108 10/8/2024
2024.0.14.6-rc-242771401 230 10/3/2024
2024.0.14.6-rc-242770501 102 10/3/2024
2024.0.14.6-rc-242770201 121 10/3/2024
2024.0.14.6-rc-242761801 108 10/2/2024
2024.0.14.6-rc-242761601 119 10/2/2024
2024.0.14.6-rc-242761501 106 10/2/2024
2024.0.14.6-rc-242761401 111 10/2/2024
2024.0.14.6-rc-242760701 123 10/2/2024
2024.0.14.6-rc-242751002 114 10/1/2024
2024.0.14.6-rc-242750901 121 10/1/2024
2024.0.14.6-rc-242750502 111 10/1/2024
2024.0.14.6-rc-242750201 112 10/1/2024
2024.0.14.6-rc-242741501 105 9/30/2024
2024.0.14.6-rc-242730701 135 9/29/2024
2024.0.14.6-preview-2730501 108 9/29/2024
2024.0.14.6-preview-2701501 142 9/26/2024
2024.0.14.6-preview-2620901 165 9/18/2024
2024.0.14.6-preview-2570701 128 9/13/2024
2024.0.14.6-preview-2510703 205 9/7/2024
2024.0.14.6-preview-2480501 147 9/4/2024
2024.0.14.6-preview-2430401 169 8/30/2024
2024.0.14.6-preview-242730701 109 9/29/2024
2024.0.14.6-preview-2421703 132 8/29/2024
2024.0.14.6-preview-2421701 119 8/29/2024
2024.0.14.6-preview-2420901 118 8/29/2024
2024.0.14.6-preview-2390101 153 8/26/2024
2024.0.14.6-preview-2381603 145 8/25/2024
2024.0.14.6-preview-2341601 170 8/21/2024
2024.0.14.6-preview-2321602 148 8/20/2024
2024.0.14.6-preview-2190801 172 8/6/2024
2024.0.14.6-preview-2041501 127 7/22/2024
2024.0.14.6-preview-1920603 194 7/10/2024
2024.0.14.6-preview-1920301 125 7/10/2024
2024.0.14.6-preview-1911302 133 7/9/2024
2024.0.14.6-preview-1901001 153 7/8/2024
2024.0.14.6-preview-1900901 149 7/8/2024
2024.0.14.6-preview-1900801 118 7/8/2024
2024.0.14.6-preview-1860304 134 7/4/2024
2024.0.14.5 204 7/1/2024
2024.0.14.5-preview-1811601 140 6/29/2024
2024.0.14.5-preview-1810501 158 6/29/2024
2024.0.14.5-preview-180132 161 6/28/2024
2024.0.14.5-preview-180131 139 6/28/2024
2024.0.14.5-preview-180121 132 6/28/2024
2024.0.14.4 176 6/27/2024
2024.0.14.4-preview-7 137 6/27/2024
2024.0.14.3 154 6/21/2024
2024.0.14.1 143 6/6/2024
2024.0.14.1-preview 128 6/6/2024
2024.0.14-preview-1 119 6/6/2024
2024.0.13.8-preview 135 6/6/2024
2024.0.13.1-preview-0146 135 6/6/2024
2024.0.12.15803-preview-03 130 6/6/2024
2024.0.12.15608 140 6/4/2024
2024.0.12.15515 219 6/3/2024
2024.0.12.15220 129 5/31/2024
2024.0.12.15220-alpha31-240... 114 5/31/2024
2024.0.12.14911 176 5/28/2024
2024.0.12.14910-alpha28-240... 127 5/28/2024
2024.0.12.14823 144 5/27/2024
2024.0.12.14522-alpha7-2405... 147 5/24/2024
2024.0.12.14514-alpha6-2405... 138 5/24/2024
2024.0.12.14511 162 5/24/2024
2024.0.12.14314 191 5/22/2024
2024.0.12.14114 171 5/20/2024
2024.0.12.12815 182 5/7/2024
2024.0.12.12814 149 5/7/2024
2024.0.12.12721 171 5/6/2024
2024.0.12.12702 163 5/5/2024
2024.0.12.12622 177 5/5/2024
2024.0.12.12514 151 5/4/2024
2024.0.12.12512 157 5/4/2024
2024.0.12.12510 151 5/4/2024
2024.0.12.12420 133 5/3/2024
2024.0.12.12319 103 5/2/2024
2024.0.12.12319-rc-2405021801 94 5/2/2024
2024.0.12.12318 111 5/2/2024
2024.0.12.12215 139 5/1/2024
2024.0.12.12011 145 4/29/2024
2024.0.12.11720 158 4/26/2024
2024.0.12.11719 146 4/26/2024
2024.0.12.11621 180 4/25/2024
2024.0.12.11523 147 4/24/2024
2024.0.12.11522 150 4/24/2024
2024.0.12.11417 172 4/23/2024
2024.0.12.11400 173 4/22/2024
2024.0.12.11316 159 4/22/2024
2024.0.11.10220 148 4/11/2024
2024.0.11.10120 130 4/10/2024
2024.0.11.10119 128 4/10/2024
2024.0.11.10115 144 4/10/2024
2024.0.11.9914 165 4/8/2024
2024.0.11.9901 146 4/7/2024
2024.0.11.9823 148 4/7/2024
2024.0.11.9401 165 4/2/2024
2024.0.11.9301 149 4/1/2024
2024.0.11.9206 151 3/31/2024
2024.0.11.9205 138 3/31/2024
2024.0.11.8200 178 3/21/2024
2024.0.11.8122 134 3/21/2024
2024.0.11.8120 136 3/21/2024
2024.0.11.7320 192 3/13/2024
2024.0.11.7316 157 3/13/2024
2024.0.11.7310 153 3/13/2024
2024.0.11 153 3/13/2024
2024.0.10 169 3/3/2024
2024.0.9 166 2/27/2024
2024.0.8 202 2/1/2024
2024.0.7 158 1/26/2024
2024.0.6 147 1/25/2024
2024.0.5 141 1/24/2024
2024.0.4 139 1/24/2024
2024.0.3 152 1/22/2024
2024.0.2 218 1/10/2024
2024.0.1 160 1/9/2024
2024.0.1-alpha-3 147 1/9/2024
2024.0.1-alpha-2 144 1/9/2024
2024.0.1-alpha-1 164 1/3/2024
2024.0.0 202 12/26/2023
2023.0.27 212 12/21/2023
2023.0.26 182 12/21/2023
2023.0.25 205 12/11/2023
2023.0.24 189 12/8/2023
2023.0.23 174 12/6/2023
2023.0.21 254 12/4/2023
2023.0.20 231 11/27/2023
2023.0.19 194 11/20/2023
2023.0.18 207 10/25/2023
2023.0.17 249 10/22/2023
2023.0.16 275 10/16/2023
2023.0.16-alpha-1 138 10/16/2023
2023.0.15 194 10/14/2023
2023.0.14 169 10/14/2023
2023.0.13 175 10/14/2023
2023.0.12 185 10/14/2023
2023.0.11 173 10/10/2023
2023.0.10 178 10/9/2023
2023.0.9 284 8/16/2023
2023.0.8 256 8/15/2023
2023.0.8-alpha-2 291 5/31/2023
2023.0.7 620 5/12/2023
2023.0.6 274 5/10/2023
2023.0.5 232 5/7/2023
2023.0.4 264 4/22/2023
2023.0.3 310 4/19/2023
2023.0.2 299 4/6/2023
2023.0.1 281 3/13/2023
2022.10.4 362 11/9/2022
2022.10.3 421 10/19/2022
2022.10.2 488 10/19/2022
2022.10.0 474 10/16/2022
2022.7.1 505 7/18/2022

Basic infrastructure provided for authorizing User with given permission