| 123456789101112131415161718192021222324 |
- using Fido2NetLib;
- using Microsoft.Extensions.Caching.Memory;
- namespace Passwordless;
- public class OptionsCache
- {
- private readonly IMemoryCache _cache;
- public OptionsCache(IMemoryCache cache)
- {
- _cache = cache;
- }
- public CredentialCreateOptions Get(string key)
- {
- return _cache.Get<CredentialCreateOptions>(key) ?? throw new Exception("Credential options not found - probably due to creation timeout");
- }
- public void Set(CredentialCreateOptions options)
- {
- _cache.Set(options.User.Name, options, TimeSpan.FromMinutes(5));
- }
- }
|