From 7fb54de8ce48adb7aba227e0bdbee615bb68d235 Mon Sep 17 00:00:00 2001 From: Teh-STIG <105899123+Teh-STIG@users.noreply.github.com> Date: Thu, 26 Dec 2024 09:14:42 -0600 Subject: [PATCH 1/2] Update Connect-HuduAPI.ps1 Add logic to check if Hudu.CFEnabled checkbox is enabled in from Extension.json**. If so, pull the CloudFlare Client ID and API Key from the cippmsdwl key vault and add them as a header for the initial connection request. ** Hudu.CFEnabled checkbox and input fields were added to /CIPP/blob/main/src/data/Extensions.json --- Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 b/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 index 05c2f9b1e78f..a8ba08b38c3d 100644 --- a/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 +++ b/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 @@ -12,6 +12,12 @@ function Connect-HuduAPI { $null = Connect-AzAccount -Identity $APIKey = (Get-AzKeyVaultSecret -VaultName $keyvaultname -Name 'Hudu' -AsPlainText) } + # Add logic to check if we're using CloudFlare Tunnel, and if so, pull CloudFlare API Key and add as a header + if ($Configuration.CFEnabled) { + $CFClientID = (Get-AzKeyVaultSecret -VaultName $keyvaultname -Name 'CloudFlareClientID' -AsPlainText) + $CFAPIKey = (Get-AzKeyVaultSecret -VaultName $keyvaultname -Name 'CloudFlareAPIKey' -AsPlainText) + New-HuduCustomHeaders -Headers @{"CF-Access-Client-Id" = "$CFClientID"; "CF-Access-Client-Secret" = "$CFAPIKey"} + } New-HuduBaseURL -BaseURL $Configuration.BaseURL New-HuduAPIKey -ApiKey $APIKey } From 70c9d60c2f93da6e16ffaf2e38b714c00c6c4804 Mon Sep 17 00:00:00 2001 From: Teh-STIG <105899123+Teh-STIG@users.noreply.github.com> Date: Thu, 26 Dec 2024 09:36:35 -0600 Subject: [PATCH 2/2] Update Connect-HuduAPI.ps1 --- Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 b/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 index a8ba08b38c3d..433bbe8547f5 100644 --- a/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 +++ b/Modules/CippExtensions/Public/Hudu/Connect-HuduAPI.ps1 @@ -12,7 +12,7 @@ function Connect-HuduAPI { $null = Connect-AzAccount -Identity $APIKey = (Get-AzKeyVaultSecret -VaultName $keyvaultname -Name 'Hudu' -AsPlainText) } - # Add logic to check if we're using CloudFlare Tunnel, and if so, pull CloudFlare API Key and add as a header + # Add logic to check if we're using CloudFlare Tunnel (if Hudu.CFEnabled checkbox is checked from Extensions.json). If the checkbox is checked, pull CloudFlare ClientID and API Key and add as a header if ($Configuration.CFEnabled) { $CFClientID = (Get-AzKeyVaultSecret -VaultName $keyvaultname -Name 'CloudFlareClientID' -AsPlainText) $CFAPIKey = (Get-AzKeyVaultSecret -VaultName $keyvaultname -Name 'CloudFlareAPIKey' -AsPlainText)