/// <summary></summary>
        /// <param name="appBuilder"></param>
        /// <param name="provider"></param>
        public static void UseBasicAuthentication(this IAppBuilder appBuilder, IBasicAuthenticationProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            BasicAuthenticationOptions options = new BasicAuthenticationOptions
            {
                Provider = provider
            };

            UseBasicAuthentication(appBuilder, options);
        }
        /// <summary></summary>
        /// <param name="appBuilder"></param>
        /// <param name="options"></param>
        public static void UseBasicAuthentication(this IAppBuilder appBuilder, BasicAuthenticationOptions options)
        {
            if (appBuilder == null)
            {
                throw new ArgumentNullException("appBuilder");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            appBuilder.Use(typeof(BasicAuthenticationMiddleware), options);
            appBuilder.MarkStage("Authenticate");
        }
        public BasicAuthenticationMiddleware(Func<IDictionary<string, object>, Task> next,
            BasicAuthenticationOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException("next");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (options.Provider == null)
            {
                // TODO: Get error messages from resources.
                throw new ArgumentException("BasicAuthenticationOptions.Provider must not be null.", "options");
            }

            _next = next;
            _protocol = new BasicAuthenticationProtocol(options.Provider, options.Realm);
        }
示例#4
0
        public BasicAuthenticationMiddleware(Func <IDictionary <string, object>, Task> next,
                                             BasicAuthenticationOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException("next");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (options.Provider == null)
            {
                // TODO: Get error messages from resources.
                throw new ArgumentException("BasicAuthenticationOptions.Provider must not be null.", "options");
            }

            _next     = next;
            _protocol = new BasicAuthenticationProtocol(options.Provider, options.Realm);
        }