Hexalith.Security.UI.Components
2.1.6
dotnet add package Hexalith.Security.UI.Components --version 2.1.6
NuGet\Install-Package Hexalith.Security.UI.Components -Version 2.1.6
<PackageReference Include="Hexalith.Security.UI.Components" Version="2.1.6" />
<PackageVersion Include="Hexalith.Security.UI.Components" Version="2.1.6" />
<PackageReference Include="Hexalith.Security.UI.Components" />
paket add Hexalith.Security.UI.Components --version 2.1.6
#r "nuget: Hexalith.Security.UI.Components, 2.1.6"
#addin nuget:?package=Hexalith.Security.UI.Components&version=2.1.6
#tool nuget:?package=Hexalith.Security.UI.Components&version=2.1.6
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.Application.Partitions.Abstractions (>= 1.60.0)
- Hexalith.Application.Sessions.Abstractions (>= 1.60.0)
- Hexalith.Security.Application (>= 2.1.6)
- Hexalith.UI.Components (>= 1.60.0)
- Microsoft.AspNetCore.Components.Authorization (>= 9.0.4)
- Microsoft.AspNetCore.Components.Web (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Hexalith.Security.UI.Components:
Package | Downloads |
---|---|
Hexalith.Security.UI.Pages
Hexalith is a set of libraries to build an application with micro-service architecture. |
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 | 54 | 4/21/2025 |
2.1.1 | 62 | 4/21/2025 |
2.1.0 | 52 | 4/21/2025 |
2.0.1 | 59 | 4/21/2025 |
2.0.0 | 69 | 4/19/2025 |
1.54.6 | 160 | 3/19/2025 |
1.54.5 | 155 | 3/19/2025 |
1.53.4 | 149 | 3/18/2025 |
1.53.3 | 159 | 3/11/2025 |
1.53.0 | 108 | 2/28/2025 |
1.52.14 | 107 | 1/15/2025 |
1.52.10 | 120 | 1/10/2025 |
1.52.8 | 104 | 1/6/2025 |
1.52.7 | 98 | 1/6/2025 |
1.51.8 | 134 | 12/15/2024 |
1.51.7 | 96 | 12/15/2024 |
1.51.4 | 120 | 12/7/2024 |
1.1.1 | 70 | 4/19/2025 |
1.1.0 | 73 | 4/19/2025 |
1.0.41 | 168 | 11/25/2024 |
1.0.40 | 107 | 11/25/2024 |
1.0.0 | 80 | 4/19/2025 |