/// <summary>
        /// Creates a new instance of the SendFileMiddleware.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="options">The configuration for this middleware.</param>
        public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, DirectoryBrowserOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (hostingEnv == null)
            {
                throw new ArgumentNullException(nameof(hostingEnv));
            }

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

            if (options.Formatter == null)
            {
                throw new ArgumentException(Resources.Args_NoFormatter);
            }
            options.ResolveFileProvider(hostingEnv);

            _next = next;
            _options = options;
            _matchUrl = options.RequestPath;
        }
 public CommonExceptionHandlerMiddleware(
     RequestDelegate next,
     ILoggerFactory loggerFactory,
     DiagnosticSource diagnosticSource,
     IOptions<ExceptionHandlerOptions> options = null
     )
 {
     _next = next;
     if(options == null)
     {
         _options = new ExceptionHandlerOptions();
     }
     else
     {
         _options = options.Value;
     }
     
     _logger = loggerFactory.CreateLogger<CommonExceptionHandlerMiddleware>();
     if (_options.ExceptionHandler == null)
     {
         _options.ExceptionHandler = _next;
     }
     _clearCacheHeadersDelegate = ClearCacheHeaders;
     _diagnosticSource = diagnosticSource;
 }
 public CookiePolicyMiddleware(
     RequestDelegate next,
     CookiePolicyOptions options)
 {
     Options = options;
     _next = next;
 }
Esempio n. 4
0
 public ErrorHandler(RequestDelegate next, int status, IErrorPage page, WebServiceType check)
 {
     _next = next;
     _page = page;
     _status = status;
     _check = check;
 }
    public RaygunAspNetMiddleware(RequestDelegate next, IOptions<RaygunSettings> settings, RaygunMiddlewareSettings middlewareSettings)
    {
      _next = next;
      _middlewareSettings = middlewareSettings;

      _settings = _middlewareSettings.ClientProvider.GetRaygunSettings(settings.Value ?? new RaygunSettings());  
    }
Esempio n. 6
0
 public QRCodeMiddleware(RequestDelegate next, IQRCodeGenerator generator, IMemoryCache cache, ILogger<QRCodeMiddleware> logger)
 {
     this.next = next;
     this.logger = logger;
     this.generator = generator;
     this.cache = cache;
 }
Esempio n. 7
0
        public THttpServerTransport(ITAsyncProcessor processor, ITProtocolFactory inputProtocolFactory,
            ITProtocolFactory outputProtocolFactory, RequestDelegate next, ILoggerFactory loggerFactory)
        {
            if (processor == null)
            {
                throw new ArgumentNullException(nameof(processor));
            }

            if (inputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(inputProtocolFactory));
            }

            if (outputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(outputProtocolFactory));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            Processor = processor;
            InputProtocolFactory = inputProtocolFactory;
            OutputProtocolFactory = outputProtocolFactory;

            _next = next;
            _logger = loggerFactory.CreateLogger<THttpServerTransport>();
        }
        public OrchardShellHostMiddleware(
            RequestDelegate next,
            IOrchardShellHost orchardShellHost) {

            _next = next;
            _orchardShellHost = orchardShellHost;
        }
Esempio n. 9
0
        /// <summary>
        /// Instantiates a new <see cref="CorsMiddleware"/>.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="corsService">An instance of <see cref="ICorsService"/>.</param>
        /// <param name="policyProvider">A policy provider which can get an <see cref="CorsPolicy"/>.</param>
        /// <param name="policyName">An optional name of the policy to be fetched.</param>
        public CorsMiddleware(
            RequestDelegate next,
            ICorsService corsService,
            ICorsPolicyProvider policyProvider,
            string policyName)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (corsService == null)
            {
                throw new ArgumentNullException(nameof(corsService));
            }

            if (policyProvider == null)
            {
                throw new ArgumentNullException(nameof(policyProvider));
            }

            _next = next;
            _corsService = corsService;
            _corsPolicyProvider = policyProvider;
            _corsPolicyName = policyName;
        }
