public IdentityServerAuthenticationController(IdentityServerExternalAuthSettings identityServerExternalAuthSettings,
                                               IExternalAuthenticationService externalAuthenticationService,
                                               ILocalizationService localizationService,
                                               IOptionsMonitorCache <FacebookOptions> optionsCache,
                                               IPermissionService permissionService,
                                               ISettingService settingService,
                                               IEventPublisher eventPublisher,
                                               StoreInformationSettings storeInformationSettings,
                                               IWorkContext workContext,
                                               ICustomerActivityService customerActivityService,
                                               IGenericAttributeService genericAttributeService,
                                               IAuthenticationService authenticationService,
                                               IHttpContextAccessor httpContextAccessor,
                                               INotificationService notificationService)
 {
     this._identityServerExternalAuthSettings = identityServerExternalAuthSettings;
     this._externalAuthenticationService      = externalAuthenticationService;
     this._localizationService = localizationService;
     this._optionsCache        = optionsCache;
     this._permissionService   = permissionService;
     this._settingService      = settingService;
     _eventPublisher           = eventPublisher;
     _storeInformationSettings = storeInformationSettings;
     _workContext             = workContext;
     _customerActivityService = customerActivityService;
     _genericAttributeService = genericAttributeService;
     _authenticationService   = authenticationService;
     _httpContextAccessor     = httpContextAccessor;
     _notificationService     = notificationService;
 }
예제 #2
0
        public async Task InvokeAsync(HttpContext context,
                                      IAuthenticationSchemeProvider schemeProvider,
                                      IOptionsMonitorCache <FakeAuthenticationSchemeOptions> optionsCache)
        {
            var fakeOptions = context.RequestServices
                              .GetRequiredService <IOptionsSnapshot <FakeAuthenticationOptions> >().Value;

            foreach (var fakeScheme in fakeOptions.Schemes)
            {
                if (await schemeProvider.GetSchemeAsync(fakeScheme.SchemeName) != null)
                {
                    schemeProvider.RemoveScheme(fakeScheme.SchemeName);
                    optionsCache.TryRemove(fakeScheme.SchemeName);
                    var scheme = new AuthenticationScheme(fakeScheme.SchemeName,
                                                          fakeScheme.SchemeName,
                                                          typeof(FakeAuthenticationHandler));
                    schemeProvider.AddScheme(scheme);
                    var fakeSchemeOptions = new FakeAuthenticationSchemeOptions();
                    foreach (var claim in fakeScheme.Claims)
                    {
                        fakeSchemeOptions.Claims.Add(claim);
                    }
                    optionsCache.TryAdd(fakeScheme.SchemeName, fakeSchemeOptions);
                }
            }
            await _next(context);
        }
 public OAuthDynamicAuthOptionsBuilder(IDataProtectionProvider dataProtectionProvider,
                                       IOptions <AuthenticationOptions> authOptions, IOptionsFactory <TOptions> optionsFactory,
                                       IOptionsMonitorCache <TOptions> optionsMonitorCache)
     : base(authOptions, optionsFactory, optionsMonitorCache)
 {
     _dataProtectionProvider = dataProtectionProvider;
 }
        public SiteCookieAuthenticationOptions(
            IOptionsFactory<CookieAuthenticationOptions> factory, 
            IEnumerable<IOptionsChangeTokenSource<CookieAuthenticationOptions>> sources, 
            IOptionsMonitorCache<CookieAuthenticationOptions> cache,
            IOptions<MultiTenantOptions> multiTenantOptionsAccessor,
            IPostConfigureOptions<CookieAuthenticationOptions> cookieOptionsInitializer,
            IHttpContextAccessor httpContextAccessor,
            ILogger<SiteCookieAuthenticationOptions> logger
            )
        {
            _multiTenantOptions = multiTenantOptionsAccessor.Value;
            _cookieOptionsInitializer = cookieOptionsInitializer;
            _httpContextAccessor = httpContextAccessor;
            _log = logger;

            _factory = factory;
            _sources = sources;
            _cache = cache;

            foreach (var source in _sources)
            {
                ChangeToken.OnChange<string>(
                    () => source.GetChangeToken(),
                    (name) => InvokeChanged(name),
                    source.Name);
            }
        }
