AndroThink.Identity.PermissionsAuther 1.0.2

dotnet add package AndroThink.Identity.PermissionsAuther --version 1.0.2                
NuGet\Install-Package AndroThink.Identity.PermissionsAuther -Version 1.0.2                
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="AndroThink.Identity.PermissionsAuther" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AndroThink.Identity.PermissionsAuther --version 1.0.2                
#r "nuget: AndroThink.Identity.PermissionsAuther, 1.0.2"                
#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 AndroThink.Identity.PermissionsAuther as a Cake Addin
#addin nuget:?package=AndroThink.Identity.PermissionsAuther&version=1.0.2

// Install AndroThink.Identity.PermissionsAuther as a Cake Tool
#tool nuget:?package=AndroThink.Identity.PermissionsAuther&version=1.0.2                

PermissionsAuther Nuget

Help in securing endpoints using permissions-based authorization. alternate text is missing from this package README image

How to use

In Program.cs

builder.Services.UsePermissionsAuther();
 
 .....

app.UseAuthentication();
app.UseAuthorization();
In the controller above the endpoint that we want to protect it
[HasPermission({ID_Of_Section}, AndroThink.Identity.PermissionsAuther.Enums.Permissions.CanView)]
public IActionResult Index()
{
    return View();
}
In the controller above the endpoint that we want to protect it
public class HomeController : Controller
{
     ...........
     
     [HasPermission({ID_Of_Section}, AndroThink.Identity.PermissionsAuther.Enums.Permissions.CanView)]
     public IActionResult Index()
     {
          return View();
     }
}
In login controller we have to add the permissions claims
A model that implements AndroThink.Identity.PermissionsAuther.Interfaces.ISectionRole interface is required so we can store permissions for every user for example
    public class UserPermission : BasEntity, AndroThink.Identity.PermissionsAuther.Interfaces.ISectionRole
    {
        public long UserId { get; set; }
        public short SectionId { get; set; }
        public bool CanAdd { get; set; }
        public bool CanEdit { get; set; }
        public bool CanDelete { get; set; }
        public bool CanSoftDelete { get; set; }
        public bool CanView { get; set; }
    }

public class LoginController : Controller
{
     ...........
     
     [HasPermission({ID_Of_Section}, AndroThink.Identity.PermissionsAuther.Enums.Permissions.CanView)]
     [HttpPost]
     public IActionResult Login(string username,string password)
     {
          ....
          
          var permissions = (List<AndroThink.Identity.PermissionsAuther.Interfaces.ISectionRole>)loggedUsers.UserPermissions;
          var permissionsClaim = AndroThink.Identity.PermissionsAuther.PermissionUtils.CreatePermissionClaim(permissions);
          
          List<Claim> claims = new List<Claim>
        {
            new("Claim1", "TestValue1"),
            new("Claim2","TestValue2"),
            permissionsClaim
        };

          var claimsIdentity = new ClaimsIdentity(claims);
          
           ....   
     }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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-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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 175 8/17/2023
1.0.1 149 8/17/2023
1.0.0 143 8/17/2023