Devinux.TokenManager 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Devinux.TokenManager --version 1.0.0                
NuGet\Install-Package Devinux.TokenManager -Version 1.0.0                
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="Devinux.TokenManager" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Devinux.TokenManager --version 1.0.0                
#r "nuget: Devinux.TokenManager, 1.0.0"                
#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 Devinux.TokenManager as a Cake Addin
#addin nuget:?package=Devinux.TokenManager&version=1.0.0

// Install Devinux.TokenManager as a Cake Tool
#tool nuget:?package=Devinux.TokenManager&version=1.0.0                

Devinux TokenManager (with Authorization)

an easy use library for Create Token Manager Service With Custom Inline Data and Integrated Authorization

Join with us

  • Integrated Token Repository.
  • Custom Category Grouping.
  • Custom Token Generator.
  • Action Filtering.
  • Custom Authorize Attribute.
  • Multi Authorize Attribute.
  • Custom Request Header Keys.
  • Multi Request Header Keys.
  • Ready for Custom Role Attributes.
  • Ready for Create Role Enum.
  • 😉

Join with us

Please Contact with our team : info@webinux.ir

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Usage

â–º program.cs
    using Devinux.TokenManager; /* #1. add refrances */

    // var builder = WebApplication.CreateBuilder(args);
    .
    .
    .
    /* #2. Create Main Service */
    // only Token manager
    builder.Services.AddDevinuxTokenManager();
    // with authorize manager
    builder.Services.AddDevinuxTokenManager(c=>
        // create token life time
        c.TokenExpireMinute = 20;
        
        // create log listener
        c.OnLog += (s) => Console.WriteLine(s);
        
        // attach custom attribute types for check on action filtering
        c.AuthorizeAttributeTypes.Add(typeof(CustomAuthorizeAttribute));
        
        // custom check body method
        c.OnCheckToken += (FoundedToken, Context, AuthorizeAttributeList) => { };
    );
    
    /* 
        #2.1 
        if u want create token manager with authorization section on your project,
        u must add Actionfilter on mvc Service
        Create Action Filter For Authorization 
    */
    builder.Services.AddMvc(o => {
        o.Filters.Add(typeof(Devinux.TokenManager.DevinuxTokenManagerActionFilter)); 
    });
    .
    .
    .
    
    /* done , enjoy ;)  */ 
...

Authorization Samples

[HttpPut]
[DevinuxAuthorize]
[DevinuxAllowAnonymous] // <-- override for Authorize = method is allow for anyone
public IActionResult Action()
// ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
[Authorize]
public IActionResult Action()
// ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
[Authorize] or [DevinuxAuthorize] or [any attribute on program.cs]
public class Controller : ControllerBase 
{
    [DevinuxAllowAnonymous] // except method on all action in controller
    public IActionResult Action()
}

Token Management Samples

public void Login(string username, string password)
{
    var signedUSerObject = new { username = "signed-user", id = 1 /* ... any data */ };

    // add genrated token
    _tm.Add(new DevinuxToken()
    {
        Data = signedUSerObject,
        ExpireDate = DateTime.Now.AddMinutes(_tm.Config.TokenExpireMinute),
        Category = "login",
        Key = "Generate Key"
    });

    // get default active with category
    _tm.GetTokenByCategory("proxy-tokens");

    // clear all tokens
    _tm.DeleteTokens();

    // delete token by key
    _tm.Delete("token key");

    // revoke time
    _tm.Revoke("token key");

    // get token by key
    _tm.GetTokenByKey("token key");
    
    // check token is valid
    if (_tm.Validate("token key")) { }
}
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-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

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.3 75 10/31/2024
1.0.2 110 7/23/2024
1.0.1 119 7/6/2024
1.0.0 97 7/5/2024