public async Task <IActionResult> ApiSecretDelete(ApiSecretsDto apiSecret) { await _apiResourceService.DeleteApiSecretAsync(apiSecret); return(Success(new { Id = apiSecret.ApiResourceId })); }
public virtual ApiSecretsDto BuildApiSecretsViewModel(ApiSecretsDto apiSecrets) { apiSecrets.HashTypes = ClientService.GetHashTypes(); apiSecrets.TypeList = ClientService.GetSecretTypes(); return(apiSecrets); }
public async Task <IActionResult> ApiSecretDelete(ApiSecretsDto apiSecret) { await _apiResourceService.DeleteApiSecretAsync(apiSecret); SuccessNotification(_localizer["SuccessDeleteApiSecret"], _localizer["SuccessTitle"]); return(RedirectToAction(nameof(ApiSecrets), new { Id = apiSecret.ApiResourceId })); }
public async Task <int> AddApiSecretAsync(ApiSecretsDto apiSecret) { HashApiSharedSecret(apiSecret); var secret = apiSecret.ToEntity(); return(await _apiResourceRepository.AddApiSecretAsync(apiSecret.ApiResourceId, secret)); }
public virtual async Task <int> DeleteApiSecretAsync(ApiSecretsDto apiSecret) { var secret = apiSecret.ToEntity(); var deleted = await ApiResourceRepository.DeleteApiSecretAsync(secret); await AuditEventLogger.LogEventAsync(new ApiSecretDeletedEvent(apiSecret.ApiResourceId, apiSecret.ApiSecretId)); return(deleted); }
public async Task <IActionResult> DeleteSecret(int secretId) { var apiSecret = new ApiSecretsDto { ApiSecretId = secretId }; await _apiResourceService.GetApiSecretAsync(apiSecret.ApiSecretId); await _apiResourceService.DeleteApiSecretAsync(apiSecret); return(Ok()); }
public virtual async Task <int> AddApiSecretAsync(ApiSecretsDto apiSecret) { HashApiSharedSecret(apiSecret); var secret = apiSecret.ToEntity(); var added = await ApiResourceRepository.AddApiSecretAsync(apiSecret.ApiResourceId, secret); await AuditEventLogger.LogEventAsync(new ApiSecretAddedEvent(apiSecret.ApiResourceId, apiSecret.Type, apiSecret.Expiration)); return(added); }
public async Task <IActionResult> ApiSecrets(ApiSecretsDto apiSecret) { if (!ModelState.IsValid) { return(Success(apiSecret)); } await _apiResourceService.AddApiSecretAsync(apiSecret); return(Success(new { Id = apiSecret.ApiResourceId })); }
public async Task <IActionResult> ApiSecrets(ApiSecretsDto apiSecret) { if (!ModelState.IsValid) { return(View(apiSecret)); } await _apiResourceService.AddApiSecretAsync(apiSecret); SuccessNotification(_localizer["SuccessAddApiSecret"], _localizer["SuccessTitle"]); return(RedirectToAction(nameof(ApiSecrets), new { Id = apiSecret.ApiResourceId })); }
private void HashApiSharedSecret(ApiSecretsDto apiSecret) { if (apiSecret.Type != SharedSecret) { return; } if (apiSecret.HashTypeEnum == HashType.Sha256) { apiSecret.Value = apiSecret.Value.Sha256(); } else if (apiSecret.HashTypeEnum == HashType.Sha512) { apiSecret.Value = apiSecret.Value.Sha512(); } }
private void HashApiSharedSecret(ApiSecretsDto apiSecret) { if (apiSecret.Type != SharedSecret) { return; } if (apiSecret.HashType == ((int)HashType.Sha256).ToString()) { apiSecret.Value = apiSecret.Value.Sha256(); } else if (apiSecret.HashType == ((int)HashType.Sha512).ToString()) { apiSecret.Value = apiSecret.Value.Sha512(); } }
public static ApiSecret ToEntity(this ApiSecretsDto resource) { return(resource == null ? null : Mapper.Map <ApiSecret>(resource)); }
public async Task <int> DeleteApiSecretAsync(ApiSecretsDto apiSecret) { var secret = apiSecret.ToEntity(); return(await _apiResourceRepository.DeleteApiSecretAsync(secret)); }