Пример #1
0
 public CensusApi(IApiKeyProvider keyService)
 {
     _apiKey = keyService.CensusApiKey;
     DataSet = CensusDataSet.SF1;
     client = new HttpClient();
     client.BaseAddress = new Uri("http://api.census.gov/data/2010/");
 }
Пример #2
0
        public BingMapsApi(IApiKeyProvider keyService)
	    {
            _bingMapsKey = keyService.BingMapsKey;

            client = new HttpClient();
            client.BaseAddress = new Uri("http://dev.virtualearth.net/REST/v1/Locations/");
	    }
Пример #3
0
 public PresentController(IApiKeyProvider apiKeyProvider, IShowsClient shows, ILogger <PresentController> logger, IQuestionsClient questions)
 {
     _apiKeyProvider = apiKeyProvider;
     _shows          = shows;
     _logger         = logger;
     _questions      = questions;
 }
Пример #4
0
        public static async Task <string> AddKeyToQueryStringAsync(
            this IApiKeyProvider apiKeyProvider,
            string url,
            CancellationToken cancellationToken)
        {
            // Validate parameters.
            if (apiKeyProvider == null)
            {
                throw new ArgumentNullException(nameof(apiKeyProvider));
            }
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException(nameof(url));
            }

            // The key.
            const string name = "key";

            // Get the value.
            string value = await apiKeyProvider
                           .GetApiKeyAsync(cancellationToken)
                           .ConfigureAwait(false);

            // Append and return.
            return(QueryHelpers.AddQueryString(url, name, value));
        }
Пример #5
0
 public MarketCandleCollector(
     IApiKeyProvider apiKeyProvider,
     MarkerAssetCandleCollector assetCollector, MarketCurrencyCandleCollector currencyCollector)
 {
     _apiKeyProvider    = apiKeyProvider;
     _assetCollector    = assetCollector;
     _currencyCollector = currencyCollector;
 }
        public BearerTokenValidator(IApiKeyProvider keyProvider)
        {
            if (keyProvider == null)
            {
                throw new ArgumentNullException(nameof(keyProvider));
            }

            _keyProvider = keyProvider;
        }
Пример #7
0
        public MyTokenController(IApiKeyProvider keyProvider)
        {
            if (keyProvider == null)
            {
                throw new ArgumentNullException(nameof(keyProvider));
            }

            _keyProvider = keyProvider;
        }
Пример #8
0
 public MarketMetadataCollector(
     ILogger <MarketMetadataCollector> logger, IApiKeyProvider apiKeyProvider, IsinProvider isinProvider,
     MetadataManager metadataManager)
 {
     _logger          = logger;
     _isinProvider    = isinProvider;
     _apiKeyProvider  = apiKeyProvider;
     _metadataManager = metadataManager;
 }
Пример #9
0
 public IndexModel(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender, IApiKeyProvider apiKeyProvider)
 {
     _userManager    = userManager;
     _signInManager  = signInManager;
     _emailSender    = emailSender;
     _apiKeyProvider = apiKeyProvider;
 }
        public GoogleApiMessageHandler(
            IApiKeyProvider apiKeyProvider
            )
        {
            // Validate parameters.
            _apiKeyProvider = apiKeyProvider ?? throw new ArgumentNullException(nameof(apiKeyProvider));

            // Set compression.
            this.SetCompression();
        }
Пример #11
0
        protected ApiKeyRequirement(long maxValue, TimeSpan renewalPeriod, bool sliding, IApiKeyProvider apiKeyProvider)
            : base(maxValue, renewalPeriod, sliding)
        {
            if (apiKeyProvider == null)
            {
                throw new ArgumentNullException(nameof(apiKeyProvider));
            }

            _apiKeyProvider = apiKeyProvider;
        }
Пример #12
0
        // ReSharper disable once UnusedParameter.Local
        public SlidesMiddleware(RequestDelegate _, IOptions <StorageOptions> options, ILogger <SlidesMiddleware> logger, IApiKeyProvider apiKeyProvider)
        {
            _logger         = logger;
            _apiKeyProvider = apiKeyProvider;
            var storageAccount = CloudStorageAccount.Parse(options.Value.ConnectionString);

            _client    = storageAccount.CreateCloudBlobClient();
            _putPolicy = ResiliencePolicy.Create(logger);
            _getPolicy = ResiliencePolicy.Create(logger);
            _logger.LogWarning(nameof(SlidesMiddleware));
        }
Пример #13
0
 public TeamsMapController(IGlobalSettings globalSettings,
                           IUmbracoContextAccessor umbracoContextAccessor,
                           ServiceContext serviceContext,
                           AppCaches appCaches,
                           IProfilingLogger profilingLogger,
                           UmbracoHelper umbracoHelper,
                           IApiKeyProvider apiKeyProvider)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _apiKeyProvider = apiKeyProvider;
 }
