protected async Task RemoveAsync(string handle) { var entity = await GetEntityByHandle(handle) .ConfigureAwait(false); await _store.DeleteAsync(entity.Id) .ConfigureAwait(false); }
private async Task RemoveExpiredTokensAsync(IAdminStore store, IEnumerable <IGrant> items, CancellationToken cancellationToken) { foreach (var token in items) { await store.DeleteAsync(token.Id, cancellationToken).ConfigureAwait(false); } }
/// <summary> /// Gets the one time token. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public string GetOneTimeToken(string id) { var token = _store.GetAsync(id, new GetRequest()).GetAwaiter().GetResult(); _store.DeleteAsync(id).GetAwaiter().GetResult(); return(token.Data); }
private async Task UpdateRedirectUris(string clientId, ClientRegisteration registration) { var redirectUriResponse = await _clientUriStore.GetAsync(new PageRequest { Filter = $"{nameof(ClientUri.ClientId)} eq '{clientId}'" }).ConfigureAwait(false); foreach (var item in redirectUriResponse.Items) { if (!registration.RedirectUris.Any(u => u == item.Uri)) { await _clientUriStore.DeleteAsync(item.Id).ConfigureAwait(false); } } foreach (var redirectUri in registration.RedirectUris) { if (!redirectUriResponse.Items.Any(u => u.Uri == redirectUri)) { await _clientUriStore.CreateAsync(new ClientUri { ClientId = clientId, Id = Guid.NewGuid().ToString(), Kind = UriKinds.Cors | UriKinds.Redirect, Uri = redirectUri }).ConfigureAwait(false); } } }
private async Task UpdateGrantTypes(string clientId, ClientRegisteration registration) { var grantTypeResponse = await _clientGrantTypeStore.GetAsync(new PageRequest { Filter = $"{nameof(ClientGrantType.ClientId)} eq '{clientId}'" }).ConfigureAwait(false); foreach (var item in grantTypeResponse.Items) { if (!registration.GrantTypes.Any(g => g == item.GrantType)) { await _clientGrantTypeStore.DeleteAsync(item.Id).ConfigureAwait(false); } } foreach (var grantType in registration.GrantTypes) { if (!grantTypeResponse.Items.Any(u => u.GrantType == grantType)) { await _clientGrantTypeStore.CreateAsync(new ClientGrantType { ClientId = clientId, Id = Guid.NewGuid().ToString(), GrantType = grantType }).ConfigureAwait(false); } } }
private async Task UpdatePropertyAsync(string clientId, ClientRegisteration registration, PageResponse <ClientProperty> propertiesResponse, string values, string key) { var property = propertiesResponse.Items.FirstOrDefault(p => p.Key == key); if ((registration.Contacts == null || !registration.Contacts.Any()) && property != null) { await _clientPropertyStore.DeleteAsync(property.Id).ConfigureAwait(false); } if (registration.Contacts == null || !registration.Contacts.Any()) { if (property == null) { await _clientPropertyStore.CreateAsync(new ClientProperty { ClientId = clientId, Id = Guid.NewGuid().ToString(), Key = key, Value = values }).ConfigureAwait(false); } else if (property.Value != values) { property.Value = values; await _clientPropertyStore.UpdateAsync(property).ConfigureAwait(false); } } }
/// <summary> /// Gets and consume the one time token. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public string ConsumeOneTimeToken(string id) { var token = _store.GetAsync(id, new GetRequest()).GetAwaiter().GetResult(); if (token == null) { return(null); } _store.DeleteAsync(id).GetAwaiter().GetResult(); return(token.Data); }
private async Task DeleteItemAsync(IEnumerable <LocalizableProperty> clientNameList, IEnumerable <LocalizableProperty> clientUriList, IEnumerable <LocalizableProperty> logoUriList, IEnumerable <LocalizableProperty> policyUriList, IEnumerable <LocalizableProperty> tosUriList, ClientLocalizedResource item) { if (item.ResourceKind == EntityResourceKind.DisplayName && !clientNameList.Any(IsDeleted(item))) { await _clientResourceStore.DeleteAsync(item.Id).ConfigureAwait(false); } if (item.ResourceKind == EntityResourceKind.ClientUri && !clientUriList.Any(IsDeleted(item))) { await _clientResourceStore.DeleteAsync(item.Id).ConfigureAwait(false); } if (item.ResourceKind == EntityResourceKind.LogoUri && !logoUriList.Any(IsDeleted(item))) { await _clientResourceStore.DeleteAsync(item.Id).ConfigureAwait(false); } if (item.ResourceKind == EntityResourceKind.PolicyUri && !policyUriList.Any(IsDeleted(item))) { await _clientResourceStore.DeleteAsync(item.Id).ConfigureAwait(false); } if (item.ResourceKind == EntityResourceKind.TosUri && !tosUriList.Any(n => n.Culture == item.CultureId && n.Value == item.Value)) { await _clientResourceStore.DeleteAsync(item.Id).ConfigureAwait(false); } }
public async Task RemoveAuthorizationCodeAsync(string code) { code = code ?? throw new ArgumentNullException(nameof(code)); var response = await _store.GetAsync(new PageRequest { Filter = $"{nameof(Entity.AuthorizationCode.Id)} eq '{code}'", Select = nameof(Entity.AuthorizationCode.Id) }).ConfigureAwait(false); foreach (var item in response.Items) { await _store.DeleteAsync(item.Id).ConfigureAwait(false); } }
public async Task RemoveByDeviceCodeAsync(string deviceCode) { deviceCode = deviceCode ?? throw new ArgumentNullException(nameof(deviceCode)); var response = await _store.GetAsync(new PageRequest { Filter = $"{nameof(DeviceCode.Code)} eq '{deviceCode}'", Select = nameof(DeviceCode.Id) }).ConfigureAwait(false); foreach (var entity in response.Items) { await _store.DeleteAsync(entity.Id).ConfigureAwait(false); } }
/// <summary> /// Removes all grants for a given subject id and client id combination. /// </summary> /// <param name="subjectId">The subject identifier.</param> /// <param name="clientId">The client identifier.</param> /// <param name="sessionId">The sesion id (optional).</param> /// <returns></returns> public async Task RemoveAllGrantsAsync(string subjectId, string clientId = null, string sessionId = null) { var filter = $"{nameof(Entity.IGrant.UserId)} eq '{subjectId}'"; if (clientId != null) { filter += $" and {nameof(Entity.IGrant.ClientId)} eq '{clientId}'"; } if (sessionId != null) { filter += $" and {nameof(Entity.IGrant.SessionId)} eq '{sessionId}'"; } var request = new PageRequest { Take = null, Filter = filter }; var consentListResponse = await _userConsentStore.GetAsync(request).ConfigureAwait(false); var codeListResponse = await _authorizationCodeStore.GetAsync(request).ConfigureAwait(false); var refreshTokenListResponse = await _refreshTokenStore.GetAsync(request).ConfigureAwait(false); var referenceTokenListResponse = await _referenceTokenStore.GetAsync(request).ConfigureAwait(false); foreach (var consent in consentListResponse.Items) { await _userConsentStore.DeleteAsync(consent.Id).ConfigureAwait(false); } foreach (var code in codeListResponse.Items) { await _authorizationCodeStore.DeleteAsync(code.Id).ConfigureAwait(false); } foreach (var token in refreshTokenListResponse.Items) { await _refreshTokenStore.DeleteAsync(token.Id).ConfigureAwait(false); } foreach (var token in referenceTokenListResponse.Items) { await _referenceTokenStore.DeleteAsync(token.Id).ConfigureAwait(false); } }
/// <summary> /// Deletes a role from the store as an asynchronous operation. /// </summary> /// <param name="role">The role to delete from the store.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> /// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns> public async virtual Task <IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); AssertNotNull(role, nameof(role)); try { await _roleStore.DeleteAsync(role.Id, cancellationToken).ConfigureAwait(false); return(IdentityResult.Success); } catch (Exception e) { return(IdentityResult.Failed(new IdentityError { Code = e.GetType().Name, Description = e.Message })); } }
public Task DeleteAsync(string id, CancellationToken cancellationToken = default) { return(_store.DeleteAsync(id, cancellationToken)); }
public Task RemoveAsync(TSchemeDefinition definition, CancellationToken cancellationToken = default) { return(_store.DeleteAsync(definition.Scheme, cancellationToken)); }
private static async Task RemoveEntityAsync(T entity, IAdminStore <T> store, ImportFileResult result) { await store.DeleteAsync(entity.Id).ConfigureAwait(false); result.Deleted.Add(entity.Id); }
/// <summary> /// Deletes the registration asynchronous. /// </summary> /// <param name="clientId">The client identifier.</param> /// <returns></returns> public Task DeleteRegistrationAsync(string clientId) => _clientStore.DeleteAsync(clientId);