HMS.Shared.Authorization 2.9.5

dotnet add package HMS.Shared.Authorization --version 2.9.5
                    
NuGet\Install-Package HMS.Shared.Authorization -Version 2.9.5
                    
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="HMS.Shared.Authorization" Version="2.9.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HMS.Shared.Authorization" Version="2.9.5" />
                    
Directory.Packages.props
<PackageReference Include="HMS.Shared.Authorization" />
                    
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 HMS.Shared.Authorization --version 2.9.5
                    
#r "nuget: HMS.Shared.Authorization, 2.9.5"
                    
#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 HMS.Shared.Authorization@2.9.5
                    
#: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=HMS.Shared.Authorization&version=2.9.5
                    
Install as a Cake Addin
#tool nuget:?package=HMS.Shared.Authorization&version=2.9.5
                    
Install as a Cake Tool

HMS.Shared.Authorization

Lightweight, high-performance token authorization library for HMS modular systems (Hospital Management System).

This package provides [TokenAuthorize] and GlobalAuthorizationActionFilter for validating tokens sent in the JSON body instead of headers. It validates JWT tokens using a shared symmetric key (from appsettings) and compares the user identity as a combination of tenant name + user name.


✨ Features

  • Simple attribute-based authorization: [TokenAuthorize]
  • Token verification handled automatically via GlobalAuthorizationActionFilter
  • Key and token validation logic configurable via HmsAuth section in appsettings.json
  • Supports multi-tenant HMS architecture (tenant + hospital)
  • Lightweight — only a few kilobytes of dependencies
  • Designed for .NET 8 and ASP.NET Core Web APIs

📦 Installation

Add the NuGet package:

dotnet add package HMS.Shared.Authorization

⚙️ Configuration

Add an HmsAuth section in your appsettings.json:

{
  "HmsAuth": {
    "Base64Secret": "YOUR_BASE64_SYMMETRIC_KEY_IN_BASE64",
    "ValidateLifetime": true,
    "ClockSkewSeconds": 60,
    "ValidateIssuer": false,
    "ValidateAudience": false
  }
}

🛠️ The Base64Secret is a Base64-encoded symmetric key used to validate JWT signatures.


🚀 Usage

1️⃣ Add service registration

In your Program.cs of the consuming project (e.g., OPD module):

using HMS.Shared.Authorization;

builder.Services.AddHmsTokenAuth(builder.Configuration);

builder.Services.AddControllers(o =>
        o.Filters.AddService<GlobalAuthorizationActionFilter>());

2️⃣ Apply [TokenAuthorize]

[TokenAuthorize]
[HttpPost("GetAllPatientSchedule")]
public async Task<ActionResult<OpdPatientScheduleListViewModel>> GetAllPatientScheduleAsync(
    OpdPatientScheduleViewModel objModel,
    CancellationToken cancellationToken = default)
{
    return Ok(await _opdService.GetAllPatientScheduleAsync(objModel, cancellationToken));
}

🧩 How it works

  • The action filter automatically checks for [TokenAuthorize].
  • It extracts _tenantName, _userName, and _token from the incoming model.
  • It verifies the token using the symmetric key from configuration.
  • If valid, the request continues; otherwise, a JSON error response is returned.

👤 Author

Ratul Koley


🏢 Maintainer

Xcelcure Technologies LLP. — private HMS modularization project.


📄 License

This package is proprietary software for HMS internal use.

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.9.5 192 10/22/2025
1.0.0 205 10/16/2025