Skip to content

Dapplesoft-AD/AuthServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AuthServer with Admin Panel

A modern, production-ready authentication and authorization server built with .NET 10, implementing Clean Architecture principles, CQRS pattern, and Domain-Driven Design (DDD).

πŸ—οΈ Architecture

This project follows Clean Architecture with clear separation of concerns across multiple layers:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Presentation Layer          β”‚
β”‚            (Web.Api)                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       Application Layer             β”‚
β”‚     (Use Cases & Handlers)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Domain Layer                 β”‚
β”‚   (Entities & Business Logic)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↑
         β”‚ Dependencies
         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Infrastructure  β”‚
β”‚ (EF Core, Auth) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Architectural Patterns

  • Clean Architecture: Dependency inversion with core business logic independent of external concerns
  • CQRS: Command Query Responsibility Segregation for read/write operations
  • Domain Events: Event-driven architecture for decoupled domain logic
  • Result Pattern: Railway-oriented programming for error handling
  • Repository Pattern: Data access abstraction via DbContext
  • Decorator Pattern: Cross-cutting concerns (validation, logging) via Scrutor

πŸš€ Features

Authentication & Authorization

  • JWT Bearer Token authentication
  • Permission-based authorization system
  • Secure password hashing with BCrypt
  • User registration and login
  • Claims-based identity management

Domain Features

  • User Management: Registration, authentication, profile retrieval
  • Todo Management: Full CRUD operations with priority levels
  • Domain Events: Async event handling for domain state changes

Technical Features

  • FluentValidation: Request validation with decorator pattern
  • Entity Framework Core: PostgreSQL database with migrations
  • Health Checks: Application and database health monitoring
  • Structured Logging: Serilog with Seq integration
  • Swagger/OpenAPI: Interactive API documentation
  • Docker Support: Multi-container deployment with docker-compose

πŸ› οΈ Technology Stack

  • Framework: .NET 9.0
  • Database: PostgreSQL 17
  • ORM: Entity Framework Core 9.0
  • Authentication: JWT Bearer Tokens
  • Validation: FluentValidation 12.0
  • Logging: Serilog with Seq
  • Testing: xUnit, NetArchTest
  • Containerization: Docker & Docker Compose

πŸ“‹ Prerequisites

🚦 Getting Started

Option 1: Docker Compose (Recommended)

  1. Clone the repository

    git clone https://github.com/Dapplesoft-AD/AuthServer.git
    cd AuthServer
  2. Run with Docker Compose

    docker-compose up --build

local

docker compose -f docker-local-compose.yml up -d --build
  1. Access the application
    • API: http://localhost:5000
    • Swagger UI: http://localhost:5000/swagger
    • Seq Logs: http://localhost:8081

Option 2: Local Development

  1. Clone the repository

    git clone https://github.com/Dapplesoft-AD/AuthServer.git
    cd AuthServer
  2. Update connection string (if needed)

    Edit src/Web.Api/appsettings.Development.json:

    "ConnectionStrings": {
      "Database": "Host=localhost;Database=clean-architecture;Username=postgres;Password=postgres"
    }
  3. Apply database migrations

    cd src/Web.Api
    dotnet ef database update
  4. Run the application

    dotnet run
  5. Access Swagger UI

    Navigate to: https://localhost:5001/swagger

πŸ“ Project Structure

AuthServer/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Domain/                    # Enterprise business rules
β”‚   β”‚   β”œβ”€β”€ Users/                 # User aggregate
β”‚   β”‚   └── Todos/                 # Todo aggregate
β”‚   β”œβ”€β”€ Application/               # Application business rules
β”‚   β”‚   β”œβ”€β”€ Abstractions/          # Interfaces & contracts
β”‚   β”‚   β”œβ”€β”€ Users/                 # User use cases
β”‚   β”‚   └── Todos/                 # Todo use cases
β”‚   β”œβ”€β”€ Infrastructure/            # External concerns
β”‚   β”‚   β”œβ”€β”€ Authentication/        # JWT & password hashing
β”‚   β”‚   β”œβ”€β”€ Authorization/         # Permission system
β”‚   β”‚   β”œβ”€β”€ Database/              # EF Core DbContext
β”‚   β”‚   └── DomainEvents/          # Event dispatcher
β”‚   β”œβ”€β”€ SharedKernel/              # Shared primitives
β”‚   β”‚   β”œβ”€β”€ Entity.cs              # Base entity
β”‚   β”‚   β”œβ”€β”€ Result.cs              # Result pattern
β”‚   β”‚   └── Error.cs               # Error handling
β”‚   └── Web.Api/                   # Presentation layer
β”‚       β”œβ”€β”€ Endpoints/             # Minimal API endpoints
β”‚       └── Middleware/            # HTTP pipeline
└── tests/
    └── ArchitectureTests/         # Architecture enforcement tests

πŸ” API Endpoints

Authentication

Method Endpoint Description
POST /users/register Register a new user
POST /users/login Authenticate and receive JWT token
GET /users/{id} Get user by ID (requires auth)

Todo Management

Method Endpoint Description
GET /todos Get all todos for authenticated user
GET /todos/{id} Get specific todo by ID
POST /todos Create a new todo
PUT /todos/{id}/complete Mark todo as completed
DELETE /todos/{id} Delete a todo

Health & Monitoring

Method Endpoint Description
GET /health Application health check

πŸ§ͺ Testing

Run Architecture Tests

dotnet test tests/ArchitectureTests

Architecture tests enforce:

  • Domain layer has no dependencies on Application, Infrastructure, or Presentation
  • Application layer has no dependencies on Infrastructure or Presentation
  • Infrastructure layer has no dependencies on Presentation

πŸ”§ Configuration

JWT Configuration

Edit appsettings.json:

{
  "Jwt": {
    "Secret": "your-secret-key-min-32-characters",
    "Issuer": "AuthServer",
    "Audience": "AuthServer",
    "ExpirationInMinutes": 60
  }
}

Database Configuration

{
  "ConnectionStrings": {
    "Database": "Host=localhost;Database=clean-architecture;Username=postgres;Password=postgres"
  }
}

🐳 Docker Configuration

The project includes:

  • Dockerfile for the Web API
  • docker-compose.yml orchestrating:
    • web-api: .NET application (ports 5000, 5001)
    • postgres: PostgreSQL database (port 5432)
    • seq: Structured log viewer (port 8081)

Default Credentials

admin@auth.dapplesoft.com
admin12345

πŸ“Š Code Quality

This project maintains high code quality standards:

  • βœ… TreatWarningsAsErrors: Enabled
  • βœ… Nullable Reference Types: Enabled
  • βœ… SonarAnalyzer: Static code analysis
  • βœ… Architecture Tests: Layer dependency enforcement
  • βœ… Central Package Management: Consistent versioning

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Authors

Dapplesoft-AD

πŸ™ Acknowledgments

  • Clean Architecture by Robert C. Martin
  • Domain-Driven Design by Eric Evans
  • CQRS pattern inspiration from various enterprise implementations

Built with ❀️ using .NET 9

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 10