https://github.com/osisdie/dotnet-webapi-auth-boilerplate
Production-ready .NET WebAPI with JWT authentication, refresh tokens, Dapper ORM, Redis caching — powered by CoreFX SDK
https://github.com/osisdie/dotnet-webapi-auth-boilerplate
authentication boilerplate corefx dapper docker dotnet jwt kubernetes redis swagger webapi
Last synced: 6 days ago
JSON representation
Production-ready .NET WebAPI with JWT authentication, refresh tokens, Dapper ORM, Redis caching — powered by CoreFX SDK
- Host: GitHub
- URL: https://github.com/osisdie/dotnet-webapi-auth-boilerplate
- Owner: osisdie
- License: mit
- Created: 2021-04-18T11:29:48.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2026-03-24T13:57:58.000Z (3 months ago)
- Last Synced: 2026-03-25T17:47:39.972Z (3 months ago)
- Topics: authentication, boilerplate, corefx, dapper, docker, dotnet, jwt, kubernetes, redis, swagger, webapi
- Language: C#
- Size: 118 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# dotnet-webapi-auth-boilerplate
[](https://github.com/osisdie/dotnet-webapi-auth-boilerplate/actions/workflows/ci.yml)
[](https://dotnet.microsoft.com/download/dotnet/8.0)
[](https://dotnet.microsoft.com/download/dotnet/10.0)
[](LICENSE)
Production-ready .NET WebAPI with JWT authentication, refresh tokens, Dapper ORM, and Redis caching — powered by [CoreFX SDK](https://github.com/osisdie/dotnet-corefx-sdk).
## Features
- **JWT Authentication** — Login, access tokens (60 min), refresh tokens (180 min)
- **Multi-target** — Supports both .NET 8.0 LTS and .NET 10.0
- **Redis Caching** — `IDistributedCache` with StackExchange.Redis and failback scoring
- **Dapper ORM** — Async database access with SQL Server
- **Log4net Logging** — Console, file, and AWS CloudWatch support
- **Middleware Pipeline** — Exception handling, JWT authorization, request/response logging
- **Swagger/OpenAPI** — Versioned API docs (v202603, v202104, v202103)
- **Health Checks** — Built-in `/health` endpoint
- **Docker & K8s** — Multi-stage Dockerfile and minikube manifests
- **Configuration** — Environment-based (Debug/Development/Testing/Staging/Production)
- **FluentValidation** — Request data validation
- **xUnit Testing** — Unit and integration test projects
## Prerequisites
- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) or [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
- [Redis](https://redis.io/) (optional, for caching features)
- [Docker](https://www.docker.com/) (optional, for container deployment)
## Quick Start
```bash
# Clone
git clone https://github.com/osisdie/dotnet-webapi-auth-boilerplate.git
cd dotnet-webapi-auth-boilerplate
# Set required env var
export COREFX_API_NAME=auth-dev
# Build & Run
dotnet build auth-api-all-projects.sln
dotnet run --project src/Endpoint/Hello6/Hello6.Domain.Endpoint.csproj
# Browse
# http://localhost:5006/swagger
# http://localhost:5006/health
```
## Projects
**Hello6.Domain.Endpoint** is the primary web application wrapping all dependent projects:
- **CoreFX** — Shared framework libraries
- CoreFX.Abstractions, CoreFX.Common, CoreFX.Hosting
- CoreFX.Auth, CoreFX.Caching.Redis, CoreFX.Logging.Log4net
- CoreFX.Notification.Smtp
- **Hello6** — Domain-driven design services
- Hello6.Domain.Common, Hello6.Domain.Contract
- Hello6.Domain.DataAccess.Database, Hello6.Domain.SDK
## API Endpoints
| Endpoint | Description |
|----------|-------------|
| `GET /health` | Health check |
| `GET /api/echo/ver` | Service version |
| `GET /api/echo/config` | Configuration status |
| `GET /api/echo/db` | Database connection check |
| `GET /api/echo/cache` | Redis cache check |
| `POST /api/auth/login` | JWT login |
| `POST /api/auth/refreshtoken` | Refresh JWT token |
## Docker
```bash
export VERSION=$(cat src/Endpoint/Hello6/.version | head -n1)
export IMAGE_HOST=docker.io/[ACCOUNT-ID]
bash dockerbuild.sh
```
## Testing
```bash
# Unit tests
dotnet test auth-api-all-projects.sln -c Release
# Integration test (requires running service)
export ASPNETCORE_ENVIRONMENT=Development
export CI_TEST_ENDPOINT=http://localhost:5006
dotnet test tests/IntegrationTest/Hello6/IntegrationTest.Hello6.csproj -c Release
```
## See Also
- [dotnet-corefx-sdk](https://github.com/osisdie/dotnet-corefx-sdk) — The reusable CoreFX framework
- [dotnet-minikube-boilerplate](https://github.com/osisdie/dotnet-minikube-boilerplate) — K8s deployment focused
- [dotnet-mediatr-boilerplate](https://github.com/osisdie/dotnet-mediatr-boilerplate) — MediatR/CQRS focused
## License
[MIT](LICENSE)