예제 #5
0
 public AuthenticationController(
     IExternalAuthenticationService externalAuthenticationService,
     ILocalizationService localizationService,
     IPermissionService permissionService,
     ISettingService settingService,
     IStoreContext storeContext,
     IOptionsMonitorCache <FacebookOptions> optionsFacebookCache,
     IOptionsMonitorCache <TwitterOptions> optionsTwitterCache,
     IOptionsMonitorCache <GoogleOptions> optionsGoogleCache,
     IOptionsMonitorCache <MicrosoftAccountOptions> optionsMicrosoftCache,
     IAuthenticationPluginManager authenticationPluginManager,
     INotificationService notificationService,
     IHttpContextAccessor httpContextAccessor
     )
 {
     _externalAuthenticationService = externalAuthenticationService;
     _localizationService           = localizationService;
     _permissionService             = permissionService;
     _settingService              = settingService;
     _storeContext                = storeContext;
     _optionsFacebookCache        = optionsFacebookCache;
     _optionsTwitterCache         = optionsTwitterCache;
     _optionsGoogleCache          = optionsGoogleCache;
     _optionsMicrosoftCache       = optionsMicrosoftCache;
     _authenticationPluginManager = authenticationPluginManager;
     _notificationService         = notificationService;
     _httpContextAccessor         = httpContextAccessor;
 }
예제 #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="factory">The factory to use to create options.</param>
        /// <param name="sources">The sources used to listen for changes to the options instance.</param>
        /// <param name="cache">The cache used to store options.</param>
        public OptionsMonitor(IOptionsFactory<TOptions> factory, IEnumerable<IOptionsChangeTokenSource<TOptions>> sources, IOptionsMonitorCache<TOptions> cache)
        {
            _factory = factory;
            _cache = cache;

            void RegisterSource(IOptionsChangeTokenSource<TOptions> source)
            {
                IDisposable registration = ChangeToken.OnChange(
                          () => source.GetChangeToken(),
                          (name) => InvokeChanged(name),
                          source.Name);

                _registrations.Add(registration);
            }

            // The default DI container uses arrays under the covers. Take advantage of this knowledge
            // by checking for an array and enumerate over that, so we don't need to allocate an enumerator.
            if (sources is IOptionsChangeTokenSource<TOptions>[] sourcesArray)
            {
                foreach (IOptionsChangeTokenSource<TOptions> source in sourcesArray)
                {
                    RegisterSource(source);
                }
            }
            else
            {
                foreach (IOptionsChangeTokenSource<TOptions> source in sources)
                {
                    RegisterSource(source);
                }
            }
        }
예제 #7
0
 public HttpClientFactoryOptionsConfigure(IOptionsMonitor <HttpClientOptions> optionsSnapshot,
                                          IOptionsMonitorCache <HttpClientFactoryOptions> cache, IServiceProvider serviceProvider)
 {
     _optionsSnapshot = optionsSnapshot;
     _serviceProvider = serviceProvider;
     optionsSnapshot.OnChange((options, name) => { cache.TryRemove(name); });
 }
예제 #8
0
        public SiteGoogleOptions(
            IOptionsFactory <GoogleOptions> factory,
            IEnumerable <IOptionsChangeTokenSource <GoogleOptions> > sources,
            IOptionsMonitorCache <GoogleOptions> cache,
            IOptions <MultiTenantOptions> multiTenantOptionsAccessor,
            IPostConfigureOptions <GoogleOptions> optionsInitializer,
            IDataProtectionProvider dataProtection,
            IHttpContextAccessor httpContextAccessor,
            ILogger <SiteGoogleOptions> logger
            )
        {
            _multiTenantOptions  = multiTenantOptionsAccessor.Value;
            _httpContextAccessor = httpContextAccessor;
            _log = logger;
            _optionsInitializer = optionsInitializer;
            _dp = dataProtection;

            _factory = factory;
            _sources = sources;
            _cache   = cache;

            foreach (var source in _sources)
            {
                ChangeToken.OnChange <string>(
                    () => source.GetChangeToken(),
                    (name) => InvokeChanged(name),
                    source.Name);
            }
        }
