Luka.Auth
1.0.9
dotnet add package Luka.Auth --version 1.0.9
NuGet\Install-Package Luka.Auth -Version 1.0.9
<PackageReference Include="Luka.Auth" Version="1.0.9" />
<PackageVersion Include="Luka.Auth" Version="1.0.9" />
<PackageReference Include="Luka.Auth" />
paket add Luka.Auth --version 1.0.9
#r "nuget: Luka.Auth, 1.0.9"
#:package Luka.Auth@1.0.9
#addin nuget:?package=Luka.Auth&version=1.0.9
#tool nuget:?package=Luka.Auth&version=1.0.9
Luka.Auth
Lightweight JWT authentication and permission management for the Luka .NET platform.
✨ Features
- 🔐 JWT token generation and validation
- ✅ Authorization via
[Authorize(Policy = "YOUR_PERMISSION")] - 🎯 Enum-based permission definition using
PermissionAttribute
⚙️ Configuration
appsettings.json
✅ Minimal example
{
"jwt": {
"issuerSigningKey": "yourSecretKey",
"expiryMinutes": 60,
"issuer": "lukachi",
"validAudience": "lukachi",
"validateAudience": false,
"validateIssuer": false,
"validateIssuerSigningKey": true,
"validateLifetime": true,
"isUsingSingleInstanceTokenRevocation": false
}
}
🚀 Usage
- Register JWT in Program.cs
🔴 With Redis token blacklist:
builder.Services
.AddLuka()
.AddJwt<RedisAccessTokenService>() // Uses Redis for token revocation
.AddRedis();
🟡 With In-Memory token blacklist:
builder.Services
.AddLuka()
.AddJwt<InMemoryAccessTokenService>(); // Uses IMemoryCache for token revocation
⚪ Without token blacklist:
builder.Services
.AddLuka()
.AddJwt(); // No token revocation
- Enable middleware
app.UseLuka()
.UseAuthentication() // Validates the JWT access token from the Authorization header
// and sets HttpContext.User with claims from the token
.UseAuthorization() // Enforces access control based on registered policies and roles
// (e.g., [Authorize(Policy = "CREATE_USER")])
.UseAccessTokenValidator(); // Validates active token blacklist
🛠 Additional Notes
You can decorate your permission enum values with [Permission], and Luka.Auth will automatically register them as policies and sync with the database.
Token revocation via Redis or in-memory is automatically handled depending on which service you register.
Logout endpoint can call IAccessTokenService.DeactivateCurrentAsync()
| 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
- Luka (>= 1.0.9)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.16)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.9.0)
- System.IdentityModel.Tokens.Jwt (>= 8.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.