Пример #14
0
        public Market(string name, IMarketModel model, IEnumerable <ApiKeyRole> apiKeyRoles,
                      string usdCurrencyTag, TimeframeType[] possibleTimeframes)
        {
            Name               = name;
            Model              = model;
            UsdCurrencyTag     = usdCurrencyTag;
            SpecifiedRoles     = apiKeyRoles.ToArray();
            PossibleTimeframes = possibleTimeframes;

            _apiKeyProvider = new ApiKeyProvider(SpecifiedRoles);
            UsdEquivalent   = new UsdEquivalent(this);
        }
 public SeasonMapController(IGlobalSettings globalSettings,
                            IUmbracoContextAccessor umbracoContextAccessor,
                            ServiceContext serviceContext,
                            AppCaches appCaches,
                            IProfilingLogger profilingLogger,
                            UmbracoHelper umbracoHelper,
                            ISeasonDataSource seasonDataSource,
                            IApiKeyProvider apiKeyProvider)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _seasonDataSource = seasonDataSource ?? throw new ArgumentNullException(nameof(seasonDataSource));
     _apiKeyProvider   = apiKeyProvider ?? throw new ArgumentNullException(nameof(apiKeyProvider));
 }
Пример #16
0
        //use factory to prevent ambiguous reference to IAuthenticationHeaderProvider as each client
        //requires a different value for api key name, if multiple of these are reg'd could cause problems
        private static ReverseDnsClient ApiKeyReverseDnsClientFactory(IServiceProvider serviceProvider)
        {
            IReverseDnsClientConfig    reverseDnsClientConfig = serviceProvider.GetRequiredService <IReverseDnsClientConfig>();
            ILogger <ReverseDnsClient> logger = serviceProvider.GetRequiredService <ILogger <ReverseDnsClient> >();

            IReverseDnsApiKeyConfig reverseDnsApiKeyConfig = serviceProvider.GetRequiredService <IReverseDnsApiKeyConfig>();
            IApiKeyProvider         apiKeyProvider         = serviceProvider.GetRequiredService <IApiKeyProvider>();

            ApiKeyAuthenticationHeaderProvider reverseDnsApiKeyAuthenticationHeaderProvider =
                new ApiKeyAuthenticationHeaderProvider(reverseDnsApiKeyConfig.ReverseDnsClaimsName, apiKeyProvider);

            return(new ReverseDnsClient(reverseDnsClientConfig, reverseDnsApiKeyAuthenticationHeaderProvider, logger));
        }
Пример #17
0
 public CreateMatchLocationController(IGlobalSettings globalSettings,
                                      IUmbracoContextAccessor umbracoContextAccessor,
                                      ServiceContext serviceContext,
                                      AppCaches appCaches,
                                      IProfilingLogger profilingLogger,
                                      UmbracoHelper umbracoHelper,
                                      IApiKeyProvider apiKeyProvider,
                                      IAuthorizationPolicy <MatchLocation> authorizationPolicy)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _apiKeyProvider      = apiKeyProvider ?? throw new System.ArgumentNullException(nameof(apiKeyProvider));
     _authorizationPolicy = authorizationPolicy ?? throw new System.ArgumentNullException(nameof(authorizationPolicy));
 }
Пример #18
0
        public SignatureServiceOptionsBuilder UseDbContext <TContext, TEntity>(
            Func <TContext, DbSet <TEntity> > entitySelector,
            Func <TEntity, string> keySelector,
            Func <TEntity, string> valueSelector)
            where TContext : DbContext
            where TEntity : class
        {
            var context = provider.GetService <TContext>();
            //context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
            var dbSet = entitySelector.Invoke(context);

            this.apiKeyProvider = new IDKeyDbProvider <TEntity>(dbSet, keySelector, valueSelector);
            return(this);
        }
Пример #19
0
 public ManageController(
   UserManager<ApplicationUser> userManager,
   SignInManager<ApplicationUser> signInManager,
   IEmailSender emailSender,
   ISmsSender smsSender,
   ILoggerFactory loggerFactory, IApiKeyProvider apiKeyProvider)
 {
     _userManager = userManager;
     _signInManager = signInManager;
     _emailSender = emailSender;
     _smsSender = smsSender;
     _apiKeyProvider = apiKeyProvider;
     _logger = loggerFactory.CreateLogger<ManageController>();
 }
