public PersistedGrantStorageContext(PersistedGrantStorageConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } Initialize(config); }
/// <summary> /// Constructor for TokenCleanup. /// </summary> /// <param name="serviceProvider"></param> /// <param name="logger"></param> /// <param name="options"></param> public PersistedGrantCleanup(IServiceProvider serviceProvider, ILogger <PersistedGrantCleanup> logger, IOptions <PersistedGrantStorageConfig> config) { _config = config?.Value ?? throw new ArgumentNullException(nameof(config)); if (_config.TokenCleanupInterval < 1) { throw new ArgumentException("Token cleanup interval must be at least 1 second"); } if (_config.TokenCleanupBatchSize < 1) { throw new ArgumentException("Token cleanup batch size interval must be at least 1"); } _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); }
protected virtual void Initialize(PersistedGrantStorageConfig config) { TableClient = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(config.StorageConnectionString).CreateCloudTableClient(); TableClient.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.Json; PersistedGrantTableName = config.PersistedGrantTableName; if (string.IsNullOrWhiteSpace(PersistedGrantTableName)) { throw new ArgumentException($"PersistedGrantTableName cannot be null or empty, check your configuration.", nameof(config.PersistedGrantTableName)); } PersistedGrantTable = TableClient.GetTableReference(PersistedGrantTableName); BlobClient = new BlobServiceClient(config.StorageConnectionString); BlobContainerName = config.BlobContainerName; if (string.IsNullOrWhiteSpace(BlobContainerName)) { throw new ArgumentException($"BlobContainerName cannot be null or empty, check your configuration.", nameof(config.BlobContainerName)); } PersistedGrantBlobContainer = BlobClient.GetBlobContainerClient(BlobContainerName); }
public PersistedGrantCleanupHost(PersistedGrantCleanup tokenCleanup, IOptions <PersistedGrantStorageConfig> config) { _tokenCleanup = tokenCleanup; _config = config.Value; }