Exemplo n.º 1
0
        public async Task StoreValidationResultCache(string pubKey, string keyId, string secret)
        {
            var next3Minutes = new DateTimeOffset(DateTime.Now.AddMonths(3));
            var options      = new DistributedCacheEntryOptions().SetAbsoluteExpiration(next3Minutes);

            var value = new KeySecretValidationResultCacheItem(pubKey, keyId).ToBytes();

            // Store validation result
            await _cache.SetAsync(secret, value, options);
        }
Exemplo n.º 2
0
        public bool IsValidOnCache(string pubkey, string secret, out string keyId)
        {
            keyId = "";
            var value = _cache.Get(pubkey);

            if (value != null)
            {
                var pubKeyOnCache = new KeySecretValidationResultCacheItem(value);

                keyId = pubKeyOnCache.KeyId;
                return(pubkey == pubKeyOnCache.PubKey);
            }

            return(false);
        }