Esempio n. 10
0
        public SessionMiddleware(
            [NotNull] RequestDelegate next,
            [NotNull] ILoggerFactory loggerFactory,
            [NotNull] IEnumerable<ISessionStore> sessionStore,
            [NotNull] IOptions<SessionOptions> options,
            [NotNull] ConfigureOptions<SessionOptions> configureOptions)
        {
            _next = next;
            _logger = loggerFactory.Create<SessionMiddleware>();
            if (configureOptions != null)
            {
                _options = options.GetNamedOptions(configureOptions.Name);
                configureOptions.Configure(_options);
            }
            else
            {
                _options = options.Options;
            }

            if (_options.Store == null)
            {
                _options.Store = sessionStore.FirstOrDefault();
                if (_options.Store == null)
                {
                    throw new ArgumentException("ISessionStore must be specified.");
                }
            }

            _options.Store.Connect();
        }
 public OrchardRouterMiddleware(
     RequestDelegate next,
     ILogger<OrchardRouterMiddleware> logger)
 {
     _next = next;
     _logger = logger;
 }
 public RequestIdMiddleware(RequestDelegate next, ILogger<RequestIdMiddleware> logger)
 {
     if (next == null) throw new ArgumentNullException(nameof(next));
     if (logger == null) throw new ArgumentNullException(nameof(logger));
     _next = next;
     _logger = logger;
 }
Esempio n. 13
0
        public WebSocketMiddleware(RequestDelegate next, WebSocketOptions options)
        {
            _next = next;
            _options = options;

            // TODO: validate options.
        }
        public HttpServiceGatewayMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            IHttpCommunicationClientFactory httpCommunicationClientFactory,
            IOptions<HttpServiceGatewayOptions> gatewayOptions)
        {
            if (next == null)
                throw new ArgumentNullException(nameof(next));

            if (loggerFactory == null)
                throw new ArgumentNullException(nameof(loggerFactory));

            if (httpCommunicationClientFactory == null)
                throw new ArgumentNullException(nameof(httpCommunicationClientFactory));

            if (gatewayOptions?.Value == null)
                throw new ArgumentNullException(nameof(gatewayOptions));

            if (gatewayOptions.Value.ServiceName == null)
                throw new ArgumentNullException($"{nameof(gatewayOptions)}.{nameof(gatewayOptions.Value.ServiceName)}");

            // "next" is not stored because this is a terminal middleware
            _logger = loggerFactory.CreateLogger(HttpServiceGatewayDefaults.LoggerName);
            _httpCommunicationClientFactory = httpCommunicationClientFactory;
            _gatewayOptions = gatewayOptions.Value;
        }
 public MockAuthorizationPipeline(IApplicationEnvironment environment)
 {
     _environment = environment;
     Login = OnLogin;
     Consent = OnConsent;
     Error = OnError;
 }
 public ClaimsTransformationMiddleware(
     [NotNull] RequestDelegate next,
     [NotNull] ClaimsTransformationOptions options)
 {
     Options = options;
     _next = next;
 }
        public OrchardShellHostMiddleware(
            RequestDelegate next,
            IShellHost shellHost) {

            _next = next;
            _shellHost = shellHost;
        }
Esempio n. 18
0
        /// <summary>
        /// Creates a new <see cref="SessionMiddleware"/>.
        /// </summary>
        /// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
        /// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
        /// <param name="options">The session configuration options.</param>
        public SessionMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            ISessionStore sessionStore,
            IOptions<SessionOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (sessionStore == null)
            {
                throw new ArgumentNullException(nameof(sessionStore));
            }

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

            _next = next;
            _logger = loggerFactory.CreateLogger<SessionMiddleware>();
            _options = options.Value;
            _sessionStore = sessionStore;
            _sessionStore.Connect();
        }
 public MetaWeblogMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, string urlEndpoint, MetaWeblogService service)
 {
   _next = next;
   _logger = loggerFactory.CreateLogger<MetaWeblogMiddleware>(); ;
   _urlEndpoint = urlEndpoint;
   _service = service;
 }
