MParchin.Authority
1.0.0
See the version list below for details.
dotnet add package MParchin.Authority --version 1.0.0
NuGet\Install-Package MParchin.Authority -Version 1.0.0
<PackageReference Include="MParchin.Authority" Version="1.0.0" />
paket add MParchin.Authority --version 1.0.0
#r "nuget: MParchin.Authority, 1.0.0"
// Install MParchin.Authority as a Cake Addin #addin nuget:?package=MParchin.Authority&version=1.0.0 // Install MParchin.Authority as a Cake Tool #tool nuget:?package=MParchin.Authority&version=1.0.0
A micro service ready JWT Authentication and Authorization(claim based) solution using https://github.com/jwt-dotnet/jwt you can override or extend most of the functionality to suit your needs
on authority service that is responsible for authentication of users and generating tokens the app needs a database connection using entityframework(db should inherit from DbContext,IAuthorityDb):
var builder = WebApplication.CreateBuilder(args);
builder.AddJWTAuthentication<Db>(env.PUBLIC_KEY_FILE, env.PRIVATE_KEY_FILE, options =>
{
options.CurrentApp = env.APP;
options.Authority = env.AUTHORITY;
options.Audience = env.AUDIENCE.Split(",");
options.Expiration = TimeSpan.FromHours(env.TOKEN_EXPIRATION_HOURS);
options.RefresExpiration = TimeSpan.FromDays(env.REFRESH_EXPIRATION_DAYS);
options.ResetTokenLifeTimeSpan = TimeSpan.FromHours(env.RESET_TOKEN_EXPIRATION_HOURS);
});
on any other service that needs to use the token for authorization or simple identification of user:
var builder = WebApplication.CreateBuilder(args);
builder.AddJWTAuthentication<Db>(env.PUBLIC_KEY_FILE, options =>
{
options.CurrentApp = env.APP;
options.Authority = env.AUTHORITY;
});
and to get the user in api methods:
app.MapGet("/", (AuthorityClaims claims) => $"Hello {claims.User.Name}!").RequireAuthorization(Authorization.User);
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. |
-
net8.0
- jwt (>= 10.1.1)
- JWT.Extensions.AspNetCore (>= 10.1.1)
- Microsoft.AspNetCore (>= 2.2.0)
- Microsoft.AspNetCore.Authorization (>= 8.0.10)
- Microsoft.EntityFrameworkCore (>= 8.0.10)
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.0.7 | 80 | 1/16/2025 |
2.0.6 | 35 | 1/8/2025 |
2.0.5 | 82 | 1/5/2025 |
2.0.4 | 94 | 12/23/2024 |
2.0.3 | 90 | 12/23/2024 |
2.0.2 | 96 | 12/22/2024 |
2.0.1 | 93 | 12/2/2024 |
2.0.0 | 95 | 12/1/2024 |
1.2.1 | 98 | 11/24/2024 |
1.2.0 | 92 | 11/23/2024 |
1.1.1 | 89 | 11/21/2024 |
1.1.0 | 89 | 11/21/2024 |
1.0.2 | 95 | 11/10/2024 |
1.0.1 | 94 | 11/10/2024 |
1.0.0 | 100 | 11/10/2024 |