DotNetBrightener.Infrastructure.Security 2025.0.3

dotnet add package DotNetBrightener.Infrastructure.Security --version 2025.0.3                
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2025.0.3                
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.3" />                
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.3                
#r "nuget: DotNetBrightener.Infrastructure.Security, 2025.0.3"                
#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.3

// Install DotNetBrightener.Infrastructure.Security as a Cake Tool
#tool nuget:?package=DotNetBrightener.Infrastructure.Security&version=2025.0.3                

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.  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. 
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.3 112 2/10/2025
2025.0.3-preview-288 110 2/10/2025
2025.0.2 127 1/21/2025
2025.0.2-preview-278 97 1/21/2025
2025.0.2-preview-277 111 12/16/2024
2025.0.1-rc-243301701 352 11/25/2024
2024.0.14.6 148 11/25/2024
2024.0.14.6-rc-243031001 198 10/29/2024
2024.0.14.6-rc-243030701 129 10/29/2024
2024.0.14.6-rc-242840501 125 10/10/2024
2024.0.14.6-rc-242820305 120 10/8/2024
2024.0.14.6-rc-242771401 253 10/3/2024
2024.0.14.6-rc-242770501 114 10/3/2024
2024.0.14.6-rc-242770201 132 10/3/2024
2024.0.14.6-rc-242761801 122 10/2/2024
2024.0.14.6-rc-242761601 133 10/2/2024
2024.0.14.6-rc-242761501 120 10/2/2024
2024.0.14.6-rc-242761401 120 10/2/2024
2024.0.14.6-rc-242760701 137 10/2/2024
2024.0.14.6-rc-242751002 125 10/1/2024
2024.0.14.6-rc-242750901 134 10/1/2024
2024.0.14.6-rc-242750502 121 10/1/2024
2024.0.14.6-rc-242750201 123 10/1/2024
2024.0.14.6-rc-242741501 119 9/30/2024
2024.0.14.6-rc-242730701 146 9/29/2024
2024.0.14.6-preview-2730501 120 9/29/2024
2024.0.14.6-preview-2701501 153 9/26/2024
2024.0.14.6-preview-2620901 175 9/18/2024
2024.0.14.6-preview-2570701 136 9/13/2024
2024.0.14.6-preview-2510703 213 9/7/2024
2024.0.14.6-preview-2480501 157 9/4/2024
2024.0.14.6-preview-2430401 177 8/30/2024
2024.0.14.6-preview-242730701 119 9/29/2024
2024.0.14.6-preview-2421703 142 8/29/2024
2024.0.14.6-preview-2421701 131 8/29/2024
2024.0.14.6-preview-2420901 128 8/29/2024
2024.0.14.6-preview-2390101 164 8/26/2024
2024.0.14.6-preview-2381603 154 8/25/2024
2024.0.14.6-preview-2341601 179 8/21/2024
2024.0.14.6-preview-2321602 162 8/20/2024
2024.0.14.6-preview-2190801 181 8/6/2024
2024.0.14.6-preview-2041501 134 7/22/2024
2024.0.14.6-preview-1920603 203 7/10/2024
2024.0.14.6-preview-1920301 134 7/10/2024
2024.0.14.6-preview-1911302 140 7/9/2024
2024.0.14.6-preview-1901001 161 7/8/2024
2024.0.14.6-preview-1900901 156 7/8/2024
2024.0.14.6-preview-1900801 127 7/8/2024
2024.0.14.6-preview-1860304 141 7/4/2024
2024.0.14.5 215 7/1/2024
2024.0.14.5-preview-1811601 147 6/29/2024
2024.0.14.5-preview-1810501 166 6/29/2024
2024.0.14.5-preview-180132 170 6/28/2024
2024.0.14.5-preview-180131 147 6/28/2024
2024.0.14.5-preview-180121 140 6/28/2024
2024.0.14.4 187 6/27/2024
2024.0.14.4-preview-7 144 6/27/2024
2024.0.14.3 169 6/21/2024
2024.0.14.1 155 6/6/2024
2024.0.14.1-preview 137 6/6/2024
2024.0.14-preview-1 125 6/6/2024
2024.0.13.8-preview 142 6/6/2024
2024.0.13.1-preview-0146 145 6/6/2024
2024.0.12.15803-preview-03 138 6/6/2024
2024.0.12.15608 151 6/4/2024
2024.0.12.15515 230 6/3/2024
2024.0.12.15220 140 5/31/2024
2024.0.12.15220-alpha31-240... 124 5/31/2024
2024.0.12.14911 188 5/28/2024
2024.0.12.14910-alpha28-240... 137 5/28/2024
2024.0.12.14823 155 5/27/2024
2024.0.12.14522-alpha7-2405... 160 5/24/2024
2024.0.12.14514-alpha6-2405... 145 5/24/2024
2024.0.12.14511 172 5/24/2024
2024.0.12.14314 207 5/22/2024
2024.0.12.14114 183 5/20/2024
2024.0.12.12815 199 5/7/2024
2024.0.12.12814 162 5/7/2024
2024.0.12.12721 180 5/6/2024
2024.0.12.12702 172 5/5/2024
2024.0.12.12622 189 5/5/2024
2024.0.12.12514 165 5/4/2024
2024.0.12.12512 174 5/4/2024
2024.0.12.12510 168 5/4/2024
2024.0.12.12420 149 5/3/2024
2024.0.12.12319 117 5/2/2024
2024.0.12.12319-rc-2405021801 105 5/2/2024
2024.0.12.12318 124 5/2/2024
2024.0.12.12215 154 5/1/2024
2024.0.12.12011 154 4/29/2024
2024.0.12.11720 168 4/26/2024
2024.0.12.11719 155 4/26/2024
2024.0.12.11621 189 4/25/2024
2024.0.12.11523 158 4/24/2024
2024.0.12.11522 159 4/24/2024
2024.0.12.11417 183 4/23/2024
2024.0.12.11400 183 4/22/2024
2024.0.12.11316 170 4/22/2024
2024.0.11.10220 160 4/11/2024
2024.0.11.10120 141 4/10/2024
2024.0.11.10119 138 4/10/2024
2024.0.11.10115 158 4/10/2024
2024.0.11.9914 177 4/8/2024
2024.0.11.9901 157 4/7/2024
2024.0.11.9823 159 4/7/2024
2024.0.11.9401 174 4/2/2024
2024.0.11.9301 157 4/1/2024
2024.0.11.9206 159 3/31/2024
2024.0.11.9205 147 3/31/2024
2024.0.11.8200 186 3/21/2024
2024.0.11.8122 144 3/21/2024
2024.0.11.8120 144 3/21/2024
2024.0.11.7320 205 3/13/2024
2024.0.11.7316 164 3/13/2024
2024.0.11.7310 160 3/13/2024
2024.0.11 161 3/13/2024
2024.0.10 182 3/3/2024
2024.0.9 173 2/27/2024
2024.0.8 209 2/1/2024
2024.0.7 165 1/26/2024
2024.0.6 154 1/25/2024
2024.0.5 152 1/24/2024
2024.0.4 146 1/24/2024
2024.0.3 161 1/22/2024
2024.0.2 225 1/10/2024
2024.0.1 169 1/9/2024
2024.0.1-alpha-3 152 1/9/2024
2024.0.1-alpha-2 150 1/9/2024
2024.0.1-alpha-1 173 1/3/2024
2024.0.0 209 12/26/2023
2023.0.27 220 12/21/2023
2023.0.26 189 12/21/2023
2023.0.25 213 12/11/2023
2023.0.24 197 12/8/2023
2023.0.23 182 12/6/2023
2023.0.21 268 12/4/2023
2023.0.20 241 11/27/2023
2023.0.19 201 11/20/2023
2023.0.18 215 10/25/2023
2023.0.17 257 10/22/2023
2023.0.16 283 10/16/2023
2023.0.16-alpha-1 144 10/16/2023
2023.0.15 201 10/14/2023
2023.0.14 177 10/14/2023
2023.0.13 182 10/14/2023
2023.0.12 194 10/14/2023
2023.0.11 181 10/10/2023
2023.0.10 187 10/9/2023
2023.0.9 293 8/16/2023
2023.0.8 264 8/15/2023
2023.0.8-alpha-2 300 5/31/2023
2023.0.7 636 5/12/2023
2023.0.6 343 5/10/2023
2023.0.5 245 5/7/2023
2023.0.4 277 4/22/2023
2023.0.3 322 4/19/2023
2023.0.2 313 4/6/2023
2023.0.1 294 3/13/2023
2022.10.4 382 11/9/2022
2022.10.3 439 10/19/2022
2022.10.2 512 10/19/2022
2022.10.0 498 10/16/2022
2022.7.1 533 7/18/2022

Basic infrastructure provided for authorizing User with given permission