Hexalith.Security.WebServer
2.1.1
See the version list below for details.
dotnet add package Hexalith.Security.WebServer --version 2.1.1
NuGet\Install-Package Hexalith.Security.WebServer -Version 2.1.1
<PackageReference Include="Hexalith.Security.WebServer" Version="2.1.1" />
<PackageVersion Include="Hexalith.Security.WebServer" Version="2.1.1" />
<PackageReference Include="Hexalith.Security.WebServer" />
paket add Hexalith.Security.WebServer --version 2.1.1
#r "nuget: Hexalith.Security.WebServer, 2.1.1"
#addin nuget:?package=Hexalith.Security.WebServer&version=2.1.1
#tool nuget:?package=Hexalith.Security.WebServer&version=2.1.1
Hexalith.Security
Overview
Hexalith.Security is a comprehensive security framework for .NET applications providing authentication, authorization, and identity management capabilities. Built with modern C# and Blazor, it offers a robust approach to implementing security in web applications, API servers, and microservices.
Build Status
Architecture
The Hexalith.Security project follows a modular architecture with clear separation of concerns:
Core Components
- Abstractions: Defines interfaces, models, and contracts for security features
- Application: Business logic and services for security functionality
- Infrastructure: Implementation of data access and external service integration
- Presentation: UI components and pages for user interactions
- Modules: Integration modules for different application types (WebApp, WebServer, ApiServer)
Integration with Hexalith Framework
The security module integrates with:
- Hexalith.IdentityStores: For identity storage and management
- Hexalith.Application: For application module integration
- Hexalith.Infrastructure.DaprRuntime: For distributed application runtime support
Modules
WebApp Module (HexalithSecurityWebAppModule
)
Client-side authentication and authorization for Blazor WebAssembly applications:
// Program.cs
var builder = WebAssemblyHostBuilder.CreateDefault(args);
// ...
HexalithSecurityWebAppModule.AddServices(builder.Services, builder.Configuration);
WebServer Module (HexalithSecurityWebServerModule
)
Server-side authentication and authorization:
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services.AddModule<HexalithSecurityWebServerModule>(builder.Configuration);
var app = builder.Build();
// ...
app.UseModule<HexalithSecurityWebServerModule>();
app.UseSecurity<HexalithSecurityWebServerModule>();
ApiServer Module (HexalithSecurityApiServerModule
)
Security for API-focused applications:
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services.AddModule<HexalithSecurityApiServerModule>(builder.Configuration);
Security Features
- Authentication: ASP.NET Core Authentication, multiple schemes, Dapr-based authentication
- Authorization: Policy-based, role-based access control
- Predefined Security Roles: Owner, Contributor, Reader
- Predefined Security Policies: For respective roles
Repository Structure
The repository is organized as follows:
- src Is the source code directory of your project.
- src/libraries Is the source code directory where you will add your Nuget package projects.
- src/examples Contains example implementations of your projects.
- src/servers Is the source code directory where you will add your Docker container projects.
- src/aspire Is the source code directory where you will add your Aspire project.
- test Contains test projects for your packages.
- Hexalith.Builds Contains shared build configurations and tools.
Getting Started
Prerequisites
- Hexalith.Builds
- Hexalith.IdentityStores
- .NET 8 SDK or later
- PowerShell 7 or later
- Git
Installation
Add the Hexalith.Security NuGet package to your project:
dotnet add package Hexalith.Security
Configuration
Configure security settings in your appsettings.json
:
{
"Security": {
"Disabled": false
}
}
Examples
Protecting a Blazor Page
@page "/secure-page"
@attribute [Authorize]
<h1>Secure Page</h1>
<p>This page is only accessible to authenticated users.</p>
Using Role-Based Authorization
@page "/admin-page"
@attribute [Authorize(Roles = SecurityRoles.Owner)]
<h1>Admin Page</h1>
<p>This page is only accessible to users with the Owner role.</p>
Using Policy-Based Authorization
@page "/contributor-page"
@attribute [Authorize(Policy = SecurityPolicies.Contributors)]
<h1>Contributors Page</h1>
<p>This page is only accessible to users who can contribute.</p>
Best Practices
- Use predefined roles and policies whenever possible
- Implement the principle of least privilege by assigning minimum required permissions
- Validate authorization at both UI and API levels
- Configure proper authentication mechanisms based on your application type
- Use cascading authentication state in Blazor applications for optimal performance
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support and Community
For support, please open an issue on the GitHub repository.
Join our Discord community: Hexalith Discord
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- Hexalith.IdentityStores.UI (>= 1.0.9)
- Hexalith.Infrastructure.ClientAppOnServer (>= 1.60.0)
- Hexalith.Security.Servers (>= 2.1.1)
- Hexalith.Security.WebApp (>= 2.1.1)
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.1.6 | 0 | 4/22/2025 |
2.1.5 | 0 | 4/22/2025 |
2.1.4 | 0 | 4/22/2025 |
2.1.3 | 0 | 4/22/2025 |
2.1.2 | 41 | 4/21/2025 |
2.1.1 | 40 | 4/21/2025 |
2.1.0 | 36 | 4/21/2025 |
2.0.1 | 40 | 4/21/2025 |
2.0.0 | 43 | 4/19/2025 |
1.54.6 | 142 | 3/19/2025 |
1.54.5 | 138 | 3/19/2025 |
1.53.4 | 138 | 3/18/2025 |
1.53.3 | 156 | 3/11/2025 |
1.53.0 | 92 | 2/28/2025 |
1.52.14 | 97 | 1/15/2025 |
1.52.10 | 97 | 1/10/2025 |
1.52.8 | 100 | 1/6/2025 |
1.52.7 | 89 | 1/6/2025 |
1.51.8 | 117 | 12/15/2024 |
1.51.7 | 81 | 12/15/2024 |
1.51.4 | 118 | 12/7/2024 |
1.1.1 | 45 | 4/19/2025 |
1.1.0 | 45 | 4/19/2025 |
1.0.41 | 149 | 11/25/2024 |
1.0.40 | 90 | 11/25/2024 |
1.0.0 | 50 | 4/19/2025 |