Token.Generator.JWT.Login 2.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Token.Generator.JWT.Login --version 2.1.4
                    
NuGet\Install-Package Token.Generator.JWT.Login -Version 2.1.4
                    
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="Token.Generator.JWT.Login" Version="2.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Token.Generator.JWT.Login" Version="2.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Token.Generator.JWT.Login" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Token.Generator.JWT.Login --version 2.1.4
                    
#r "nuget: Token.Generator.JWT.Login, 2.1.4"
                    
#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.
#:package Token.Generator.JWT.Login@2.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Token.Generator.JWT.Login&version=2.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Token.Generator.JWT.Login&version=2.1.4
                    
Install as a Cake Tool

ESPAÑOL 🇪🇸

¡Bienvenido a la
Guía Dinámica de la Librería de Generación de Tokens JWT 🚀


🚦 Introducción

En el mundo del desarrollo web, la seguridad y la autenticación son esenciales. Con esta librería, podrás generar y gestionar tokens JWT de forma sencilla, segura y con un flujo totalmente integrado en tu proyecto .NET. ¡Descubre a continuación cómo aprovecharla al máximo!


🤔 ¿Qué es un Token JWT?

<details> <summary>▶️ Ver definición</summary>

Un JSON Web Token (JWT) es un estándar abierto (RFC 7519) que define un formato compacto y auto-contenible para transmitir información de forma segura como un objeto JSON.

  • 🔐 Firma digital: Garantiza la integridad y autenticidad.
  • 🕒 Expiración: Incluye un tiempo de vida para evitar usos indebidos.
  • 📦 Auto-contenible: Transporta tanto los datos como la firma.

</details>


⚙️ Instalación

<details> <summary>▶️ Mostrar comando</summary>

  1. Abre la Consola de Administrador de Paquetes en Visual Studio.

  2. Ejecuta:

    Install-Package Token.Generator.JWT.Login
    
  3. ¡Listo! Ya tienes la librería disponible en tu proyecto.

</details>


🔧 Configuración

public void ConfigureServices(IServiceCollection services)
{
    // Registra tu servicio de generación de tokens como singleton
    services.AddSingleton<ITokenService, TokenService>();

    // 🚀 Otros servicios de tu aplicación...
}

💡 Tip: Ajusta el ciclo de vida del servicio según tus necesidades (Scoped o Transient).


🏷️ Uso de la Librería

La librería expone tres métodos principales. Cada uno responde a un nivel de requerimiento distinto:

1. ✨ BasicToken

  • Duración: 30 minutos
  • Uso: Sin parámetros extras
public string GenerateBasicToken()
{
    var tokenService = new TokenService();
    return tokenService.BasicToken();
}

2. ⚡ ProToken

  • Incluye: issuer, audience y clientUsername
public string GenerateProToken(
    string issuer,
    string audience,
    string clientUsername)
{
    var tokenService = new TokenService();
    return tokenService.ProToken(
        issuer,
        audience,
        clientUsername);
}

3. 🌟 PremiumTokenAsync

  • Duración: 30 días
  • Requiere: clave válida verificada desde repositorio
public async Task<string> GeneratePremiumTokenAsync(
    string key,
    string issuer,
    string audience,
    string clientUsername)
{
    var tokenService = new TokenService();
    return await tokenService.PremiumTokenAsync(
        key,
        issuer,
        audience,
        clientUsername);
}

🔄 Ejemplo Completo en ASP.NET Core

[ApiController]
[Route("[controller]")]
public class TokenController : ControllerBase
{
    private readonly ITokenService _tokenService;

    public TokenController(ITokenService tokenService)
    {
        _tokenService = tokenService;
    }

    // 🎫 Token Básico
    [HttpGet("basic")]
    public IActionResult GetBasicToken()
    {
        var token = _tokenService.BasicToken();
        return Ok(new { Token = token });
    }

    // 🎫 Token Pro
    [HttpGet("pro")]
    public IActionResult GetProToken(
        string issuer,
        string audience,
        string clientUsername)
    {
        var token = _tokenService.ProToken(
            issuer,
            audience,
            clientUsername);
        return Ok(new { Token = token });
    }

    // 🎫 Token Premium
    [HttpGet("premium")]
    public async Task<IActionResult> GetPremiumTokenAsync(
        string key,
        string issuer,
        string audience,
        string clientUsername)
    {
        var token = await _tokenService.PremiumTokenAsync(
            key,
            issuer,
            audience,
            clientUsername);
        return Ok(new { Token = token });
    }
}