예제 #9
0
 public SamlSchemeGenerator(
     IAuthenticationSchemeProvider schemeProvider,
     IOptionsMonitorCache <SamlAuthenticationOptions> optionsCache
     )
 {
     this.schemeProvider = schemeProvider;
     this.optionsCache   = optionsCache;
 }
 public MultitenantOptionsMonitor(IOptionsFactory <TOptions> factory, IEnumerable <IOptionsChangeTokenSource <TOptions> > sources, IOptionsMonitorCache <TOptions> cache, IHttpContextAccessor httpContextAccessor)
 {
     _factory             = factory;
     _sources             = sources;
     _optionsCache        = cache;
     _httpContextAccessor = httpContextAccessor;
     _cache.TryAdd("root", new Lazy <IOptionsMonitor <TOptions> >(() => new OptionsMonitor <TOptions>(_factory, _sources, new OptionsCache <TOptions>())));
 }
 public HttpClientTracingConfigure(IOptionsMonitor <HttpTracingOptions> optionsSnapshot,
                                   IOptionsMonitor <HttpClientOptions> clientOptions,
                                   IOptionsMonitorCache <HttpClientFactoryOptions> cache)
 {
     _optionsSnapshot = optionsSnapshot;
     _clientOptions   = clientOptions;
     // optionsSnapshot.OnChange((options, name) => { cache.TryRemove(name); });
 }
