public async Task <UserInteractiveAuthResponseBase> GenerateSessionAsync( RegisterRequest <AuthenticationData> request) { string sessionKey; bool sessionKeyIsDuplicate; var cacheData = new RegistrationCacheData { Kind = request.Kind, Request = request, }; var caheOptions = new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromHours(1) }; do { sessionKey = GenerateAlphanumericString(64); var cacheTuple = await _cache.SetObjectIfNotExistsAsync(sessionKey, cacheData, caheOptions); sessionKeyIsDuplicate = cacheTuple.Exists; } while (sessionKeyIsDuplicate); return(new UserInteractiveAuthResponse { Session = sessionKey, Flows = new[] { new UserInteractiveAuthFlow { Stages = new[] { Constants.Authentication.Types.Dummy, } } } }); }
private static bool HaveSameRegistrationInfo(RegistrationCacheData cacheData, RegisterRequest <AuthenticationData> request2) => cacheData.Kind == request2.Kind && (cacheData.Request.UserName?.Equals(request2.UserName, StringComparison.OrdinalIgnoreCase) ?? true);