Esempio n. 20
0
 public CookiePolicyMiddleware(
     RequestDelegate next,
     IOptions<CookiePolicyOptions> options)
 {
     Options = options.Value;
     _next = next;
 }
 public RequestCultureMiddleware(RequestDelegate next, IOptions<RequestCultureOptions> options)
 {
     if (next == null) throw new ArgumentNullException(nameof(next));
     if (options == null) throw new ArgumentNullException(nameof(options));
     _next = next;
     _options = options.Value;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RuntimeInfoMiddleware"/> class
        /// </summary>
        /// <param name="next"></param>
        /// <param name="options"></param>
        public RuntimeInfoMiddleware(
            RequestDelegate next,
            RuntimeInfoPageOptions options,
            ILibraryManager libraryManager,
            IRuntimeEnvironment runtimeEnvironment)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

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

            if (libraryManager == null)
            {
                throw new ArgumentNullException(nameof(libraryManager));
            }

            if (runtimeEnvironment == null)
            {
                throw new ArgumentNullException(nameof(runtimeEnvironment));
            }

            _next = next;
            _options = options;
            _libraryManager = libraryManager;
            _runtimeEnvironment = runtimeEnvironment;
        }
        public IdentityServerAuthenticationMiddleware(RequestDelegate next, IApplicationBuilder app, CombinedAuthenticationOptions options, ILogger<IdentityServerAuthenticationMiddleware> logger)
        {
            _next = next;
            _options = options;
            _logger = logger;

            // building pipeline for introspection middleware
            if (options.IntrospectionOptions != null)
            {
                var introspectionBuilder = app.New();
                introspectionBuilder.UseOAuth2IntrospectionAuthentication(options.IntrospectionOptions);
                introspectionBuilder.Run(ctx => next(ctx));
                _introspectionNext = introspectionBuilder.Build();
            }

            // building pipeline for JWT bearer middleware
            if (options.JwtBearerOptions != null)
            {
                var jwtBuilder = app.New();
                jwtBuilder.UseJwtBearerAuthentication(options.JwtBearerOptions);
                jwtBuilder.Run(ctx => next(ctx));
                _jwtNext = jwtBuilder.Build();
            }

            // building pipeline for no token
            var nopBuilder = app.New();
            var nopOptions = new NopAuthenticationOptions
            {
                AuthenticationScheme = options.AuthenticationScheme
            };

            nopBuilder.UseMiddleware<NopAuthenticationMiddleware>(nopOptions);
            nopBuilder.Run(ctx => next(ctx));
            _nopNext = nopBuilder.Build();
        }
		public PrerenderMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IOptions<PrerenderConfiguration> configuration)
		{
			_next = next;
			this.configuration = configuration;
			logger = loggerFactory.CreateLogger<RequestLoggerMiddleware>();
			helper = new WebRequestHelper(logger, configuration.Options);
    }
 public ConditionalProxyMiddleware(RequestDelegate next, string pathPrefix, ConditionalProxyMiddlewareOptions options)
 {
     this.next = next;
     this.pathPrefix = pathPrefix;
     this.options = options;
     this.httpClient = new HttpClient(new HttpClientHandler());
 }
Esempio n. 26
0
        public void Publish(IEnumerable<RouteDescriptor> routes, RequestDelegate pipeline)
        {
            var orderedRoutes = routes
                .OrderByDescending(r => r.Priority)
                .ToList();

            string routePrefix = "";
            if (!String.IsNullOrWhiteSpace(_shellSettings.RequestUrlPrefix))
            {
                routePrefix = _shellSettings.RequestUrlPrefix + "/";
            }

            orderedRoutes.Insert(0, new RouteDescriptor
            {
                Route = new Route("Default", "{area}/{controller}/{action}/{id?}")
            });


            var inlineConstraint = _routeBuilder.ServiceProvider.GetService<IInlineConstraintResolver>();

            foreach (var route in orderedRoutes)
            {
                IRouter router = new TemplateRoute(
                    _routeBuilder.DefaultHandler,
                    route.Route.RouteName,
                    routePrefix + route.Route.RouteTemplate,
                    route.Route.Defaults,
                    route.Route.Constraints,
                    route.Route.DataTokens,
                    inlineConstraint);

                _routeBuilder.Routes.Add(new TenantRoute(_shellSettings, router, pipeline));
            }
        }
		public ApiErrorHandlerMiddleware(RequestDelegate next, ILogger<ApiErrorHandlerMiddleware> logger, IContextProblemDetectionHandler contextProblemDetectionHandler, IExceptionProblemDetectionHandler exceptionProblemDetectionHandler)
		{
			_next = next;
			_logger = logger;
			_contextProblemDetectionHandler = contextProblemDetectionHandler;
			_exceptionProblemDetectionHandler = exceptionProblemDetectionHandler;
		}
 public DebugInfoPageMiddleware(RequestDelegate next, IServerAddressesFeature serverAddresses, IHostingEnvironment hostingEnv, Scenarios scenarios)
 {
     _next = next;
     _hostingEnv = hostingEnv;
     _scenarios = scenarios;
     _serverAddresses = serverAddresses;
 }
