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) }); }