コード例 #1
0
        public async Task <IActionResult> ApiSecretDelete(ApiSecretsDto apiSecret)
        {
            await _apiResourceService.DeleteApiSecretAsync(apiSecret);


            return(Success(new { Id = apiSecret.ApiResourceId }));
        }
コード例 #2
0
        public virtual ApiSecretsDto BuildApiSecretsViewModel(ApiSecretsDto apiSecrets)
        {
            apiSecrets.HashTypes = ClientService.GetHashTypes();
            apiSecrets.TypeList  = ClientService.GetSecretTypes();

            return(apiSecrets);
        }
コード例 #3
0
        public async Task <IActionResult> ApiSecretDelete(ApiSecretsDto apiSecret)
        {
            await _apiResourceService.DeleteApiSecretAsync(apiSecret);

            SuccessNotification(_localizer["SuccessDeleteApiSecret"], _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(ApiSecrets), new { Id = apiSecret.ApiResourceId }));
        }
コード例 #4
0
        public async Task <int> AddApiSecretAsync(ApiSecretsDto apiSecret)
        {
            HashApiSharedSecret(apiSecret);

            var secret = apiSecret.ToEntity();

            return(await _apiResourceRepository.AddApiSecretAsync(apiSecret.ApiResourceId, secret));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public async Task <IActionResult> DeleteSecret(int secretId)
        {
            var apiSecret = new ApiSecretsDto {
                ApiSecretId = secretId
            };

            await _apiResourceService.GetApiSecretAsync(apiSecret.ApiSecretId);

            await _apiResourceService.DeleteApiSecretAsync(apiSecret);

            return(Ok());
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public async Task <IActionResult> ApiSecrets(ApiSecretsDto apiSecret)
        {
            if (!ModelState.IsValid)
            {
                return(Success(apiSecret));
            }

            await _apiResourceService.AddApiSecretAsync(apiSecret);


            return(Success(new { Id = apiSecret.ApiResourceId }));
        }
コード例 #9
0
        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 }));
        }
コード例 #10
0
        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();
            }
        }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
 public static ApiSecret ToEntity(this ApiSecretsDto resource)
 {
     return(resource == null ? null : Mapper.Map <ApiSecret>(resource));
 }
コード例 #13
0
        public async Task <int> DeleteApiSecretAsync(ApiSecretsDto apiSecret)
        {
            var secret = apiSecret.ToEntity();

            return(await _apiResourceRepository.DeleteApiSecretAsync(secret));
        }