Example #1
0
        public override async Task <RegeneratedSecret> GetSecretToUseDuringRekeying()
        {
            Logger.LogInformation("Getting temporary secret to use during rekeying from other ({0}) key...", GetOtherKeyKind(Configuration.KeyKind));
            var cosmosDbAccount = await CosmosDbAccount;
            IDatabaseAccountListKeysResult keys = await cosmosDbAccount.ListKeysAsync();

            Logger.LogInformation("Successfully retrieved temporary secret!");
            return(new RegeneratedSecret()
            {
                Expiry = DateTimeOffset.UtcNow + TimeSpan.FromMinutes(10),
                UserHint = Configuration.UserHint,
                NewSecretValue = GetKeyValue(keys, GetOtherKeyKind(Configuration.KeyKind))
            });
        }
Example #2
0
        public override async Task <RegeneratedSecret> Rekey(TimeSpan requestedValidPeriod)
        {
            var cosmosDbAccount = await CosmosDbAccount;

            Logger.LogInformation("Regenerating CosmosDB key kind {0}", Configuration.KeyKind);
            await cosmosDbAccount.RegenerateKeyAsync(GetKeyKindString(Configuration.KeyKind));

            IDatabaseAccountListKeysResult keys = await cosmosDbAccount.ListKeysAsync();

            Logger.LogInformation("Successfully rekeyed CosmosDB key kind {0}", Configuration.KeyKind);
            return(new RegeneratedSecret()
            {
                Expiry = DateTimeOffset.UtcNow + requestedValidPeriod,
                UserHint = Configuration.UserHint,
                NewSecretValue = GetKeyValue(keys, Configuration.KeyKind)
            });
        }