From 6e352de324f1585b8a8d248b50ab6898ceb90a78 Mon Sep 17 00:00:00 2001 From: webalexeu <28548335+webalexeu@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:21:26 +0100 Subject: [PATCH] [Fix]: Fix authentication method in Set-PSWinBGPConfig (#12) * Fix authentication method in Set-PSWinBGPConfig --- src/data/PSWinBGP.psd1 | 16 ++++++++-------- src/functions/private/Invoke-PSWinBGP.ps1 | 4 ++-- src/functions/public/Set-PSWinBGPConfig.ps1 | 10 ++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/data/PSWinBGP.psd1 b/src/data/PSWinBGP.psd1 index b7e02c4..c0b0f4a 100644 --- a/src/data/PSWinBGP.psd1 +++ b/src/data/PSWinBGP.psd1 @@ -1,10 +1,10 @@ @{ - LocalhostApiPort = 8888 - LocalhostApiProtocol = 'http' - LocalhostApiTimeout = 5 - LocalhostAuthenticationMethod = 'Anonymous' - ApiPort = 8888 - ApiProtocol = 'https' - ApiTimeout = 10 - AuthenticationMethod = 'IntegratedWindowsAuthentication' + LocalhostApiAuthenticationMethod = 'Anonymous' + LocalhostApiPort = 8888 + LocalhostApiProtocol = 'http' + LocalhostApiTimeout = 5 + ApiAuthenticationMethod = 'IntegratedWindowsAuthentication' + ApiPort = 8888 + ApiProtocol = 'https' + ApiTimeout = 10 } diff --git a/src/functions/private/Invoke-PSWinBGP.ps1 b/src/functions/private/Invoke-PSWinBGP.ps1 index 382614e..c05090c 100644 --- a/src/functions/private/Invoke-PSWinBGP.ps1 +++ b/src/functions/private/Invoke-PSWinBGP.ps1 @@ -31,15 +31,15 @@ function Invoke-PSWinBGP() { } } else { if ($ComputerName -eq 'localhost') { + [String]$AuthenticationMethod = $Script:PSWinBGP.LocalhostApiAuthenticationMethod [Int]$Port = $Script:PSWinBGP.LocalhostApiPort [String]$Protocol = $Script:PSWinBGP.LocalhostApiProtocol [Int]$Timeout = $Script:PSWinBGP.LocalhostApiTimeout - [String]$AuthenticationMethod = $Script:PSWinBGP.LocalhostAuthenticationMethod } else { + [String]$AuthenticationMethod = $Script:PSWinBGP.ApiAuthenticationMethod [Int]$Port = $Script:PSWinBGP.ApiPort [String]$Protocol = $Script:PSWinBGP.ApiProtocol [Int]$Timeout = $Script:PSWinBGP.ApiTimeout - [String]$AuthenticationMethod = $Script:PSWinBGP.AuthenticationMethod } # Initialize output variable diff --git a/src/functions/public/Set-PSWinBGPConfig.ps1 b/src/functions/public/Set-PSWinBGPConfig.ps1 index 4d44ba7..bfb9401 100644 --- a/src/functions/public/Set-PSWinBGPConfig.ps1 +++ b/src/functions/public/Set-PSWinBGPConfig.ps1 @@ -6,6 +6,9 @@ function Set-PSWinBGPConfig { .DESCRIPTION Set PSWinBBGP module configuration, and $PSWinBBGP module variable. + .PARAMETER ApiAuthenticationMethod + API Authentication Method (Default: IntegratedWindowsAuthentication) + .PARAMETER ApiPort API Port (Default: 8888) @@ -15,6 +18,9 @@ function Set-PSWinBGPConfig { .PARAMETER ApiTimeout API Timeout (Default: 10s) + .PARAMETER LocalhostApiAuthenticationMethod + Localhost API Authentication Method (Default: Anonymous) + .PARAMETER LocalhostApiPort Localhost API Port (Default: 8888) @@ -26,9 +32,11 @@ function Set-PSWinBGPConfig { #> [CmdletBinding(SupportsShouldProcess = $true)] param( + [string]$ApiAuthenticationMethod, [Int]$ApiPort, [string]$ApiProtocol, [Int]$ApiTimeout, + [string]$LocalhostApiAuthenticationMethod, [Int]$LocalhostApiPort, [string]$LocalhostApiProtocol, [Int]$LocalhostApiTimeout @@ -36,9 +44,11 @@ function Set-PSWinBGPConfig { if ($pscmdlet.ShouldProcess('$Script:PSWinBGP', 'Set config')) { switch ($PSBoundParameters.Keys) { + 'ApiAuthenticationMethod' { $Script:PSWinBGP.ApiAuthenticationMethod = $ApiAuthenticationMethod } 'ApiPort' { $Script:PSWinBGP.ApiPort = $ApiPort } 'ApiProtocol' { $Script:PSWinBGP.ApiProtocol = $ApiProtocol } 'ApiTimeout' { $Script:PSWinBGP.ApiTimeout = $ApiTimeout } + 'LocalhostApiAuthenticationMethod' { $Script:PSWinBGP.LocalhostApiAuthenticationMethod = $LocalhostApiAuthenticationMethod } 'LocalhostApiPort' { $Script:PSWinBGP.LocalhostApiPort = $LocalhostApiPort } 'LocalhostApiProtocol' { $Script:PSWinBGP.LocalhostApiProtocol = $LocalhostApiProtocol } 'LocalhostApiTimeout' { $Script:PSWinBGP.LocalhostApiTimeout = $LocalhostApiTimeout }