예제 #12
0
 public QQConnectAuthenticationController(ISettingService settingService, ExternalAuthenticationSettings externalAuthenticationSettings, IPermissionService permissionService, IStoreContext storeContext, IStoreService storeService, ILocalizationService localizationService, IExternalAuthenticationService externalAuthenticationService, QQConnectExternalAuthSettings facebookExternalAuthSettings, IOptionsMonitorCache <QQConnectOptions> optionsCache)
 {
     _settingService                = settingService;
     _permissionService             = permissionService;
     _localizationService           = localizationService;
     _externalAuthenticationService = externalAuthenticationService;
     _facebookExternalAuthSettings  = facebookExternalAuthSettings;
     _optionsCache = optionsCache;
 }
 public ExceptionHandlerConfigureOptions(
     IEnumerable <IExceptionHandler> handlers,
     IOptionsMonitorCache <IExceptionHandler> cache,
     IHostingEnvironment env)
 {
     _handlers = handlers;
     _cache    = cache;
     _env      = env;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="authOptions"></param>
 /// <param name="optionsFactory"></param>
 /// <param name="optionsMonitorCache"></param>
 public DynamicAuthOptionsBuilder(
     IOptions <AuthenticationOptions> authOptions,
     IOptionsFactory <TOptions> optionsFactory,
     IOptionsMonitorCache <TOptions> optionsMonitorCache)
 {
     _optionsFactory      = optionsFactory;
     _optionsMonitorCache = optionsMonitorCache;
     AuthOptions          = authOptions.Value;
 }
예제 #15
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="optionsCache">Options</param>
 /// <param name="optionsFactory">Factory for options</param>
 /// <param name="requestStateStore">Storage for request state</param>
 public Saml2Handler(
     IOptionsMonitorCache <Saml2Options> optionsCache,
     IOptionsFactory <Saml2Options> optionsFactory,
     IRequestStateStore requestStateStore)
 {
     this.optionsFactory    = optionsFactory;
     this.requestStateStore = requestStateStore;
     this.optionsCache      = optionsCache;
 }
예제 #16
0
 public ApplicationFeatureFactory(
     IEnumerable <ApplicationPart> parts,
     IEnumerable <IApplicationFeatureProvider> providers,
     IOptionsMonitorCache <Feature> features)
 {
     _parts     = parts;
     _providers = providers;
     _features  = features;
 }
 public TenantBasedMicrosoftAccountOptions(
     IOptionsFactory <MicrosoftAccountOptions> factory,
     IEnumerable <IOptionsChangeTokenSource <MicrosoftAccountOptions> > sources,
     IOptionsMonitorCache <MicrosoftAccountOptions> cache,
     ISettingManager settingManager
     ) : base(factory, sources, cache)
 {
     AbpSession      = NullAbpSession.Instance;
     _settingManager = settingManager;
 }
예제 #18
0
        public ScriptApplicationHostOptionsSetup(IConfiguration configuration, IOptionsMonitor <StandbyOptions> standbyOptions,
                                                 IOptionsMonitorCache <ScriptApplicationHostOptions> cache)
        {
            _cache          = cache ?? throw new ArgumentNullException(nameof(cache));
            _configuration  = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _standbyOptions = standbyOptions ?? throw new ArgumentNullException(nameof(standbyOptions));

            // If standby options change, invalidate this options cache.
            _standbyOptionsOnChangeSubscription = _standbyOptions.OnChange(o => _cache.Clear());
        }
예제 #19
0
 public AuthController(
     IAuthenticationSchemeProvider schemeProvider,
     IOptionsMonitorCache <SimpleOptions> optionsCache,
     IOptionsMonitorCache <OpenIdConnectOptions> openIdConnectOptionsCache,
     OpenIdConnectPostConfigureOptions openIdConnectPostConfigureOptions)
 {
     _schemeProvider                    = schemeProvider;
     _optionsCache                      = optionsCache;
     _openIdConnectOptionsCache         = openIdConnectOptionsCache;
     _openIdConnectPostConfigureOptions = openIdConnectPostConfigureOptions;
 }
 public BundlingOptionsConfigurer(
     IApplicationContext appContext,
     IAssetFileProvider fileProvider,
     IOptionsMonitorCache <BundlingOptions> optionsCache,
     Work <ThemeSettings> themeSettings)
 {
     _appContext    = appContext;
     _fileProvider  = fileProvider;
     _optionsCache  = optionsCache;
     _themeSettings = themeSettings;
 }
 public TenantBasedWsFederationOptions(
     IOptionsFactory <WsFederationOptions> factory,
     IEnumerable <IOptionsChangeTokenSource <WsFederationOptions> > sources,
     IOptionsMonitorCache <WsFederationOptions> cache,
     ISettingManager settingManager,
     IAppConfigurationAccessor configurationAccessor
     ) : base(factory, sources, cache)
 {
     AbpSession      = NullAbpSession.Instance;
     _settingManager = settingManager;
 }
        protected TenantBasedSocialLoginOptionsBase(
            IOptionsFactory <TOptions> factory,
            IEnumerable <IOptionsChangeTokenSource <TOptions> > sources,
            IOptionsMonitorCache <TOptions> cache
            ) : base(factory, sources, cache)
        {
            AbpSession = NullAbpSession.Instance;

            _factory = factory;
            _cache   = cache;
        }
예제 #23
0
        public SettingsProvider(
            ISettingsCreator settingsCreator,
            IOptionsMonitor <GatewayOptions> options,
            IOptionsMonitorCache <HttpClientFactoryOptions> httpFactoryOptionsMonitorCache)
        {
            this.settingsCreator = CheckValue(settingsCreator, nameof(settingsCreator));
            this.options         = CheckValue(options, nameof(options));
            this.httpFactoryOptionsMonitorCache = CheckValue(httpFactoryOptionsMonitorCache, nameof(httpFactoryOptionsMonitorCache));

            options.OnChange(_ => CurrentValue = CreateSettings());
            CurrentValue = CreateSettings();
        }
 public SiteCookieAuthenticationOptions(
     IOptionsFactory <CookieAuthenticationOptions> factory,
     IEnumerable <IOptionsChangeTokenSource <CookieAuthenticationOptions> > sources,
     IOptionsMonitorCache <CookieAuthenticationOptions> cache,
     IPostConfigureOptions <CookieAuthenticationOptions> cookieOptionsInitializer,
     IHttpContextAccessor httpContextAccessor,
     ILogger <SiteCookieAuthenticationOptions> logger
     )
 {
     _cookieOptionsInitializer = cookieOptionsInitializer;
     _httpContextAccessor      = httpContextAccessor;
     _log = logger;
 }
 public FacebookAuthenticationController(FacebookExternalAuthSettings facebookExternalAuthSettings,
                                         IExternalAuthenticationService externalAuthenticationService,
                                         ILocalizationService localizationService,
                                         IOptionsMonitorCache <FacebookOptions> optionsCache,
                                         IPermissionService permissionService,
                                         ISettingService settingService)
 {
     this._facebookExternalAuthSettings  = facebookExternalAuthSettings;
     this._externalAuthenticationService = externalAuthenticationService;
     this._localizationService           = localizationService;
     this._optionsCache      = optionsCache;
     this._permissionService = permissionService;
     this._settingService    = settingService;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="factory">The factory to use to create options.</param>
        /// <param name="sources">The sources used to listen for changes to the options instance.</param>
        /// <param name="cache">The cache used to store options.</param>
        public OptionsMonitor(IOptionsFactory <TOptions> factory, IEnumerable <IOptionsChangeTokenSource <TOptions> > sources, IOptionsMonitorCache <TOptions> cache)
        {
            _factory = factory;
            _sources = sources;//bookmark 通过IOptionsChangeTokenSource实现事件的监听
            _cache   = cache;

            foreach (var source in _sources)
            {//bookmark changeTokenproducer 获取文件变更的触发,  changeTokenconsumer 传入具体的函数式来消费这个触发
                ChangeToken.OnChange <string>(
                    () => source.GetChangeToken(),
                    (name) => InvokeChanged(name),
                    source.Name);
            }
        }
예제 #27
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="factory">The factory to use to create options.</param>
        /// <param name="sources">The sources used to listen for changes to the options instance.</param>
        /// <param name="cache">The cache used to store options.</param>
        public OptionsMonitor(IOptionsFactory <TOptions> factory, IEnumerable <IOptionsChangeTokenSource <TOptions> > sources, IOptionsMonitorCache <TOptions> cache)
        {
            _factory = factory;
            _sources = sources;
            _cache   = cache;

            foreach (var source in _sources)
            {
                ChangeToken.OnChange <string>(
                    () => source.GetChangeToken(),
                    (name) => InvokeChanged(name),
                    source.Name);
            }
        }
 public OAuth2AuthenticationController(IExternalAuthenticationService externalAuthenticationService,
                                       ILocalizationService localizationService,
                                       IOptionsMonitorCache <OAuthOptions> optionsCache,
                                       ISettingService settingService,
                                       OAuth2AuthenticationSettings oAuth2AuthenticationSettings,
                                       IAuthenticationPluginManager authenticationPluginManager)
 {
     _externalAuthenticationService = externalAuthenticationService;
     _localizationService           = localizationService;
     _optionsCache   = optionsCache;
     _settingService = settingService;
     _oAuth2AuthenticationSettings = oAuth2AuthenticationSettings;
     _authenticationPluginManager  = authenticationPluginManager;
 }
예제 #29
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="optionsCache">Options</param>
        /// <param name="dataProtectorProvider">Data Protector Provider</param>
        /// <param name="optionsFactory">Factory for options</param>
        public Saml2Handler(
            IOptionsMonitorCache <Saml2Options> optionsCache,
            IDataProtectionProvider dataProtectorProvider,
            IOptionsFactory <Saml2Options> optionsFactory)
        {
            if (dataProtectorProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProtectorProvider));
            }

            dataProtector = dataProtectorProvider.CreateProtector(GetType().FullName);

            this.optionsFactory = optionsFactory;
            this.optionsCache   = optionsCache;
        }
예제 #30
0
 public SiteGoogleOptions(
     IOptionsFactory <GoogleOptions> factory,
     IEnumerable <IOptionsChangeTokenSource <GoogleOptions> > sources,
     IOptionsMonitorCache <GoogleOptions> cache,
     IOptions <MultiTenantOptions> multiTenantOptionsAccessor,
     IHttpContextAccessor httpContextAccessor,
     ILogger <SiteGoogleOptions> logger
     ) : base(factory, sources, cache)
 {
     _multiTenantOptions  = multiTenantOptionsAccessor.Value;
     _httpContextAccessor = httpContextAccessor;
     _factory             = factory;
     _cache = cache;
     _log   = logger;
 }