Custom Authentication in ASP.Net-Core

rgvassar :

I am working on a web app that needs to integrate with an existing user database. I would still like to use the [Authorize] attributes, but I don't want to use the Identity framework. If I did want to use the Identity framework I would add something like this in the startup.cs file:

services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
    options.Password.RequireNonLetterOrDigit = false;
}).AddEntityFrameworkStores<ApplicationDbContext>()
  .AddDefaultTokenProviders();

I'm assuming I have to add something else there, and then create some kind of class that implements a specific interface? Can somebody point me in the right direction? I'm using RC1 of of asp.net 5 right now.

natemcmaster :

Creating custom authentication in ASP.NET Core can be done in a variety of ways. If you want to build off existing components (but don't want to use identity), checkout the "Security" category of docs on docs.asp.net. https://docs.asp.net/en/latest/security/index.html

Some articles you might find helpful:

Using Cookie Middleware without ASP.NET Identity

Custom Policy-Based Authorization

And of course, if that fails or docs aren't clear enough, the source code is at https://github.com/dotnet/aspnetcore/tree/master/src/Security which includes some samples.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ASP.NET Core Web API Authentication

Token Based Authentication in ASP.NET Core

ASP.NET Web API with custom authentication

Using the Authorize Attribute with Custom Cookie Authentication in ASP.NET Core

Bearer Token Authentication in ASP.NET Core

Windows Authentication with asp.net core

Custom Authentication using legacy user table in Asp.Net Core

Custom authentication asp.net core web api

Asp.net Core Persistent Authentication - Custom Cookie Authentication

How to request authentication from custom middleware in ASP.NET Core 2.0

ASP.NET Core 2.1 Custom RoleProvider with Windows Authentication

ASP.NET Core 2.0 Preview 1: How to set up Cookie Authentication with custom login path

How do I add a custom claim to authentication cookie generated by OpenIdConnect middleware in ASP.Net Core after authentication?

Multiple authentication schemes in ASP.NET Core

ASP.NET Core Identity with Windows Authentication

ASP.Net Core 3.0 Windows Authentication with Custom Role Based Authorization

Blazor WebAssembly Authentication with IdentityServer4, Asp.Net Core Identity and custom provider without Entity Framework

ASP.NET Core JWT with Custom Authentication Type

Authorization failing for custom authentication handler for ASP.NET Core 3.1?

.Net core 3.1 custom authentication

ASP.NET Identity - Steps for custom authentication

How to implement Custom UserStore (or custom authentication) in ASP.NET Core (not older versions!)

Custom ASP.NET MVC Forms Authentication

Custom Authentication mechanism in ASP.Net Core

Implementing A Custom 2 Factor Authentication Mechanism In Asp.Net Core

Custom Authentication & Update Claims in ASP.NET CORE

Asp.net Core Authentication

ASP.Net Core 5.0 Authentication and Authorization

Is it possible to use custom RequireAuthorization and AllowAnonymous for custom middleware authentication in ASP Net Core 6 Minimal APIs?