12

Is it possible to use digest authentication in ASP.NET Core / Kestrel? If it is, how do I enable and use it?

I know that basic authentication is not and will not be implemented because it's considered insecure and slow, but I can't find anything at all about digest.

I don't want to use IIS' authentication because I don't want to be tied to Windows accounts, I want use a custom credentials validation logic.

Albireo
  • 10,977
  • 13
  • 62
  • 96

3 Answers3

5

The only implementation of digest auth currently available with Core is the one in IIS that's tied to integrated windows auth.

Tratcher
  • 5,929
  • 34
  • 44
0

If someone is looking for the answer. This code is working for me:

using System.ServiceModel;

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest;
binding.TextEncoding = Encoding.UTF8;
binding.TransferMode = TransferMode.Buffered;
binding.AllowCookies = false;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

var endpoint = new EndpointAddress(new Uri("http://website.domain/WebService.svc"));
var client = new MessageServiceClient(binding, endpoint);
client.ClientCredentials.HttpDigest.ClientCredential.UserName = "username";
client.ClientCredentials.HttpDigest.ClientCredential.Password = "password";

var response = client.CallMethod();
-4

Few thing about Kestrel, WebListener servers and authentication

And example how you can allow anonymous users using WebListener:

builder.UseWebListener(options =>
{    
     options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.AllowAnonymous;
});
Dawid Rutkowski
  • 2,658
  • 1
  • 29
  • 36
  • 2
    I'm not asking for [Integrated Windows Authentication](https://en.wikipedia.org/wiki/Integrated_Windows_Authentication), what I'm looking for is [digest access authentication](https://en.wikipedia.org/wiki/Digest_access_authentication). – Albireo Oct 21 '16 at 09:38