示例#1
0
        public void ConfigureProxy(IServiceCollection services)
        {
            services.AddScoped <IProxyApplicationService, ProxyApplicationService>();
            services.AddSingleton <KerberosIdentityService>();
            services.AddSingleton <IAuthenticatorProvider, AuthenticatorProvider>();
            services.AddSingleton <IClaimsProviderProvider, ClaimsProviderProvider>();
            services.AddMemoryCache();

            foreach (var application in _proxyOptions.Applications)
            {
                services.AddHttpClient(application.Name).ConfigureHttpMessageHandlerBuilder(builder =>
                {
                    var proxyBuilder = new ProxyMessageHandlerBuilder(builder);

                    var authenticatorProvider = builder.Services.GetService <IAuthenticatorProvider>();
                    foreach (var authenticator in authenticatorProvider[application.Name])
                    {
                        authenticator.Configure(proxyBuilder);
                    }

                    proxyBuilder.PostConfigure();
                })
                .ConfigureHttpClient(client => {
                    client.BaseAddress = application.Destination;
                });
            }

            services.AddHostFiltering(options =>
            {
                options.AllowedHosts = _proxyOptions.Applications.Select(x => x.Host.Value.Value).ToArray();
            });
        }
示例#2
0
 public void Configure(ProxyMessageHandlerBuilder builder)
 {
     builder.AuthenticatorHandlers.Add(new HeadersHandler()
     {
         Authenticator = this
     });
 }
示例#3
0
        public void Configure(ProxyMessageHandlerBuilder builder)
        {
            EnableUseDefaultKerberosCredentials(builder.PrimaryAuthenticatedHandler);

            if (_bindingOptions.SendAnonymousRequestAsService)
            {
                EnableUseDefaultKerberosCredentials(builder.PrimaryAnonymousHandler);
            }

            builder.AuthenticatorHandlers.Add(new KerberosHandler()
            {
                Options         = _options,
                IdentityService = builder.Services.GetService <KerberosIdentityService>()
            });
        }