![]() |
VOOZH | about |
dotnet add package Raycynix.Extensions.Security.AspNetCore --version 1.0.2
NuGet\Install-Package Raycynix.Extensions.Security.AspNetCore -Version 1.0.2
<PackageReference Include="Raycynix.Extensions.Security.AspNetCore" Version="1.0.2" />
<PackageVersion Include="Raycynix.Extensions.Security.AspNetCore" Version="1.0.2" />Directory.Packages.props
<PackageReference Include="Raycynix.Extensions.Security.AspNetCore" />Project file
paket add Raycynix.Extensions.Security.AspNetCore --version 1.0.2
#r "nuget: Raycynix.Extensions.Security.AspNetCore, 1.0.2"
#:package Raycynix.Extensions.Security.AspNetCore@1.0.2
#addin nuget:?package=Raycynix.Extensions.Security.AspNetCore&version=1.0.2Install as a Cake Addin
#tool nuget:?package=Raycynix.Extensions.Security.AspNetCore&version=1.0.2Install as a Cake Tool
Raycynix.Extensions.Security.AspNetCore adds ASP.NET Core JWT authentication, dynamic authorization policies, and shared authorization-attribute integration for Raycynix security.
AddRaycynixAspNetCoreSecurity(...)UseRaycynixSecurity(this IApplicationBuilder app)ClaimsPrincipal to ISecurityContext mappingauthenticated, permission:*, role:*, and subject:*Raycynix.Extensions.Security.AbstractionsRequireRaycynixAuthorization(...)401 Unauthorized and 403 Forbidden JSON responsesvar builder = WebApplication.CreateBuilder(args);
builder.Services.AddRaycynixAspNetCoreSecurity(builder.Configuration, options =>
{
options.Jwt.Authority = "https://auth.raycynix.com";
options.Jwt.Issuer = "raycynix-auth";
options.Jwt.Audience = "raycynix-services";
});
var app = builder.Build();
app.UseRaycynixSecurity();
app.Run();
{
"SecurityConfiguration": {
"Jwt": {
"Authority": "https://auth.raycynix.com",
"Issuer": "raycynix-auth",
"Audience": "raycynix-services",
"RequireHttpsMetadata": true
}
}
}
Use authorization policies with standard names:
using Raycynix.Extensions.Security.AspNetCore.Authorization;
[Authorize(Policy = SecurityPolicies.Permission("users.read"))]
[Authorize(Policy = SecurityPolicies.AnyPermission("users.read", "users.write"))]
[Authorize(Policy = SecurityPolicies.AllPermissions("users.read", "users.export"))]
[Authorize(Policy = SecurityPolicies.Role("admin"))]
[Authorize(Policy = SecurityPolicies.AnyRole("admin", "support"))]
[Authorize(Policy = SecurityPolicies.AllRoles("manager", "auditor"))]
[Authorize(Policy = SecurityPolicies.Authenticated)]
[Authorize(Policy = SecurityPolicies.ServiceOnly)]
Or use the shared security attributes and let the package translate them into standard ASP.NET Core authorization policies:
using Raycynix.Extensions.Security.Abstractions.Attributes;
[RequireAuthenticatedSubject]
[RequireSubjectType(SecuritySubjectType.Service)]
[RequirePermission("users.read")]
public sealed class UsersController : ControllerBase
{
}
For minimal APIs or endpoint builders, use the helper extension:
app.MapGet("/users/{id}", HandleUserAsync)
.RequireRaycynixAuthorization(
new RequireAuthenticatedSubjectAttribute(),
new RequirePermissionAttribute("users.read"));
The package expects JWT access tokens with:
subsubject_typerolespermissionssubject_type is mapped to SecuritySubjectType, allowing both User and Service request subjects to use the same ISecurityContext.
Authentication and authorization failures return safe JSON responses without exposing internal policy details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
Added an ASP.NET Core example with JWT registration, protected endpoints, request security context mapping, and dynamic authorization policy usage.