Esempio n. 29
0
 public TenantRoute(IRouter target, 
     string urlHost, 
     RequestDelegate pipeline) {
     _target = target;
     _urlHost = urlHost;
     _pipeline = pipeline;
 }
Esempio n. 30
0
        /// <summary>
        /// Creates a new instance of the StaticFileMiddleware.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="options">The configuration options.</param>
        /// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
        public StaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, StaticFileOptions options, ILoggerFactory loggerFactory)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (hostingEnv == null)
            {
                throw new ArgumentNullException(nameof(hostingEnv));
            }

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

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (options.ContentTypeProvider == null)
            {
                throw new ArgumentException(Resources.Args_NoContentTypeProvider);
            }
            options.ResolveFileProvider(hostingEnv);

            _next = next;
            _options = options;
            _matchUrl = options.RequestPath;
            _logger = loggerFactory.CreateLogger<StaticFileMiddleware>();
        }
Esempio n. 31
0
 public ExceptionHandlerMiddleware(RequestDelegate next,
                                   ILoggerFactory loggerFactory)
 {
     this.next   = next;
     this.logger = loggerFactory.CreateLogger <ExceptionHandlerMiddleware>();
 }
 public ErrorHandlingMiddleware(RequestDelegate next)
 {
     _next = next;
 }
Esempio n. 33
0
 public ExceptionMiddleware(RequestDelegate next)
 {
     _next = next;
 }
Esempio n. 34
0
 public CorridMiddleware(RequestDelegate next, ICorridContextUpdater contextUpdater)
 {
     _next           = next;
     _contextUpdater = contextUpdater;
 }
Esempio n. 35
0
 public CorridMiddleware(RequestDelegate next)
     : this(next, CorridContext.Default)
 {
 }
Esempio n. 36
0
 public HttpsRedirectMiddleware(RequestDelegate next)
 {
     _next = next;
 }
Esempio n. 37
0
 public ExceptionMiddleware(RequestDelegate next, ILoggerManager logger)
 {
     _next   = next;
     _logger = logger;
 }
Esempio n. 38
0
 public ExceptionHandlerMiddleware(RequestDelegate next, ILogger <ExceptionHandlerMiddleware> logger)
 {
     _next   = next;
     _logger = logger;
 }
 public FrameAllowMiddleware(RequestDelegate next)
 {
     this.next = next;
 }
Esempio n. 40
0
 public ExceptionMiddleware(RequestDelegate next, ILogger <ExceptionMiddleware> logger, IHostEnvironment env)
 {
     _next   = next;
     _logger = logger;
     _env    = env;
 }
