Skip to content

Latest commit

 

History

History

Passwordless.AspNetCore

Passwordless ASP.NET Core Integration

Version Downloads

The official Bitwarden Passwordless.dev ASP.NET Identity integration. Automatically adds endpoints to verify passwordless signin and sign the user in using the existing ASP.NET Identity code.

Install

  • NuGet: dotnet add package Passwordless.AspNetCore

Usage

💡 See the full Getting started guide in the official documentation.

Using Minimal APIs

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddIdentity<MyUser, MyRole>()
      .AddEntityFrameworkStores<MyDbContext>()
      .AddPasswordless(builder.Configuration.GetRequiredSection("Passwordless"));

var app = builder.Build();

app.MapPasswordless();

app.Run();

Using Startup class

// In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    services.AddIdentity<MyUser, MyRole>()
      .AddEntityFrameworkStores<MyDbContext>()
      .AddPasswordless(Configuration.GetRequiredSection("Passwordless"));

    services.AddControllers();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseRouting();

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

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapPasswordless();
        endpoints.MapControllers();
    });
}