public static IAppBuilder UseHttpBasicAuthentication(this IAppBuilder app, HttpBasicAuthenticationOptions options = null) { if (app == null) { throw new ArgumentNullException("app"); } app.Use(typeof(HttpBasicAuthenticationMiddleware), options != null ? options : new HttpBasicAuthenticationOptions()); app.UseStageMarker(PipelineStage.Authenticate); return app; }
public void Configuration(IAppBuilder app) { var options = new HttpBasicAuthenticationOptions(); options.AuthenticationMode = AuthenticationMode.Active; options.ValidateCredentials = (user, pwd) => { if (user == "max" && pwd == "geheim") return true; return false; }; app.UseHttpBasicAuthentication(options); }