-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from craysiii/custom-headers
Add new methods to allow custom headers in each Hudu API Request
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function New-HuduCustomHeaders { | ||
<# | ||
.SYNOPSIS | ||
Set Hudu custom headers to be injected into each request | ||
.DESCRIPTION | ||
There may be times when one might need to use custom headers e.g. Service Tokens for Cloudflare Zero Trust | ||
.PARAMETER Headers | ||
Hashtable with the Custom Headers that need to be injected into each request | ||
.EXAMPLE | ||
New-HuduCustomHeaders -Headers @{"CF-Access-Client-Id" = "x"; "CF-Access-Client-Secret" = "y"} | ||
.NOTES | ||
General notes | ||
#> | ||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function')] | ||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $true, | ||
ValueFromPipeline = $true)] | ||
[hashtable] | ||
$Headers | ||
) | ||
process { | ||
if ($Headers.Count -eq 0) { | ||
Write-Host "Empty Custom Header hashtable was provided, no Custom Headers will be set" | ||
return 0 | ||
} | ||
|
||
Set-Variable -Name 'Int_HuduCustomHeaders' -Value $Headers -Visibility Private -Scope script -Force | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function Remove-HuduCustomHeaders { | ||
<# | ||
.SYNOPSIS | ||
Remove Custom Headers that are injected into each request | ||
.DESCRIPTION | ||
Unsets the Hudu Custom Header variable | ||
.EXAMPLE | ||
Remove-HuduCustomHeaders | ||
#> | ||
[CmdletBinding(SupportsShouldProcess)] | ||
Param() | ||
if ($PSCmdlet.ShouldProcess('Custom Headers')) { | ||
Remove-Variable -Name 'Int_HuduCustomHeaders' -Scope script -Force | ||
} | ||
} |