Kuwait.Lis.Common.Security 2.0.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Kuwait.Lis.Common.Security --version 2.0.1
                    
NuGet\Install-Package Kuwait.Lis.Common.Security -Version 2.0.1
                    
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="Kuwait.Lis.Common.Security" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kuwait.Lis.Common.Security" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Kuwait.Lis.Common.Security" />
                    
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 Kuwait.Lis.Common.Security --version 2.0.1
                    
#r "nuget: Kuwait.Lis.Common.Security, 2.0.1"
                    
#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 Kuwait.Lis.Common.Security@2.0.1
                    
#: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=Kuwait.Lis.Common.Security&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Kuwait.Lis.Common.Security&version=2.0.1
                    
Install as a Cake Tool

Kuwait.Lis.Common.Security

A .NET library providing common security utilities for Kuwait LIS services.

Features

  • JWT Token Management: Generate and validate JWT tokens with custom claims
  • Token Blacklisting: In-memory token blacklist service for security
  • Service Validation: Health check and validation services for microservices
  • User Service Health Check: Monitor user service availability and instances

Installation

Install the package via NuGet Package Manager:

dotnet add package Kuwait.Lis.Common.Security

Or via Package Manager Console:

Install-Package Kuwait.Lis.Common.Security

Usage

JWT Token Service

using Kuwait.Lis.Common.Security;

var tokenService = new TokenService("your-secret-key", "issuer", "audience");

// Generate token
string token = tokenService.GenerateToken("userId", "user@example.com", 60);

// Validate token
ClaimsPrincipal? principal = tokenService.ValidateToken(token);

Service Validation

using Kuwait.Lis.Common.Security;
using Microsoft.Extensions.DependencyInjection;

// Register in DI container
services.AddHttpClient<IServiceValidationService, ServiceValidationService>();

// Use in your service
public class MyController
{
    private readonly IServiceValidationService _validationService;
    
    public MyController(IServiceValidationService validationService)
    {
        _validationService = validationService;
    }
    
    public async Task<bool> CheckService()
    {
        return await _validationService.IsUserServiceAvailableAsync();
    }
}

Token Blacklisting

// Blacklist a token
_validationService.BlacklistToken("jwt-token-here");

// Check if token is blacklisted
bool isBlacklisted = _validationService.IsTokenBlacklisted("jwt-token-here");

Configuration

Add the following configuration to your appsettings.json:

{
  "Services": {
    "UserService": {
      "BaseUrl": "https://your-user-service-url"
    }
  },
  "UserService": {
    "BaseUrl": "https://your-user-service-url"
  }
}

Build and Package

To build the project and create NuGet package:

# Build the project
dotnet build --configuration Release

# Create NuGet package
dotnet pack --configuration Release --output ./packages

# Push to NuGet (optional)
dotnet nuget push ./packages/Kuwait.Lis.Common.Security.1.0.0.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json

Dependencies

  • .NET 9.0
  • System.IdentityModel.Tokens.Jwt (7.0.3)
  • Microsoft.Extensions.Configuration.Abstractions (9.0.0)
  • Microsoft.Extensions.Http (9.0.0)

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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