/// <summary> /// Initializes a new instance of the <see cref="IdentityServerBearerTokenValidationMiddleware" /> class. /// </summary> /// <param name="next">The next middleware.</param> /// <param name="options">The options.</param> /// <param name="loggerFactory">The logger factory.</param> public IdentityServerBearerTokenValidationMiddleware(AppFunc next, IdentityServerOAuthBearerAuthenticationOptions options, ILoggerFactory loggerFactory) { _next = next; _options = options; _logger = loggerFactory.Create(this.GetType().FullName); if (options.LocalValidationOptions != null) { var localBuilder = new AppBuilder(); options.OnValidationAppBuilderCreated?.Invoke(localBuilder); localBuilder.UseOAuthBearerAuthentication(options.LocalValidationOptions); localBuilder.Run(ctx => next(ctx.Environment)); _localValidationFunc = localBuilder.Build(); } if (options.EndpointValidationOptions != null) { var endpointBuilder = new AppBuilder(); options.OnValidationAppBuilderCreated?.Invoke(endpointBuilder); endpointBuilder.Properties["host.AppName"] = "foobar"; endpointBuilder.UseOAuthBearerAuthentication(options.EndpointValidationOptions); endpointBuilder.Run(ctx => next(ctx.Environment)); _endpointValidationFunc = endpointBuilder.Build(); } }
/// <summary> /// Initializes a new instance of the <see cref="IdentityServerBearerTokenValidationMiddleware"/> class. /// </summary> /// <param name="next">The next middleware.</param> /// <param name="options">The options.</param> public IdentityServerBearerTokenValidationMiddleware(AppFunc next, IdentityServerOAuthBearerAuthenticationOptions options) { _next = next; _options = options; if (options.LocalValidationOptions != null) { var localBuilder = new AppBuilder(); localBuilder.UseOAuthBearerAuthentication(options.LocalValidationOptions); localBuilder.Run(ctx => next(ctx.Environment)); _localValidationFunc = localBuilder.Build(); } if (options.EndpointValidationOptions != null) { var endpointBuilder = new AppBuilder(); endpointBuilder.Properties["host.AppName"] = "foobar"; endpointBuilder.UseOAuthBearerAuthentication(options.EndpointValidationOptions); endpointBuilder.Run(ctx => next(ctx.Environment)); _endpointValidationFunc = endpointBuilder.Build(); } }