DotNetBrightener.Infrastructure.Security 2023.0.20

.NET 7.0
dotnet add package DotNetBrightener.Infrastructure.Security --version 2023.0.20
NuGet\Install-Package DotNetBrightener.Infrastructure.Security -Version 2023.0.20
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="2023.0.20" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.Infrastructure.Security --version 2023.0.20
#r "nuget: DotNetBrightener.Infrastructure.Security, 2023.0.20"
#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=2023.0.20

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

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 net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android 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)
Additional computed target framework(s)
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.WebApp.CommonShared

Package Description

DotNetBrightener.Infrastructure.JwtAuthentication

Package Description

DotNetBrightener.MultiTenancy

Package Description

DotNetBrightener.Infrastructure.ApiKeyAuthentication

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2023.0.20 95 11/27/2023
2023.0.19 75 11/20/2023
2023.0.18 112 10/25/2023
2023.0.17 169 10/22/2023
2023.0.16 182 10/16/2023
2023.0.16-alpha-1 64 10/16/2023
2023.0.15 105 10/14/2023
2023.0.14 91 10/14/2023
2023.0.13 94 10/14/2023
2023.0.12 102 10/14/2023
2023.0.11 94 10/10/2023
2023.0.10 96 10/9/2023
2023.0.9 156 8/16/2023
2023.0.8 152 8/15/2023
2023.0.8-alpha-2 209 5/31/2023
2023.0.7 399 5/12/2023
2023.0.6 170 5/10/2023
2023.0.5 155 5/7/2023
2023.0.4 184 4/22/2023
2023.0.3 219 4/19/2023
2023.0.2 216 4/6/2023
2023.0.1 212 3/13/2023
2022.10.4 316 11/9/2022
2022.10.3 374 10/19/2022
2022.10.2 453 10/19/2022
2022.10.0 432 10/16/2022
2022.7.1 462 7/18/2022

Basic infrastructure provided for authorizing User with given permission