Пример #1
0
        private async Task <RequestTokenRequest> CreateAuthenticationTokenRequestAsync(string apiJwtToken)
        {
            var eboUsername = (await vaultService.GetVaultValueAsync(VaultConstants.EquiasEboUsernameKey, apiJwtToken))?.Data?.SingleOrDefault()?.VaultValue;
            var eboPassword = (await vaultService.GetVaultValueAsync(VaultConstants.EquiasEboPasswordKey, apiJwtToken))?.Data?.SingleOrDefault()?.VaultValue;

            if (string.IsNullOrEmpty(eboUsername))
            {
                logger.LogError("The {EquiasEboUsernameKey} is not configured in the vault", VaultConstants.EquiasEboUsernameKey);
                throw new SecurityException($"The {VaultConstants.EquiasEboUsernameKey} is not configured in the vault");
            }

            if (string.IsNullOrEmpty(eboPassword))
            {
                logger.LogError("The {EquiasEboPasswordKey} is not configured in the vault", VaultConstants.EquiasEboPasswordKey);
                throw new SecurityException($"The {VaultConstants.EquiasEboPasswordKey} is not configured in the vault");
            }

            return(new RequestTokenRequest(eboUsername, eboPassword));
        }
Пример #2
0
        private async Task <RequestTokenRequest> CreateAuthenticationTokenRequestAsync(string apiJwtToken)
        {
            var fidectusClientId     = (await vaultService.GetVaultValueAsync(VaultConstants.FidectusClientId, apiJwtToken))?.Data?.SingleOrDefault()?.VaultValue;
            var fidectusClientSecret = (await vaultService.GetVaultValueAsync(VaultConstants.FidectusClientSecret, apiJwtToken))?.Data?.SingleOrDefault()?.VaultValue;

            if (string.IsNullOrWhiteSpace(fidectusClientId))
            {
                logger.LogError("The {FidectusClientId} is not configured in the vault", VaultConstants.FidectusClientId);
                throw new SecurityException($"The {VaultConstants.FidectusClientId} is not configured in the vault");
            }

            if (string.IsNullOrEmpty(fidectusClientSecret))
            {
                logger.LogError("The {FidectusClientSecret} is not configured in the vault", VaultConstants.FidectusClientSecret);
                throw new SecurityException($"The {VaultConstants.FidectusClientSecret} is not configured in the vault");
            }

            var fidectusAudience = (await settingService.GetSettingViaJwtAsync("FIDECTUS_AUDIENCE", apiJwtToken))?.Data?.SingleOrDefault()?.SettingValue;

            return(new RequestTokenRequest(fidectusClientId, fidectusClientSecret, fidectusAudience));
        }