コード例 #1
0
 public DataKeyProviderCacheDecorator(
     IDataKeyProvider dataKeyProvider,
     ICacheService cacheService) : base(cacheService)
 {
     _dataKeyProvider = dataKeyProvider;
     _cacheService    = cacheService;
 }
コード例 #2
0
 public DataProtector(
     IEncryptionFactory encryptionFactory,
     IDataKeyProvider dataKeyProvider)
 {
     _encryptionFactory = encryptionFactory;
     _dataKeyProvider   = dataKeyProvider;
 }
 public FundPerformanceRepository(
     IDataKeyProvider dataKeyProvider,
     IAmazonDynamoDB amazonDynamoDB,
     IScopedCancellationToken scopedCancellationToken)
     : base(amazonDynamoDB, scopedCancellationToken, TableName)
 {
     this.dataKeyProvider = dataKeyProvider;
 }
コード例 #4
0
        private static void AddJwtAuthentication(IServiceCollection services, IConfiguration configuration)
        {
            JwtIssuerOptions      jwtIssuerOptions        = new JwtIssuerOptions();
            IConfigurationSection jwtIssuerOptionsSection = configuration.GetSection(nameof(JwtIssuerOptions));

            jwtIssuerOptionsSection.Bind(jwtIssuerOptions);

            ServiceProvider serviceProvider = services.BuildServiceProvider();

            using (IServiceScope scope = serviceProvider.CreateScope())
            {
                scope.ServiceProvider.GetRequiredService <IDataProtector>().SetDataProtector();
                IDataKeyProvider dataKeyProvider = scope.ServiceProvider.GetRequiredService <IDataKeyProvider>();

                DataKey dataKey = dataKeyProvider.GetAsync(SharedDataKeys.Authentication).Result;

                services.Configure <JwtIssuerOptions>(options =>
                {
                    options.Issuer             = jwtIssuerOptions.Issuer;
                    options.Audience           = jwtIssuerOptions.Audience;
                    options.SigningKey         = dataKey.Value;
                    options.SigningCredentials = new SigningCredentials(dataKey.Value, SecurityAlgorithms.HmacSha256);
                });

                TokenValidationParameters tokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer = true,
                    ValidIssuers   = new List <string>
                    {
                        jwtIssuerOptions.Issuer
                    },
                    ValidateAudience = true,
                    ValidAudiences   = new List <string>
                    {
                        jwtIssuerOptions.Audience
                    },
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKeys        = new List <SecurityKey>
                    {
                        dataKey.Value
                    },
                    RequireExpirationTime = true,
                    ValidateLifetime      = true,
                    ClockSkew             = TimeSpan.Zero
                };

                services.AddAuthentication(options =>
                {
                    options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                    options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
                }).AddJwtBearer(configureOptions =>
                {
                    configureOptions.TokenValidationParameters = tokenValidationParameters;
                    configureOptions.SaveToken = true;
                });
            }
        }
		internal EnvelopeCryptoProvider(IDataKeyProvider dataKeyProvider, IEnvelopeCryptoConfig config, IAlgorithmFactory algorithmFactory)
		{
			if (dataKeyProvider == null)
			{
				throw new ArgumentNullException("dataKeyProvider");
			}
			_dataKeyProvider = dataKeyProvider;
			_config = config;
			_algorithmFactory = algorithmFactory;
		}
コード例 #6
0
 public TransactionRepository(
     IDataKeyProvider dataKeyProvider,
     IAmazonDynamoDB amazonDynamoDB,
     IHttpContextAccessor httpContextAccessor,
     IScopedCancellationToken scopedCancellationToken)
     : base(amazonDynamoDB, scopedCancellationToken, TableName)
 {
     this.dataKeyProvider     = dataKeyProvider;
     this.httpContextAccessor = httpContextAccessor;
 }
コード例 #7
0
 internal EnvelopeCryptoProvider(IDataKeyProvider dataKeyProvider, IEnvelopeCryptoConfig config, IAlgorithmFactory algorithmFactory)
 {
     if (dataKeyProvider == null)
     {
         throw new ArgumentNullException("dataKeyProvider");
     }
     _dataKeyProvider  = dataKeyProvider;
     _config           = config;
     _algorithmFactory = algorithmFactory;
 }
		public EnvelopeCryptoProvider(IEnvelopeCryptoConfig config, IDataKeyProvider dataKeyProvider)
			: this(dataKeyProvider, config, new DefaultAlgorithmFactory()) {}
		/// <summary>
		///     Creates a caching wrapper around the provided <paramref name="actualDataKeyProvider" />.
		/// </summary>
		/// <param name="actualDataKeyProvider">The key provider that can actually encrypt and decrypt</param>
		/// <param name="capacity">The number of keys to cache in RAM</param>
		public CachingDataKeyProvider(IDataKeyProvider actualDataKeyProvider, int capacity)
		{
			_lruCache = new LruCache<string, byte[]>(capacity);
			_actualDataKeyProvider = actualDataKeyProvider;
		}
コード例 #10
0
 public DataHasher(IHashFactory hashFactory, IDataKeyProvider dataKeyProvider)
 {
     _hashFactory     = hashFactory;
     _dataKeyProvider = dataKeyProvider;
 }
コード例 #11
0
 public EnvelopeCryptoProvider(IEnvelopeCryptoConfig config, IDataKeyProvider dataKeyProvider)
     : this(dataKeyProvider, config, new DefaultAlgorithmFactory())
 {
 }
コード例 #12
0
 /// <summary>
 ///     Creates a caching wrapper around the provided <paramref name="actualDataKeyProvider" />.
 /// </summary>
 /// <param name="actualDataKeyProvider">The key provider that can actually encrypt and decrypt</param>
 /// <param name="capacity">The number of keys to cache in RAM</param>
 public CachingDataKeyProvider(IDataKeyProvider actualDataKeyProvider, int capacity)
 {
     _lruCache = new LruCache <string, byte[]>(capacity);
     _actualDataKeyProvider = actualDataKeyProvider;
 }