Пример #20
0
 public MatchLocationController(IGlobalSettings globalSettings,
                                IUmbracoContextAccessor umbracoContextAccessor,
                                ServiceContext serviceContext,
                                AppCaches appCaches,
                                IProfilingLogger profilingLogger,
                                UmbracoHelper umbracoHelper,
                                IMatchLocationDataSource matchLocationDataSource,
                                IAuthorizationPolicy <MatchLocation> authorizationPolicy,
                                IApiKeyProvider apiKeyProvider,
                                IEmailProtector emailProtector)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchLocationDataSource = matchLocationDataSource ?? throw new System.ArgumentNullException(nameof(matchLocationDataSource));
     _authorizationPolicy     = authorizationPolicy ?? throw new System.ArgumentNullException(nameof(authorizationPolicy));
     _apiKeyProvider          = apiKeyProvider ?? throw new System.ArgumentNullException(nameof(apiKeyProvider));
     _emailProtector          = emailProtector ?? throw new System.ArgumentNullException(nameof(emailProtector));
 }
Пример #21
0
        public static async Task <Uri> AddKeyToQueryStringAsync(
            this IApiKeyProvider apiKeyProvider,
            Uri url,
            CancellationToken cancellationToken)
        {
            // Validate parameters.
            if (apiKeyProvider == null)
            {
                throw new ArgumentNullException(nameof(apiKeyProvider));
            }
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            // Call the overload.
            return(new Uri(await apiKeyProvider.AddKeyToQueryStringAsync(url.ToString(), cancellationToken).ConfigureAwait(false)));
        }
        public async Task InvokeAsync(HttpContext context, IApiKeyProvider apiKeyProvider)
        {
            if (!context.Request.Headers.TryGetValue(ApiKeyHeaderName, out var extractedApiKey))
            {
                context.Response.StatusCode = 401;
                await context.Response.WriteAsync("Please provide ApiKey in Authorization header");

                return;
            }

            if (!extractedApiKey.Equals(apiKeyProvider.GetApiKey()))
            {
                context.Response.StatusCode = 401;
                await context.Response.WriteAsync("Wrong ApiKey");

                return;
            }

            await _next(context);
        }
Пример #23
0
        private string GetRequestApiKeyId(HttpContext context)
        {
            var principal = context.User as ClaimsPrincipal;

            if (principal == null)
            {
                return(null);
            }

            Claim           tokenClaim  = principal.Claims.Where(c => c.Type == Core.Security.ClaimTypes.AccessToken).FirstOrDefault();
            IApiKeyProvider keyProvider = (IApiKeyProvider)context.RequestServices.GetService(typeof(IApiKeyProvider));

            if (tokenClaim == null || keyProvider == null)
            {
                return(null);
            }

            var requestKey = keyProvider.FindKey(tokenClaim.Value);

            return(requestKey == null ? null : requestKey.Id);
        }
Пример #24
0
 public MockCensusApi(IApiKeyProvider keyService)
 {
     
 }
 protected ApiKeyHandlerBase(IOptionsMonitor <ApiKeyOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IApiKeyProvider apiKeyValidationService)
     : base(options, logger, encoder, clock)
 {
     _apiKeyValidationService = apiKeyValidationService;
 }
Пример #26
0
 public ApiKeyAuthHandler(IOptionsMonitor <ApiKeyAuthOptions> options, IApiKeyProvider apiKeyProvider, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock)
 {
     this.apiKeyProvider = apiKeyProvider;
     this.logger         = logger;
 }
Пример #27
0
 public MockBingMapsApi(IApiKeyProvider keyService)
 {
     
 }
 public ApiKeyInQueryParamsHandler(IOptionsMonitor <ApiKeyOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IApiKeyProvider apiKeyValidationService)
     : base(options, logger, encoder, clock, apiKeyValidationService)
 {
 }
Пример #29
0
 public ApiKeyResolver(IApiKeyProvider apiKeyProvider)
     : this()
 {
     ApiKeyProvider = apiKeyProvider;
 }
Пример #30
0
 public SignatureService(SignatureServiceOptions options)
 {
     this.IDKeyMap = options.ApiKeyProvider;
 }
Пример #31
0
 private void InitializeApis(IApiKeyProvider keyService)
 {
     map.Credentials = keyService.BingMapsKey;
     geolocator = new Geolocator();
     geolocator.StatusChanged += geolocator_StatusChanged;          
 }
Пример #32
0
 public ApiKeyResolver(IApiKeyProvider apiKeyProvider, IApplicationNameProvider nameProvider) : this()
 {
     ApiKeyProvider          = apiKeyProvider;
     ApplicationNameProvider = nameProvider;
 }
Пример #33
0
 public ApiKeysController(IApiKeyProvider keyProvider)
 {
     _keyProvider = keyProvider ?? throw new ArgumentNullException(nameof(keyProvider));
 }
 protected ApiKeyRateLimitRequirement(long maxValue, TimeSpan renewalPeriod, bool sliding, IApiKeyProvider apiKeyProvider)
     : base(maxValue, renewalPeriod, sliding, apiKeyProvider)
 {
 }
Пример #35
0
 public AlphaVantageStocksClientFactory(IApiKeyProvider apiKeyProvider)
 {
     _apiKeyProvider = apiKeyProvider;
 }