This repository contains a collection of authentication and authorization samples built with ASP.NET Core (.NET 8/9). Each sample demonstrates a different authentication technique or security scenario. These projects are intended for learning and demonstration purposes.
A basic .NET console project. Used for simple C# code demonstrations.
Demonstrates classic forms authentication using cookies in ASP.NET Core MVC. Includes login, logout, and secure pages.
Shows how to implement certificate pinning for outgoing HTTP requests to enhance security against man-in-the-middle attacks.
Implements passwordless authentication using magic links sent via email. Built with ASP.NET Core Identity and in-memory database.
Demonstrates API key authentication for securing APIs. Clients must provide a valid API key in requests.
Shows how to integrate OAuth 2.0 and OpenID Connect authentication using an external identity provider.
Implements two-factor authentication (2FA) using ASP.NET Core Identity. Users must complete a second verification step after login.
Demonstrates stateless authentication using JSON Web Tokens (JWT). Includes token generation and validation for API endpoints.
Shows cookie-based authentication for APIs. Includes login, logout, and profile endpoints protected by cookies.
Demonstrates policy-based authorization with custom requirements and handlers. Includes sample policies for age, department, and resource ownership.
Simulates biometric authentication (e.g., fingerprint) using WebAuthn/FIDO2 concepts. Built with ASP.NET Core Identity.
Demonstrates Windows Authentication for intranet scenarios. Secures endpoints using the current Windows user context.
Shows how to secure APIs using client certificate authentication. Includes public and protected endpoints.
Each sample is a standalone ASP.NET Core project. To run a sample:
- Open the solution in Visual Studio or VS Code.
- Set the desired project as the startup project.
- Build and run the project.
- Follow the instructions in the browser or API documentation (Swagger where available).
- .NET 8.0 or .NET 9.0 SDK
- Visual Studio 2022+ or VS Code
This repository is for educational purposes.