Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OWIN/Katana & BasicAuthentication

I am trying to achieve a simple task: Secure my ASP.NET WEBAPI (built on top of Katana) with BASIC Auth. I know I could implement my own middleware or message handler or whatever. However I'm wondering if such a simple task is not already implemented? I found multiple samples on the web that shows how simple it should be. But all of these samples refer to a nuget package named microsoft.owin.security.basic which I can not find anywhere!? Can you help me?

like image 350
LaurinSt Avatar asked Jan 17 '14 15:01

LaurinSt


People also ask

What is OWIN and Katana?

Katana is a flexible set of components for building and hosting Open Web Interface for . NET (OWIN)-based web apps. New development should use ASP.NET Core. The Microsoft. Owin.

What is the purpose of OWIN?

OWIN allows web apps to be decoupled from web servers. It defines a standard way for middleware to be used in a pipeline to handle requests and associated responses.

What is Microsoft OWIN?

Open Web Interface for . NET (OWIN) defines an abstraction between . NET web servers and web applications. By decoupling the web server from the application, OWIN makes it easier to create middleware for . NET web development.

Is Kestrel a OWIN?

Kestrel is just a host implementation. Its goal is to provide OWIN hosting support across many platforms.


2 Answers

First of all you should consider NOT doing basic authentication directly - but rather use the OAuth2 authorization server approach - read this first:

http://leastprivilege.com/2013/11/13/authorization-servers-are-good-for-you-and-your-web-apis/

http://leastprivilege.com/2013/11/13/embedding-a-simple-usernamepassword-authorization-server-in-web-api-v2/

If you still want to do basic auth - then in this repo you will find an implementation for Katana:

https://github.com/thinktecture/Thinktecture.IdentityModel/tree/master/source/Thinktecture.IdentityModel.Owin

nuget: Thinktecture.IdentityModel.Owin

like image 80
leastprivilege Avatar answered Sep 22 '22 11:09

leastprivilege


For those looking for a streamlined way of doing basic auth using Web API+OWIN+Katana, use the excellent Thinktecture.IdentityModel.Owin.BasicAuthentication library.

NuGet: HERE and the source: HERE

like image 20
Sudhanshu Mishra Avatar answered Sep 22 '22 11:09

Sudhanshu Mishra