public virtual ExtendedAuthenticationBuilder Configure() { var configurationSection = this.Configuration.GetSection(this.ConfigurationKey); this.Services.Configure <ExtendedAuthenticationOptions>(configurationSection); var extendedAuthenticationOptions = new ExtendedAuthenticationOptions(); configurationSection.Bind(extendedAuthenticationOptions); foreach (var(key, value) in extendedAuthenticationOptions.SchemeRegistrations) { if (!value.Enabled) { continue; } var registrator = (Registrator)this.InstanceFactory.Create(value.Type); registrator.Add(this, key, value); } this.Services.TryAddTransient <ActiveDirectoryCallbackDecorator>(); this.Services.TryAddTransient <CallbackDecorator>(); this.Services.TryAddTransient <CertificateAuthenticationDecorator>(); this.Services.TryAddSingleton <IActiveDirectory, ActiveDirectory>(); this.Services.TryAddSingleton <IAuthenticationSchemeLoader, AuthenticationSchemeLoader>(); this.Services.TryAddSingleton <IDecorationLoader, DecorationLoader>(); this.Services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); this.Services.TryAddTransient <WindowsAuthenticationDecorator>(); return(this); }
public void CallbackDecorators_ShouldContainACallbackDecoratorByDefault() { var authenticationOptions = new ExtendedAuthenticationOptions(); Assert.AreEqual(1, authenticationOptions.CallbackDecorators.Count); Assert.AreEqual("*", authenticationOptions.CallbackDecorators.First().Value.AuthenticationSchemes.First().Key); Assert.AreEqual(10, authenticationOptions.CallbackDecorators.First().Value.AuthenticationSchemes.First().Value); Assert.IsTrue(authenticationOptions.CallbackDecorators.First().Value.Enabled); Assert.AreEqual(typeof(CallbackDecorator).AssemblyQualifiedName, authenticationOptions.CallbackDecorators.First().Value.Type); }
protected internal virtual WindowsAuthenticationDecorator CreateWindowsAuthenticationDecorator(ExtendedAuthenticationOptions authenticationOptions, ILoggerFactory loggerFactory) { var options = Options.Create(authenticationOptions); return new WindowsAuthenticationDecorator(new ActiveDirectory(options), options, loggerFactory); }
protected internal virtual void OnOptionsChanged(ExtendedAuthenticationOptions options, string name) { this.AuthenticationDecoratorDictionary = null; this.AuthenticationPropertiesDecoratorDictionary = null; this.CallbackDecoratorDictionary = null; }
protected internal virtual WindowsAuthenticationDecorator CreateWindowsAuthenticationDecorator(ExtendedAuthenticationOptions authenticationOptions, ILoggerFactory loggerFactory) { return(new WindowsAuthenticationDecorator(Mock.Of <IActiveDirectory>(), Options.Create(authenticationOptions), loggerFactory)); }