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;
        }
示例#2
0
        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);
        }