Delegate DigestAuthenticator
- Namespace
- Cuemon.AspNetCore.Authentication.Digest
- Assembly
- Cuemon.AspNetCore.Authentication.dll
Represents the method that defines an Authenticator typically assigned on DigestAuthenticationOptions.
public delegate ClaimsPrincipal DigestAuthenticator(string username, out string password)
Parameters
usernamestringThe username to match and lookup the paired
password.passwordstringThe password paired with
username.
Returns
- ClaimsPrincipal
A ClaimsPrincipal that is associated with the result of
password.
Examples
The following example demonstrates how to assign and invoke a
using System;
using System.Security.Claims;
using Cuemon.AspNetCore.Authentication.Digest;
namespace MyApp.Examples;
public static class DigestAuthenticatorExample
{
public static void Demonstrate()
{
DigestAuthenticator authenticator = (string username, out string password) =>
{
password = username == "Agent" ? "Test" : null;
return password == null
? null
: new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme));
};
var principal = authenticator("Agent", out var password);
Console.WriteLine(password);
Console.WriteLine(principal?.Identity?.Name);
}
}