Exemplo n.º 1
0
        public virtual async Task <int> DeleteClientSecretAsync(ClientSecretsDto clientSecret)
        {
            var clientSecretEntity = clientSecret.ToEntity();

            var deleted = await ClientRepository.DeleteClientSecretAsync(clientSecretEntity);

            await AuditEventLogger.LogEventAsync(new ClientSecretDeletedEvent(clientSecret.ClientId, clientSecret.ClientSecretId));

            return(deleted);
        }
Exemplo n.º 2
0
        public virtual async Task <int> AddClientSecretAsync(ClientSecretsDto clientSecret)
        {
            HashClientSharedSecret(clientSecret);

            var clientSecretEntity = clientSecret.ToEntity();
            var added = await ClientRepository.AddClientSecretAsync(clientSecret.ClientId, clientSecretEntity);

            await AuditEventLogger.LogEventAsync(new ClientSecretAddedEvent(clientSecret.ClientId, clientSecret.Type, clientSecret.Expiration));

            return(added);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> DeleteSecret(int secretId)
        {
            var clientSecret = new ClientSecretsDto {
                ClientSecretId = secretId
            };

            await _clientService.GetClientSecretAsync(clientSecret.ClientSecretId);

            await _clientService.DeleteClientSecretAsync(clientSecret);

            return(Ok());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> ClientSecretDelete(ClientSecretsDto clientSecret)
        {
            if (await IsUserManagerOrAdmin(clientSecret.ClientId))
            {
                await _clientService.DeleteClientSecretAsync(clientSecret);

                SuccessNotification(_localizer["SuccessDeleteClientSecret"], _localizer["SuccessTitle"]);
            }
            else
            {
                UnauthorizedNotification();
            }

            return(RedirectToAction(nameof(ClientSecrets), new { Id = clientSecret.ClientId }));
        }
Exemplo n.º 5
0
        private void HashClientSharedSecret(ClientSecretsDto clientSecret)
        {
            if (clientSecret.Type != SharedSecret)
            {
                return;
            }

            if (clientSecret.HashTypeEnum == HashType.Sha256)
            {
                clientSecret.Value = clientSecret.Value.Sha256();
            }
            else if (clientSecret.HashTypeEnum == HashType.Sha512)
            {
                clientSecret.Value = clientSecret.Value.Sha512();
            }
        }
        private void HashClientSharedSecret(ClientSecretsDto clientSecret)
        {
            if (clientSecret.Type != SharedSecret)
            {
                return;
            }

            if (clientSecret.HashType == ((int)HashType.Sha256).ToString())
            {
                clientSecret.Value = clientSecret.Value.Sha256();
            }
            else if (clientSecret.HashType == ((int)HashType.Sha512).ToString())
            {
                clientSecret.Value = clientSecret.Value.Sha512();
            }
        }
Exemplo n.º 7
0
 public static ClientSecret ToEntity(this ClientSecretsDto clientSecret, IMapper mapper)
 {
     return(mapper.Map <ClientSecret>(clientSecret));
 }
        public async Task <int> DeleteClientSecretAsync(ClientSecretsDto clientSecret)
        {
            var clientSecretEntity = clientSecret.ToEntity();

            return(await _clientRepository.DeleteClientSecretAsync(clientSecretEntity));
        }