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
<PackageReference Include="HMS.Shared.Authorization" Version="2.9.5" />
<PackageVersion Include="HMS.Shared.Authorization" Version="2.9.5" />
<PackageReference Include="HMS.Shared.Authorization" />
paket add HMS.Shared.Authorization --version 2.9.5
#r "nuget: HMS.Shared.Authorization, 2.9.5"
#:package HMS.Shared.Authorization@2.9.5
#addin nuget:?package=HMS.Shared.Authorization&version=2.9.5
#tool nuget:?package=HMS.Shared.Authorization&version=2.9.5
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
HmsAuthsection 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
Base64Secretis 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_tokenfrom 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 | Versions 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. |
-
net8.0
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.10)
- Microsoft.IdentityModel.Tokens (>= 8.14.0)
- System.IdentityModel.Tokens.Jwt (>= 8.14.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.