public static void AddBasicAuthentication(this AuthenticationConfiguration configuration, Func<string, string, bool> validationDelegate, Func<string, string[]> roleDelegate, string realm = "localhost", bool retainPassword = false) { var handler = new BasicAuthenticationWithRoleSecurityTokenHandler(validationDelegate, roleDelegate); handler.RetainPassword = retainPassword; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = AuthenticationOptions.ForAuthorizationHeader(scheme: "Basic"), Scheme = AuthenticationScheme.SchemeAndRealm("Basic", realm) }); }
public static void AddBasicAuthentication(this AuthenticationConfiguration configuration, BasicAuthenticationSecurityTokenHandler.ValidateUserNameCredentialDelegate validationDelegate, AuthenticationOptions options, string realm = "localhost", bool retainPassword = false) { var handler = new BasicAuthenticationSecurityTokenHandler(validationDelegate); handler.RetainPassword = retainPassword; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options, Scheme = AuthenticationScheme.SchemeAndRealm("Basic", realm) }); }