📞 Soporte y Contribución

  • 🔗 Repositorio & Portfolio: Visita mi portfolio para más detalles y ejemplos.
  • 🐛 Bugs / Requests: Crea un issue en GitHub o contáctame por email.

ENGLISH 🇬🇧

Welcome to the 🚀 Dynamic JWT Token Generation Library Guide 🌟


🚦 Introduction

In the fast-paced world of web development, security and authentication are non-negotiable. This library makes it effortless to generate and manage JWTs in your .NET projects—securely and efficiently. Let’s dive in!


🤔 What Is a JWT?

<details> <summary>▶️ Show definition</summary>

A JSON Web Token (JWT) is an open standard (RFC 7519) for transmitting claims between parties in a compact, self-contained JSON object.

  • 🔐 Digital Signature: Ensures integrity and authenticity.
  • 🕒 Expiration: Includes a built-in expiry to mitigate misuse.
  • 📦 Self-Contained: Carries both payload and signature.

</details>


⚙️ Installation

<details> <summary>▶️ Show command</summary>

  1. Open the NuGet Package Manager Console in Visual Studio.

  2. Run:

    Install-Package Token.Generator.JWT.Login
    
  3. You’re all set!

</details>


🔧 Configuration

public void ConfigureServices(IServiceCollection services)
{
    // Register your token service as a singleton
    services.AddSingleton<ITokenService, TokenService>();

    // 🚀 Other application services...
}

💡 Tip: Adjust lifetime (Scoped/Transient) based on your needs.


🏷️ Library Usage

Three main methods cover basic through premium requirements:

1. ✨ BasicToken

  • TTL: 30 minutes
  • Parameters: none
public string GenerateBasicToken()
{
    var tokenService = new TokenService();
    return tokenService.BasicToken();
}

2. ⚡ ProToken

  • Includes: issuer, audience, clientUsername
public string GenerateProToken(
    string issuer,
    string audience,
    string clientUsername)
{
    var tokenService = new TokenService();
    return tokenService.ProToken(
        issuer,
        audience,
        clientUsername);
}

3. 🌟 PremiumTokenAsync

  • TTL: 30 days
  • Requires: valid key checked against a GitHub-hosted list
public async Task<string> GeneratePremiumTokenAsync(
    string key,
    string issuer,
    string audience,
    string clientUsername)
{
    var tokenService = new TokenService();
    return await tokenService.PremiumTokenAsync(
        key,
        issuer,
        audience,
        clientUsername);
}

🔄 Full ASP.NET Core Example

[ApiController]
[Route("[controller]")]
public class TokenController : ControllerBase
{
    private readonly ITokenService _tokenService;

    public TokenController(ITokenService tokenService)
    {
        _tokenService = tokenService;
    }

    // 🎫 Basic Token
    [HttpGet("basic")]
    public IActionResult GetBasicToken()
    {
        var token = _tokenService.BasicToken();
        return Ok(new { Token = token });
    }

    // 🎫 Pro Token
    [HttpGet("pro")]
    public IActionResult GetProToken(
        string issuer,
        string audience,
        string clientUsername)
    {
        var token = _tokenService.ProToken(
            issuer,
            audience,
            clientUsername);
        return Ok(new { Token = token });
    }

    // 🎫 Premium Token
    [HttpGet("premium")]
    public async Task<IActionResult> GetPremiumTokenAsync(
        string key,
        string issuer,
        string audience,
        string clientUsername)
    {
        var token = await _tokenService.PremiumTokenAsync(
            key,
            issuer,
            audience,
            clientUsername);
        return Ok(new { Token = token });
    }
}

📞 Support & Contributions

  • 🔗 Repo & Portfolio: Check my portfolio for more details and examples.
  • 🐛 Issues / Feature Requests: Open an issue on GitHub or reach out via email.

Thanks for choosing the JWT Token Generation Library! 🙌 Happy coding, and keep your applications secure! 💻✨

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.  net9.0 was computed.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
2.1.6 139 5/10/2025
2.1.5 98 5/10/2025
2.1.4 103 5/10/2025
2.1.3 159 4/29/2025
2.1.2 177 4/29/2025
1.0.1 536 6/16/2022
1.0.0 485 6/14/2022

Version 2.1.3

- Include license
- More description about this package