public async Task DeleteAllBySubjectIdAsync_Should_Delete_All_PersistedGrants_For_Particular_SubjectId() { var subjectId = Guid.NewGuid(); var persistedGrant = new PersistedGrant { ClientId = "clientId", Type = "refresh_token", Data = "{\"CreationTime\":\"2020-02-17T18:39:53Z\",\"Lifetime\":2592000,\"AccessToken\":{\"Audiences\":[\"Riva.Identity\"],\"Issuer\":\"http://*****:*****@gmail.com\",\"ValueType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Type\":\"email_verified\",\"Value\":\"True\",\"ValueType\":\"http://www.w3.org/2001/XMLSchema#boolean\"},{\"Type\":\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name\",\"Value\":\"[email protected]\",\"ValueType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Type\":\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier\",\"Value\":\"5eb19001-41ef-4819-9a96-e7f777fe3dcc\",\"ValueType\":\"http://www.w3.org/2001/XMLSchema#string\"}],\"Version\":4},\"Version\":4}", CreationTime = DateTime.UtcNow, Key = "LUzQkz9A1uljITj7GRk4FkwFXA7z6S8VN8Cx1EnWxg8=", SubjectId = subjectId.ToString(), Expiration = DateTime.UtcNow.AddDays(1) }; _context.PersistedGrants.Add(persistedGrant); await _context.SaveChangesAsync(); Func <Task> result = async() => await _persistedGrantRepository.DeleteAllBySubjectIdAsync(subjectId); await result.Should().NotThrowAsync <Exception>(); var deletedEntity = await _context.PersistedGrants.FindAsync(persistedGrant.Key); deletedEntity.Should().BeNull(); }
public async Task <LoggedOutOutput> ExecuteAsync(string logoutId) { var getLogoutRequestTask = _logoutService.GetLogoutRequestAsync(logoutId); var claimsPrincipal = _claimsPrincipalService.GetClaimsPrincipal(); var logoutRequest = await getLogoutRequestTask; if (claimsPrincipal?.Identity != null && claimsPrincipal.Identity.IsAuthenticated) { var signOutTask = _signOutService.SignOutAsync(); if (logoutRequest.SubjectId.HasValue) { await _persistedGrantRepository.DeleteAllBySubjectIdAsync(logoutRequest.SubjectId.Value); } var idp = _claimsPrincipalService.GetNonLocalIdentityProvider(claimsPrincipal); await signOutTask; if (!string.IsNullOrWhiteSpace(idp) && await _schemeService.SchemeSupportsSignOutAsync(idp)) { if (string.IsNullOrWhiteSpace(logoutId)) { logoutId = await _logoutService.CreateLogoutContextAsync(); } return(new LoggedOutOutput(logoutId, logoutRequest.PostLogoutRedirectUri, logoutRequest.SignOutIFrameUrl, logoutRequest.ClientId, idp)); } } return(new LoggedOutOutput(logoutId, logoutRequest?.PostLogoutRedirectUri, logoutRequest?.SignOutIFrameUrl, logoutRequest?.ClientId, null)); }
public async Task DeleteAccountWithRelatedPersistedGrants(Account account) { var strategy = _rivaIdentityDbContext.Database.CreateExecutionStrategy(); await strategy.ExecuteAsync(async() => { await using var transaction = await _rivaIdentityDbContext.Database.BeginTransactionAsync(); await _accountRepository.DeleteAsync(account); await _persistedGrantDbContext.Database.UseTransactionAsync(transaction.GetDbTransaction()); await _persistedGrantRepository.DeleteAllBySubjectIdAsync(account.Id); await transaction.CommitAsync(); }); }
public async Task <bool> DeleteAllBySubjectIdAsync(string subjectId) { return(await _repository.DeleteAllBySubjectIdAsync(subjectId)); }
public async Task RemoveAllAsync(PersistedGrantFilter filter) { await _repository.DeleteAllBySubjectIdAsync(filter.SubjectId); }