MasterNeverDown.TokenBlackList
3.0.2
dotnet add package MasterNeverDown.TokenBlackList --version 3.0.2
NuGet\Install-Package MasterNeverDown.TokenBlackList -Version 3.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="MasterNeverDown.TokenBlackList" Version="3.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MasterNeverDown.TokenBlackList --version 3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MasterNeverDown.TokenBlackList, 3.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 MasterNeverDown.TokenBlackList as a Cake Addin #addin nuget:?package=MasterNeverDown.TokenBlackList&version=3.0.2 // Install MasterNeverDown.TokenBlackList as a Cake Tool #tool nuget:?package=MasterNeverDown.TokenBlackList&version=3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MasterNeverDown.TokenBlackList
Features
- TokenBlackListMiddleware The TokenBlackListMiddleware class is responsible for checking if a token is blacklisted and preventing access if it is. It also provides a method to blacklist tokens for a specified duration. This middleware is useful for implementing logout functionality by blacklisting tokens upon logout.
Usage
dotnet add package MasterNeverDown.TokenBlackList --version 3.0.0
- you can add middleware to startup.cs but path must match /account/logout
// dependency injection
builder.Services.AddTokenBlackList();
..
app.UseMiddleware<TokenBlackListMiddleware>(); //path must match /account/logout
- or you can add LogoutFilter to controller ,this is much more easy🎉
/// <summary>
/// Logs out the user by invalidating the provided JWT token.
/// This action uses a custom logout filter.
/// </summary>
/// <param name="authorization">The authorization header containing the JWT token.</param>
/// <returns>Returns Ok if successful, otherwise BadRequest.</returns>
[Authorize]
[TypeFilter(typeof(LogoutFilter))]
[HttpPost("custom/logout")]
[Tags("Filter Demo")]
public IActionResult Logout2([FromHeader]string authorization)
{
var token = authorization.Replace("Bearer ", "");
if (string.IsNullOrEmpty(token))
{
return BadRequest("Token is required");
}
return Ok("Logged out successfully");
}
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.IdentityModel.Tokens (>= 8.2.1)
- System.IdentityModel.Tokens.Jwt (>= 8.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.