SilverLABS.SilverSHELL.Auth.Server 1.0.0

SilverLABS.SilverSHELL.Auth.Server

Enterprise-grade authentication server library for ASP.NET Core applications.

Features

  • JWT Authentication - HS256 token signing with configurable expiration
  • Refresh Tokens - Automatic token rotation for enhanced security
  • Session Management - Track and revoke sessions across multiple devices
  • Audit Logging - Comprehensive authentication event tracking
  • Rate Limiting - IP-based brute force protection
  • Password Security - BCrypt hashing with salt
  • Password Reset - Token-based password recovery flow
  • Role-Based Authorization - Multi-role support with claims

Installation

dotnet add package SilverLABS.SilverSHELL.Auth.Server

Quick Start

1. Configure appsettings.json

{
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=auth.db"
  },
  "Jwt": {
    "SecretKey": "YOUR-SECRET-KEY-32-CHARACTERS-MINIMUM",
    "Issuer": "YourApp.Auth.Server",
    "Audience": "YourApp.Client",
    "ExpirationMinutes": 60,
    "RefreshTokenExpirationDays": 7
  },
  "IpRateLimiting": {
    "GeneralRules": [
      {"Endpoint": "*/api/auth/login", "Period": "1m", "Limit": 5},
      {"Endpoint": "*/api/auth/register", "Period": "1h", "Limit": 3}
    ]
  }
}

2. Configure Services

In your Program.cs:

using SilverSHELL.Auth.Server.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add SilverSHELL authentication (auto-configured from appsettings.json)
builder.Services.AddSilverShellAuth();

var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();

app.Run();

3. Use in Controllers

[Authorize]
[ApiController]
[Route("api/[controller]")]
public class MyController : ControllerBase
{
    [HttpGet("admin")]
    [Authorize(Roles = "Admin")]
    public IActionResult AdminOnly()
    {
        return Ok("Admin access granted");
    }

    [HttpGet("profile")]
    public IActionResult GetProfile()
    {
        var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
        return Ok(new { UserId = userId });
    }
}

API Endpoints

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/login Authenticate user
POST /api/auth/refresh Refresh access token
POST /api/auth/logout Logout from all devices
GET /api/auth/sessions Get active sessions
DELETE /api/auth/sessions/{id} Revoke session
POST /api/auth/password-reset/request Request password reset
POST /api/auth/password-reset/confirm Confirm password reset

Database Models

The library includes Entity Framework Core models for:

  • Users - User accounts with credentials
  • Roles - User roles (Admin, User, etc.)
  • UserRoles - Many-to-many relationship
  • RefreshTokens - Refresh token storage with rotation
  • UserSessions - Active session tracking
  • AuditLogs - Authentication event logging
  • PasswordResetTokens - Password reset token management

Security Features

  • BCrypt Password Hashing - Industry-standard password security
  • JWT Token Signing - HS256 algorithm
  • Refresh Token Rotation - Prevents token replay attacks
  • Rate Limiting - Configurable per endpoint
  • Audit Logging - All authentication events tracked
  • Session Management - Revoke compromised sessions
  • CORS Protection - Whitelist-based origins

Documentation

Support

License

This project is licensed under the MIT License.


Made with ❤️ by SilverLABS

No packages depend on SilverLABS.SilverSHELL.Auth.Server.

Version Downloads Last updated
1.1.1 5 10/06/2025
1.1.0 4 10/06/2025
1.0.0 4 10/06/2025