public UserInformationMiddleware( RequestDelegate next, IApplicationBuilder app, IOptions <TOptions> options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _next = next; _options = options.Value; _httpClient = new HttpClient(_options.BackChannelHttpHandler ?? new HttpClientHandler()); var nullAuthenticationBuilder = app.New(); var nullAuthenticationOptions = new NullAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true }; nullAuthenticationBuilder.UseMiddleware <NullAuthenticationMiddleware>(Options.Create(nullAuthenticationOptions)); nullAuthenticationBuilder.Run(ctx => next(ctx)); _nullAuthenticationNext = nullAuthenticationBuilder.Build(); }
public Oauth2IntrospectionMiddleware( RequestDelegate next, IApplicationBuilder app, IOptions <TOptions> options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _next = next; _options = options.Value; var handler = _options.BackChannelHttpHandler; if (handler == null) { handler = new HttpClientHandler(); #if NETSTANDARD handler.ServerCertificateCustomValidationCallback = delegate { return(true); }; #else ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; #endif } _httpClient = new HttpClient(handler); var nullAuthenticationBuilder = app.New(); var nullAuthenticationOptions = new NullAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true }; nullAuthenticationBuilder.UseMiddleware <NullAuthenticationMiddleware>(Options.Create(nullAuthenticationOptions)); nullAuthenticationBuilder.Run(ctx => next(ctx)); _nullAuthenticationNext = nullAuthenticationBuilder.Build(); }
public UmaIntrospectionMiddleware( RequestDelegate next, IApplicationBuilder app, IOptions <TOptions> options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _next = next; _app = app; _options = options.Value; // Register dependencies var serviceCollection = new ServiceCollection(); RegisterDependencies(serviceCollection, _options); _serviceProvider = serviceCollection.BuildServiceProvider(); // Create empty middleware var nullAuthenticationBuilder = app.New(); var nullAuthenticationOptions = new NullAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true }; nullAuthenticationBuilder.UseMiddleware <NullAuthenticationMiddleware>(Options.Create(nullAuthenticationOptions)); nullAuthenticationBuilder.Run(ctx => next(ctx)); _nullAuthenticationNext = nullAuthenticationBuilder.Build(); }