AuthEndpoints
AuthEndpoints copied to clipboard
A simple jwt library for Asp.Net 6 that provides a set of minimal api endpoints to handle authentication actions
AuthEndpoints
A simple jwt authentication library for ASP.Net 6. AuthEndpoints library provides a set of Web API controllers and minimal api endpoints to handle basic web & JWT authentication actions such as registration, email verification, reset password, create jwt, etc. It works with custom identity user model. AuthEndpoints is built with the aim of increasing developer productivity.
Supported endpoints
- Basic authentication actions:
- sign-up
- email verification
- user profile (retrieving)
- reset password
- change password
- enable 2fa
- login 2fa
- TokenAuth:
- Create (login)
- Destroy (logout)
- Simple JWT:
- Create (login)
- Refresh
- Verify
Current limitations
- Only works with IdentityUser or custom identity user
- No session based auth support
- 2fa via email
Installing via NuGet
The easiest way to install AuthEndpoints is via NuGet
Install the library using the following .net cli command:
dotnet add package AuthEndpoints
or in Visual Studio's Package Manager Console, enter the following command:
Install-Package AuthEndpoints
Quick start
// MyDbContext.cs
using AuthEndpoints.SimpleJwt.Core.Models;
DbSet<RefreshToken>? RefreshTokens { get; set; } // <--
// Program.cs
// Required services
builder.Services
.AddIdentityCore<IdentityUser>() // <-- or `AddIdentity<,>`
.AddEntityFrameworkStores<MyDbContext>() // <-- Install Microsoft.AspNetCore.Identity.EntityFrameworkCore
.AddDefaultTokenProviders(); // <--
// Add basic authentication endpoints
builder.Services.AddAuthEndpointsCore<IdentityUser>()
.AddBasicAuthenticationEndpoints()
.Add2FAEndpoints();
// Add jwt endpoints
builder.Services.AddSimpleJwtEndpoints<IdentityUser, MyDbContext>();
var app = builder.Build();
...
app.UseAuthentication(); // <--
app.UseAuthorization(); // <--
...
app.MapEndpoints(); // <--
app.Run();
Checkout docs for more info.
Documentations
Documentation is available at https://madeyoga.github.io/AuthEndpoints/ and in docs directory.
Contributing
Your contributions are always welcome! simply send a pull request! The up-for-grabs label is a great place to start. If you find a flaw, please open an issue or a PR and let's sort things out.
The documentation is far from perfect so every bit of help is more than welcome.