Esempio n. 41
0
        /// <summary>
        /// Initializes a <see cref="TwitterMiddleware"/>
        /// </summary>
        /// <param name="next">The next middleware in the HTTP pipeline to invoke</param>
        /// <param name="dataProtectionProvider"></param>
        /// <param name="loggerFactory"></param>
        /// <param name="encoder"></param>
        /// <param name="sharedOptions"></param>
        /// <param name="options">Configuration options for the middleware</param>
        /// <param name="configureOptions"></param>
        public TwitterMiddleware(
            RequestDelegate next,
            IDataProtectionProvider dataProtectionProvider,
            ILoggerFactory loggerFactory,
            IUrlEncoder encoder,
            IOptions <SharedAuthenticationOptions> sharedOptions,
            TwitterOptions options)
            : base(next, options, loggerFactory, encoder)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (dataProtectionProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProtectionProvider));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (encoder == null)
            {
                throw new ArgumentNullException(nameof(encoder));
            }

            if (sharedOptions == null)
            {
                throw new ArgumentNullException(nameof(sharedOptions));
            }

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

            if (string.IsNullOrEmpty(Options.ConsumerSecret))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.ConsumerSecret)));
            }
            if (string.IsNullOrEmpty(Options.ConsumerKey))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.ConsumerKey)));
            }
            if (!Options.CallbackPath.HasValue)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.CallbackPath)));
            }

            if (Options.Events == null)
            {
                Options.Events = new TwitterEvents();
            }
            if (Options.StateDataFormat == null)
            {
                var dataProtector = dataProtectionProvider.CreateProtector(
                    typeof(TwitterMiddleware).FullName, Options.AuthenticationScheme, "v1");
                Options.StateDataFormat = new SecureDataFormat <RequestToken>(
                    new RequestTokenSerializer(),
                    dataProtector);
            }

            if (string.IsNullOrEmpty(Options.SignInScheme))
            {
                Options.SignInScheme = sharedOptions.Value.SignInScheme;
            }
            if (string.IsNullOrEmpty(Options.SignInScheme))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "SignInScheme"));
            }

            _httpClient         = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler());
            _httpClient.Timeout = Options.BackchannelTimeout;
            _httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB
            _httpClient.DefaultRequestHeaders.Accept.ParseAdd("*/*");
            _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Twitter middleware");
            _httpClient.DefaultRequestHeaders.ExpectContinue = false;
        }
Esempio n. 42
0
 public SillyAuthentication(RequestDelegate next)
 {
     _next = next;
 }
Esempio n. 43
0
 public AcceptHeaderMiddleware(RequestDelegate next)
 {
     this.next = next;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RequestLoggerMiddleware"/> class.
 /// </summary>
 /// <param name="next">The next middleware.</param>
 public RequestLoggerMiddleware(RequestDelegate next)
 {
     this._next = next ?? throw new ArgumentNullException(nameof(next));
 }
 public AddNoCacheHeadersMiddleware(RequestDelegate next) => _next = next;
 public ErrorHandlingMiddleware(RequestDelegate next, Serilog.ILogger logger)
 {
     Next = next;
     Logger = logger;
 }
 public ErrorHandlingMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
 {
     _next   = next;
     _logger = loggerFactory.CreateLogger(typeof(ErrorHandlingMiddleware));
 }
 public PlaintextMiddleware(RequestDelegate next)
 {
     _next = next;
 }
Esempio n. 49
0
 public TokenMiddleware(RequestDelegate next, ITokenManager tokenManager)
 {
     _next         = next;
     _tokenManager = tokenManager;
 }
 public CustomMiddleware(RequestDelegate next)
 {
     _next = next;
 }
 public SiteViewMiddleware(RequestDelegate _next)
 {
     this._next = _next;
 }
Esempio n. 52
0
 public EnforceHttpsMiddleware(RequestDelegate next)
 {
     _next = next;
 }
Esempio n. 53
0
 public Server(RequestDelegate next)
 {
     _next = next;
 }
 public SerilogMiddleware(RequestDelegate next)
 {
     _next = next ?? throw new ArgumentNullException(nameof(next));
 }
 public ContentMiddleware(RequestDelegate nextDelegate, UptimeService uptimeService)
 {
     _nextDelegate  = nextDelegate;
     _uptimeService = uptimeService;
 }
Esempio n. 56
0
 public HttpWebApiHelperMiddleware(RequestDelegate next)
 {
     _next = next;
 }
 public ErrorHandlingMiddleware(RequestDelegate next, ILogger<ErrorHandlingMiddleware> logger)
 {
     _logger = logger;
     _next = next;
 }
 public ImageCachingMiddleware(RequestDelegate next, IFilesCachingService cachingService)
 {
     _next           = next;
     _cachingService = cachingService;
 }
Esempio n. 59
0
 public AuthMiddleware(RequestDelegate next, ApiKey apiKey)
 {
     _next   = next;
     _apiKey = apiKey;
 }
Esempio n. 60
0
 //ctor
 public TokenMiddleware(RequestDelegate next)
 {
     Next = next;
 }