예제 #1
0
        public async Task <StatusCodes> UpdateAppOptionsAsync(string key, string value, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - SetupService_UpdateAppOpptionsAsync called.");
            // Update ProposalManagementRootSiteId if empty
            if (string.IsNullOrWhiteSpace(_writableOptions.Value.ProposalManagementRootSiteId))
            {
                _writableOptions.UpdateAsync(nameof(_writableOptions.Value.ProposalManagementRootSiteId), await _graphSharePointAppService.GetSharePointRootId(), requestId);
            }

            _writableOptions.UpdateAsync(key, value, requestId);
            return(StatusCodes.Status200OK);
        }
예제 #2
0
        public Task <StatusCodes> UpdateDocumentIdActivatorOptionsAsync(string key, string value, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - SetupService_UpdateAppOpptionsAsync called.");

            if (!key.StartsWith("SharePoint"))
            {
                documentIdActivatorConfigurationWritableOptions.UpdateAsync(key, value, requestId);
            }
            else
            {
                SaveSharePointAppSetting(key, value);
            }

            return(Task.FromResult(StatusCodes.Status200OK));
        }
예제 #3
0
        public async Task <StatusCodes> UpdateAppOpptionsAsync(string key, string value, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - SetupService_UpdateAppOpptionsAsync called.");

            ////Save powerbi username and password to to Key Vault.
            //if (key == "PBIUserName" || key == "PBIUserPassword")
            //{
            //    await _azureKeyVaultService.SetValueInVaultAsync(key, value, requestId);
            //    return StatusCodes.Status200OK;
            //}
            ////save values to appsettings.
            //else
            //{
            _writableOptions.UpdateAsync(key, value, requestId);
            return(StatusCodes.Status200OK);
            //}
        }
예제 #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (Smtp.Address is null)
            {
                Smtp.Address = Smtp.Login;
            }

            if (Smtp.Name is null)
            {
                Smtp.Name = "CRM Server";
            }

            password                 = Smtp.Password;
            Smtp.Password            = string.Empty;
            using var passwordHasher = new PasswordHasher();
            Smtp.Password            = passwordHasher.Encrypt(password, Smtp);

            try
            {
                await smtpService.ConfigureAsync(Smtp);

                await writableSmtp.UpdateAsync(Smtp);

                // Disables setup
                application.FirstRun = false;
                await writableApplication.UpdateAsync(application);

                return(LocalRedirect("~/"));
            }

            catch (AuthenticationException)
            {
                return(Page());
            }

            catch (NotSupportedException)
            {
                return(Page());
            }
        }
        public async Task SetValueInVaultAsync(string key, string value, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - SetValueInVaultAsync called.");
            try
            {
                var keyVaultClient = new KeyVaultClient(new
                                                        KeyVaultClient.AuthenticationCallback(GetToken), new HttpClient());
                // checking vaultBaseURL containes https or not
                string vaultBaseUrl = _appOptions.VaultBaseUrl;
                if (!(_appOptions.VaultBaseUrl.Contains("https://")))
                {
                    vaultBaseUrl = "https://" + vaultBaseUrl;
                }
                var sec = await keyVaultClient.SetSecretAsync(vaultBaseUrl, key, value);

                //update appsetings with the new secret identifier.
                _writableOptions.UpdateAsync(key, sec.SecretIdentifier.ToString());
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - SetValueInVaultAsync Exception: {ex}");
                throw new ResponseException($"RequestId: {requestId} - SetValueInVaultAsync  Exception: {ex}");
            }
        }