internal async Task <(OpenIdConnectOptions options, OpenIdConnectConfiguration configuration)> GetOpenIdConnectSettingsAsync(string schemeName)
        {
            OpenIdConnectOptions options;

            if (string.IsNullOrWhiteSpace(schemeName))
            {
                var scheme = await _schemeProvider.GetDefaultChallengeSchemeAsync();

                if (scheme is null)
                {
                    throw new InvalidOperationException("No OpenID Connect authentication scheme configured for getting client configuration. Either set the scheme name explicitly or set the default challenge scheme");
                }

                options = _oidcOptions.Get(scheme.Name);
            }
            else
            {
                options = _oidcOptions.Get(schemeName);
            }

            OpenIdConnectConfiguration configuration;

            try
            {
                configuration = await options.ConfigurationManager.GetConfigurationAsync(default);
Ejemplo n.º 2
0
 public CosmosDBRepository(IOptionsSnapshot <CosmosDbOptions> config) :
     this(config.Get(typeof(T).FullName).Endpoint,
          config.Get(typeof(T).FullName).AuthKey,
          config.Get(typeof(T).FullName).Database,
          config.Get(typeof(T).FullName).Collection)
 {
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Sends the specified message.
        /// </summary>
        /// <typeparam name="TMessage">The type of the message.</typeparam>
        /// <param name="message">The message.</param>
        /// <param name="options">The options.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public async Task Send <TMessage>(TMessage message, ExtendableOptions options, CancellationToken cancellationToken = default) where TMessage : IMessage
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var context = new DefaultMessageContext(
                _provider,
                _options,
                options.Context,
                cancellationToken);

            var messageType   = message.GetType();
            var configuration = _options.Get(messageType.Name);

            await MessageOperations
            .Send(
                message,
                context,
                _provider,
                configuration)
            .ConfigureAwait(false);
        }
 public GoogleSheetsConnector(Helpers helpers, GoogleSheetConfiguration googleSheetConfiguration, IOptionsSnapshot <GoogleSheetConfiguration> options)
 {
     _helpers = helpers;
     _googleSheetConfiguration           = googleSheetConfiguration;
     _crunchTimePlayerIdMapConfiguration = options.Get(crunchtimePlayerIdMap);
     _sfbbPlayerIdMapConfiguration       = options.Get(sfbbPlayerIdMap);
 }
        public HomeController(
            ILogger <HomeController> logger,
            IConfiguration config,
            IOptionsMonitor <MyOptions> optionAccessor,
            IOptionsMonitor <MyOptionsWithDelegateConfig> optionsAccessorWithDelegateConfig,
            IOptionsMonitor <MySubOptions> subOptionsAccessor,
            IOptionsSnapshot <MyOptions> snapshotOptionsAccessor,
            IOptionsSnapshot <MyOptions> namedOptionsAccessor,
            IMyDependency myDependency,
            OperationService operationService,
            IOperationTransient transientOperation,
            IOperationScoped scopedOperation,
            IOperationSingleton singletonOperation,
            IOperationSingletonInstance instanceOperation)
        {
            _logger = logger;
            _config = config;

            _options = optionAccessor.CurrentValue;
            _optionsWithDelegateConfig = optionsAccessorWithDelegateConfig.CurrentValue;
            _subOptions      = subOptionsAccessor.CurrentValue;
            _snapshotOptions = snapshotOptionsAccessor.Value;
            _named_options_1 = namedOptionsAccessor.Get("named_options_1");
            _named_options_2 = namedOptionsAccessor.Get("named_options_2");

            _myDependency      = myDependency;
            OperationService   = operationService;
            TransientOperation = transientOperation;
            ScopedOperation    = scopedOperation;
            SingletonOperation = singletonOperation;
            InstanceOperation  = instanceOperation;
        }
Ejemplo n.º 6
0
 public TodoController(TodoContext todoContext,
                       ILogger <TodoController> logger,
                       IOperationTransien operationTransien,
                       IOperationScope operationScope,
                       IOperationSingleton operationSingleton,
                       IOptionsMonitor <PositionOptions> optionsMonitor,
                       IOptionsSnapshot <TopItemSettings> namedOptionsAccessor,
                       IOptions <MyConfigOptions> options,
                       IHttpClientFactory httpClientFactory,
                       IMemoryCache cache,
                       IDistributedCache distributedCache)
 {
     _todoContext        = todoContext;
     _logger             = logger;
     _operationTransien  = operationTransien;
     _operationScope     = operationScope;
     _operationSingleton = operationSingleton;
     _positionOptions    = optionsMonitor.CurrentValue;
     _monthTopItem       = namedOptionsAccessor.Get(TopItemSettings.Month);
     _yearTopItem        = namedOptionsAccessor.Get(TopItemSettings.Year);
     _myConfigOptions    = options.Value;
     _clientFactory      = httpClientFactory;
     _cache            = cache;
     _distributedCache = distributedCache;
 }
 public CosmosDBRepository(IOptionsSnapshot <CosmosDBOptions> config, ILogger <CosmosDBBaseRepository> logger) :
     base(config.Get(typeof(T).FullName).Endpoint,
          config.Get(typeof(T).FullName).AuthKey,
          config.Get(typeof(T).FullName).Database,
          config.Get(typeof(T).FullName).Collection,
          logger)
 {
 }
Ejemplo n.º 8
0
        public HomeController(IOptions <MyOptions> optionAccessor, IOptions <SubOptions> subOptionAccessor, IOptionsSnapshot <SubOptions> nameOptionsAccess)
        {
            options    = optionAccessor.Value;
            subOptions = subOptionAccessor.Value;

            subOption1 = nameOptionsAccess.Get("sub1");
            subOption2 = nameOptionsAccess.Get("sub2");
        }
        //public ConfigController(IConfiguration configuration, MyOption myOption)
        //{
        //    _configuration = configuration;
        //    _myOption = myOption;
        //}

        //public ConfigController(IConfiguration configuration, IOptions<MyOption> myOption)
        //{
        //    _configuration = configuration;
        //    _myOption = myOption.Value;
        //}

        public ConfigController(IConfiguration configuration, IOptionsSnapshot <MyOption> myOption)
        {
            _configuration = configuration;
            _myOption      = myOption.Value;

            _myOption = myOption.Get(MyOption.PETER);
            _myOption = myOption.Get(MyOption.JACK);
        }
Ejemplo n.º 10
0
        public HomeController(IOptionsSnapshot <BookAlertConfig> newBookAlertConfiguration, IMessageRepository messageRepositoryconfig)
        {
            _newBookAlertConfiguration = newBookAlertConfiguration.Get("InternalBook");
            _thirdPartyBooks           = newBookAlertConfiguration.Get("ThirdPartyBook");


            _mConfiguration = messageRepositoryconfig;
        }
Ejemplo n.º 11
0
 public HomeController(IOptions <MyOptions> optionAccessor, IOptions <SubOptions> subOptionAccessor, IOptionsSnapshot <SubOptions> optionsSnapshot)
 {
     options    = optionAccessor.Value;
     subOptions = subOptionAccessor.Value;
     //通过name读取对应的选项
     subOptions1 = optionsSnapshot.Get("sub1");
     subOptions2 = optionsSnapshot.Get("sub2");
 }
Ejemplo n.º 12
0
        public MsalClientFactory(IOptionsSnapshot <MsalOptions> config, ITokenCacheAccessor tokenCacheAccessor, ILoggerFactory loggerFactory)
        {
            _log = loggerFactory.CreateLogger <MsalClientFactory>();
            _log.LogDebug($"Entering MsalClientFactory without certificate");

            _config             = config.Get("Commercial");
            _chinaConfig        = config.Get("China");
            _tokenCacheAccessor = tokenCacheAccessor;
        }
Ejemplo n.º 13
0
        // private string spRankings = "SpRankings";


        public AirtableManager(Helpers helpers, IOptions <AirtableConfiguration> airtableConfig, IOptionsSnapshot <AirtableConfiguration> options)
        {
            _helpers                      = helpers;
            _airtableConfig               = airtableConfig.Value;
            _spRankingsConfiguration      = options.Get("SpRankings");
            _authorsConfiguration         = options.Get("Authors");
            _websitesConfiguration        = options.Get("Websites");
            _baseballScraperConfiguration = options.Get("BaseballScraperConfig");
        }
 public HomeController(IOptionsSnapshot <NewBookAlertConfig> newBookAlertconfiguration,
                       IMessageRepository messageRepository, IUserService userService,
                       IEmailService emailService)
 {
     _newBookAlertconfiguration   = newBookAlertconfiguration.Get("InternalBook");
     _thirdPartyBookconfiguration = newBookAlertconfiguration.Get("ThirdPartyBook");
     _messageRepository           = messageRepository;
     _userService  = userService;
     _emailService = emailService;
 }
Ejemplo n.º 15
0
        public MsalClientFactory(IOptionsSnapshot <MsalOptions> config, ITokenCacheAccessor tokenCacheAccessor, X509Certificate2 cert, ILoggerFactory loggerFactory)
        {
            _log = loggerFactory.CreateLogger <MsalClientFactory>();
            _log.LogDebug($"Entering MsalClientFactory with injected certificate {cert.Subject}, {cert.Thumbprint}");

            _config             = config.Get("Commercial");
            _chinaConfig        = config.Get("China");
            _config.Certificate = cert;
            _tokenCacheAccessor = tokenCacheAccessor;
        }
Ejemplo n.º 16
0
 public DefaultController(IOptions <MyOptions> optionsAccessor, IOptionsSnapshot <MyOptions> namedOptionsAccessor, ILogger <DefaultController> logger, IFileProvider fileProvider, IPersonRepostitoy personRepostitoy, SampleInterface sampleInterface)
 {
     this.optionsAccessor  = optionsAccessor;
     this.logger           = logger;
     this.fileProvider     = fileProvider;
     this.personRepostitoy = personRepostitoy;
     this.sampleInterface  = sampleInterface;
     _named_options_1      = namedOptionsAccessor.Get("named_options_1");
     _named_options_2      = namedOptionsAccessor.Get("named_options_2");
 }
Ejemplo n.º 17
0
            /// <summary>
            /// 使用具名的IOptionsMonitor和IOptionsSnapshot的Get方法读取指定名称的Options
            /// </summary>
            public void PrintOptionTwo()
            {
                Console.WriteLine($"_optionsSnapshot1.foo:{_optionsSnapshot1.Get("foo").AsFormatJsonStr()}");
                Console.WriteLine($"_optionsSnapshot1.bar:{_optionsSnapshot1.Get("bar").AsFormatJsonStr()}");

                Console.WriteLine($"_optionsMonitor1.foo:{_optionsMonitor1.Get("foo").AsFormatJsonStr()}");
                Console.WriteLine($"_optionsMonitor2.bar:{_optionsMonitor2.Get("bar").AsFormatJsonStr()}");

                PrintOptionCatch();
            }
Ejemplo n.º 18
0
        public async Task <T> ExecuteAsync <T>(IJDPayRequest <T> request, string optionsName) where T : JDPayResponse
        {
            var options = _optionsSnapshotAccessor.Get(optionsName);
            // 字典排序
            var sortedTxtParams = new JDPayDictionary(request.GetParameters());

            var content = BuildEncryptXml(request, sortedTxtParams, options);

            _logger.Log(options.LogLevel, "Request:{content}", content);

            using (var client = _clientFactory.CreateClient())
            {
                var body = await client.DoPostAsync(request.GetRequestUrl(), content);

                _logger.Log(options.LogLevel, "Response:{content}", body);

                var parser = new JDPayXmlParser <T>();
                var rsp    = parser.Parse(JDPayUtility.FotmatXmlString(body));
                if (!string.IsNullOrEmpty(rsp.Encrypt))
                {
                    var encrypt          = rsp.Encrypt;
                    var base64EncryptStr = Encoding.UTF8.GetString(Convert.FromBase64String(encrypt));
                    var reqBody          = JDPaySecurity.DecryptECB(base64EncryptStr, options.DesKeyBase64);
                    _logger.Log(options.LogLevel, "Encrypt Content:{body}", reqBody);

                    var reqBodyDoc = new XmlDocument();
                    reqBodyDoc.LoadXml(reqBody);

                    var sign     = JDPayUtility.GetValue(reqBodyDoc, "sign");
                    var rootNode = reqBodyDoc.SelectSingleNode("jdpay");
                    var signNode = rootNode.SelectSingleNode("sign");
                    rootNode.RemoveChild(signNode);

                    var reqBodyStr = JDPayUtility.ConvertXmlToString(reqBodyDoc);
                    var xmlh       = rsp.Body.Substring(0, rsp.Body.IndexOf("<jdpay>"));
                    if (!string.IsNullOrEmpty(xmlh))
                    {
                        reqBodyStr = reqBodyStr.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", xmlh);
                    }
                    var sha256SourceSignString = SHA256.Compute(reqBodyStr);
                    var decryptByte            = RSA_ECB_PKCS1Padding.Decrypt(Convert.FromBase64String(sign), options.PublicKey);
                    var decryptStr             = JDPaySecurity.BytesToString(decryptByte);
                    if (sha256SourceSignString == decryptStr)
                    {
                        rsp         = parser.Parse(reqBody);
                        rsp.Encrypt = encrypt;
                    }
                    else
                    {
                        throw new JDPayException("sign check fail: check Sign and Data Fail!");
                    }
                }
                return(rsp);
            }
        }
        private async Task <SpaceOptions> GetSpaceOptionsAsync()
        {
            if (string.IsNullOrEmpty(_options.Scheme))
            {
                var scheme = await _schemeProvider.GetDefaultChallengeSchemeAsync();

                return(_spaceOptions.Get(scheme.Name));
            }

            return(_spaceOptions.Get(_options.Scheme));
        }
Ejemplo n.º 20
0
 public HomeController(IOptionsSnapshot <NouveauLivreAlertConfig> nouveauLivreAlertConfig,
                       IMessageRepository messageRepository,
                       IUserService userService,
                       IEmailService emailService)
 {
     _nouveauLivreAlertConfig = nouveauLivreAlertConfig.Get("InternalBook");
     _thirdPartyBookConfig    = nouveauLivreAlertConfig.Get("ThirdPartyBook");
     _messageRepository       = messageRepository;
     _userService             = userService;
     _emailService            = emailService;
 }
Ejemplo n.º 21
0
        private async Task <OpenIdConnectOptions> GetOidcOptionsAsync()
        {
            if (!string.IsNullOrEmpty(_managementOptions.Scheme))
            {
                return(_oidcOptions.Get(_managementOptions.Scheme));
            }

            var scheme = await _schemeProvider.GetDefaultChallengeSchemeAsync();

            return(_oidcOptions.Get(scheme.Name));
        }
Ejemplo n.º 22
0
 public HomeController(ILogger <HomeController> logger,
                       IOptionsSnapshot <CredHubServiceOption> credHubServiceOption,
                       IOptions <CloudFoundryServicesOptions> servicesOptions,
                       IConfiguration config)
 {
     _logger = logger;
     _credHubServiceOption1 = credHubServiceOption.Get("showme-creds");
     _credHubServiceOption2 = credHubServiceOption.Get("showme-creds2");
     CloudFoundryServices   = servicesOptions.Value;
     _config = config;
 }
Ejemplo n.º 23
0
 public OptionsBindController(IConfiguration configuration,
                              IOptionsMonitor <PositionOptions> options,
                              IOptionsSnapshot <TopItemSettings> optionsSnapshot,
                              ILogger <OptionsBindController> logger
                              )
 {
     Configuration = configuration;
     _options      = options.CurrentValue;
     _monthTopItem = optionsSnapshot.Get(TopItemSettings.Month);
     _yearTopItem  = optionsSnapshot.Get(TopItemSettings.Year);
     _logger       = logger;
 }
Ejemplo n.º 24
0
        public HomeController(IOptionsMonitor <MyOptions> optionsAccessor, IOptionsMonitor <MyOptionsWithDelegateConfig> optionsAccessorWithDelegateConfig,
                              IOptionsSnapshot <MyOptions> snapshotOptionsAccessor, IOptionsSnapshot <MyOptions> namedOptionsAccessor,
                              ILogger <HomeController> logger)
        {
            _options = optionsAccessor.CurrentValue;
            _optionsWithDelegateConfig = optionsAccessorWithDelegateConfig.CurrentValue;
            _snapshotOptions           = snapshotOptionsAccessor.Value;
            _named_options_1           = namedOptionsAccessor.Get("named_options_1");
            _named_options_2           = namedOptionsAccessor.Get("named_options_2");

            _logger = logger;
        }
Ejemplo n.º 25
0
 //IOptionsSnapshot works on scoped
 //IOptions works on singleton
 public HomeController(IConfiguration iConfiguration, IOptionsSnapshot <NewBookAlertConfig> iOptions,
                       IMessageRepository messageRepository, IUserService userService,
                       IEmailService emailService)
 {
     _iConfiguration    = iConfiguration;
     _messageRepository = messageRepository;
     _userService       = userService;
     _emailService      = emailService;
     // newBookAlertConfig = iOptions.Value;
     newBookAlertConfig = iOptions.Get("InternalBook");
     thirdpartyBook     = iOptions.Get("ThirdPartyBook");
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Sends the specified message.
        /// </summary>
        /// <typeparam name="TMessage">The type of the message.</typeparam>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public async Task Send <TMessage>(TMessage message) where TMessage : IMessage
        {
            var messageType   = message.GetType();
            var configuration = _options.Get(messageType.Name);

            await MessageOperations
            .Send(
                message,
                this,
                _provider,
                configuration)
            .ConfigureAwait(false);
        }
Ejemplo n.º 27
0
        public OidcOptionsController(
            IOptions <SmtpOptions> smtpOptions,
            IOptionsSnapshot <OidcOptions> oidcOptions,
            IOptionsMonitor <JwtOptions> jwtOptions)
        {
            smtp = smtpOptions.Value;

            google   = oidcOptions.Get(OidcProviders.Google);
            facebook = oidcOptions.Get(OidcProviders.Facebook);
            okta     = oidcOptions.Get(OidcProviders.Okta);

            jwt = jwtOptions.CurrentValue;
        }
Ejemplo n.º 28
0
 public IndexModel(IOptionsMonitor <MyOptions> optionsAccessor,
                   IOptionsMonitor <MyOptionsWithDelegateConfig> optionsAccessorWithDelegateConfig,
                   IOptionsMonitor <MySubOptions> subOptionsAccessor,
                   IOptionsSnapshot <MyOptions> snapshotOptionsAccessor,
                   IOptionsSnapshot <MyOptions> namedOptionsAccessor)
 {
     _options = optionsAccessor.CurrentValue;
     _optionsWithDelegateConfig = optionsAccessorWithDelegateConfig.CurrentValue;
     _subOptions      = subOptionsAccessor.CurrentValue;
     _snapshotOptions = snapshotOptionsAccessor.Value;
     _named_options_1 = namedOptionsAccessor.Get("named_options_1");
     _named_options_2 = namedOptionsAccessor.Get("named_options_2");
 }
Ejemplo n.º 29
0
        public IEnumerable <WeatherForecast> Get()
        {
            var x = options.Get("v1");
            var y = options.Get("v2");

            y.Tag = "v100";
            return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = Random.Shared.Next(-20, 55),
                Summary = Summaries[Random.Shared.Next(Summaries.Length)]
            })
                   .ToArray());
        }
Ejemplo n.º 30
0
        public IActionResult Demo()
        {
            EmailOption defaultEmailOption = _options.Value;

            EmailOption defaultEmailOption1           = _optionsMonitor.CurrentValue;//_optionsMonitor.Get(Microsoft.Extensions.Options.Options.DefaultName);
            EmailOption fromMemoryEmailOption1        = _optionsMonitor.Get("FromMemory");
            EmailOption fromConfigurationEmailOption1 = _optionsMonitor.Get("FromConfiguration");

            EmailOption defaultEmailOption2           = _optionsSnapshot.Value;//_optionsSnapshot.Get(Microsoft.Extensions.Options.Options.DefaultName);
            EmailOption fromMemoryEmailOption2        = _optionsSnapshot.Get("FromMemory");
            EmailOption fromConfigurationEmailOption2 = _optionsSnapshot.Get("FromConfiguration");

            return(View());
        }