Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic Authentication in ASP.NET Core

Question

How can I implement Basic Authentication with Custom Membership in an ASP.NET Core web application?

Notes

  • In MVC 5 I was using the instructions in this article which requires adding a module in the WebConfig.

  • I am still deploying my new MVC Coreapplication on IIS but this approach seems not working.

  • I also do not want to use the IIS built in support for Basic authentication, since it uses Windows credentials.

like image 316
A-Sharabiani Avatar asked Feb 09 '16 16:02

A-Sharabiani


2 Answers

ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems.

If you require Basic Authentication middleware for testing purposes, then please look at https://github.com/blowdart/idunno.Authentication

like image 187
blowdart Avatar answered Sep 29 '22 03:09

blowdart


ASP.NET Core 2.0 introduced breaking changes to Authentication and Identity.

On 1.x auth providers were configured via Middleware (as the accepted answer's implementation). On 2.0 it's based on services.

Details on MS doc: https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x

I've written a Basic Authentication implementation for ASP.NET Core 2.0 and publish to NuGet: https://github.com/bruno-garcia/Bazinga.AspNetCore.Authentication.Basic

like image 44
Bruno Garcia Avatar answered Sep 29 '22 01:09

Bruno Garcia