DotNetBrightener.Infrastructure.Security 2024.0.14.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotNetBrightener.Infrastructure.Security --version 2024.0.14.3
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2024.0.14.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="2024.0.14.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.Infrastructure.Security --version 2024.0.14.3
#r "nuget: DotNetBrightener.Infrastructure.Security, 2024.0.14.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=2024.0.14.3

// Install DotNetBrightener.Infrastructure.Security as a Cake Tool
#tool nuget:?package=DotNetBrightener.Infrastructure.Security&version=2024.0.14.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 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. 
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
2024.0.14.4 0 6/27/2024
2024.0.14.4-preview-7 23 6/27/2024
2024.0.14.3 105 6/21/2024
2024.0.14.1 95 6/6/2024
2024.0.14.1-preview 81 6/6/2024
2024.0.14-preview-1 80 6/6/2024
2024.0.13.8-preview 88 6/6/2024
2024.0.13.1-preview-0146 88 6/6/2024
2024.0.12.15803-preview-03 86 6/6/2024
2024.0.12.15608 90 6/4/2024
2024.0.12.15515 164 6/3/2024
2024.0.12.15220 78 5/31/2024
2024.0.12.15220-alpha31-240... 71 5/31/2024
2024.0.12.14911 130 5/28/2024
2024.0.12.14910-alpha28-240... 85 5/28/2024
2024.0.12.14823 97 5/27/2024
2024.0.12.14522-alpha7-2405... 99 5/24/2024
2024.0.12.14514-alpha6-2405... 94 5/24/2024
2024.0.12.14511 111 5/24/2024
2024.0.12.14314 147 5/22/2024
2024.0.12.14114 116 5/20/2024
2024.0.12.12815 137 5/7/2024
2024.0.12.12814 106 5/7/2024
2024.0.12.12721 124 5/6/2024
2024.0.12.12702 116 5/5/2024
2024.0.12.12622 129 5/5/2024
2024.0.12.12514 106 5/4/2024
2024.0.12.12512 105 5/4/2024
2024.0.12.12510 107 5/4/2024
2024.0.12.12420 89 5/3/2024
2024.0.12.12319 61 5/2/2024
2024.0.12.12319-rc-2405021801 55 5/2/2024
2024.0.12.12318 64 5/2/2024
2024.0.12.12215 93 5/1/2024
2024.0.12.12011 101 4/29/2024
2024.0.12.11720 112 4/26/2024
2024.0.12.11719 103 4/26/2024
2024.0.12.11621 127 4/25/2024
2024.0.12.11523 102 4/24/2024
2024.0.12.11522 109 4/24/2024
2024.0.12.11417 125 4/23/2024
2024.0.12.11400 128 4/22/2024
2024.0.12.11316 112 4/22/2024
2024.0.11.10220 103 4/11/2024
2024.0.11.10120 95 4/10/2024
2024.0.11.10119 90 4/10/2024
2024.0.11.10115 98 4/10/2024
2024.0.11.9914 123 4/8/2024
2024.0.11.9901 100 4/7/2024
2024.0.11.9823 112 4/7/2024
2024.0.11.9401 116 4/2/2024
2024.0.11.9301 103 4/1/2024
2024.0.11.9206 105 3/31/2024
2024.0.11.9205 101 3/31/2024
2024.0.11.8200 125 3/21/2024
2024.0.11.8122 90 3/21/2024
2024.0.11.8120 91 3/21/2024
2024.0.11.7320 132 3/13/2024
2024.0.11.7316 107 3/13/2024
2024.0.11.7310 108 3/13/2024
2024.0.11 107 3/13/2024
2024.0.10 131 3/3/2024
2024.0.9 114 2/27/2024
2024.0.8 150 2/1/2024
2024.0.7 106 1/26/2024
2024.0.6 105 1/25/2024
2024.0.5 92 1/24/2024
2024.0.4 95 1/24/2024
2024.0.3 111 1/22/2024
2024.0.2 172 1/10/2024
2024.0.1 109 1/9/2024
2024.0.1-alpha-3 92 1/9/2024
2024.0.1-alpha-2 96 1/9/2024
2024.0.1-alpha-1 113 1/3/2024
2024.0.0 162 12/26/2023
2023.0.27 170 12/21/2023
2023.0.26 130 12/21/2023
2023.0.25 162 12/11/2023
2023.0.24 145 12/8/2023
2023.0.23 135 12/6/2023
2023.0.21 197 12/4/2023
2023.0.20 191 11/27/2023
2023.0.19 151 11/20/2023
2023.0.18 162 10/25/2023
2023.0.17 207 10/22/2023
2023.0.16 221 10/16/2023
2023.0.16-alpha-1 92 10/16/2023
2023.0.15 149 10/14/2023
2023.0.14 121 10/14/2023
2023.0.13 124 10/14/2023
2023.0.12 140 10/14/2023
2023.0.11 128 10/10/2023
2023.0.10 140 10/9/2023
2023.0.9 232 8/16/2023
2023.0.8 202 8/15/2023
2023.0.8-alpha-2 244 5/31/2023
2023.0.7 561 5/12/2023
2023.0.6 228 5/10/2023
2023.0.5 183 5/7/2023
2023.0.4 217 4/22/2023
2023.0.3 257 4/19/2023
2023.0.2 249 4/6/2023
2023.0.1 237 3/13/2023
2022.10.4 336 11/9/2022
2022.10.3 392 10/19/2022
2022.10.2 463 10/19/2022
2022.10.0 445 10/16/2022
2022.7.1 477 7/18/2022

Basic infrastructure provided for authorizing User with given permission