@ -106,8 +106,12 @@ Function Download-File($result, $url, $dest, $headers, $credentials, $timeout, $
}
}
if ( $credentials ) {
if ( $credentials ) {
if ( $force_basic_auth ) {
$extWebClient . Headers . Add ( " Authorization " , " Basic $credentials " )
} else {
$extWebClient . Credentials = $credentials
$extWebClient . Credentials = $credentials
}
}
}
if ( -not $whatif ) {
if ( -not $whatif ) {
Try {
Try {
@ -138,6 +142,7 @@ $skip_certificate_validation = Get-AnsibleParam -obj $params -name "skip_certifi
$validate_certs = Get-AnsibleParam -obj $params -name " validate_certs " -type " bool " -default $true
$validate_certs = Get-AnsibleParam -obj $params -name " validate_certs " -type " bool " -default $true
$url_username = Get-AnsibleParam -obj $params -name " url_username " -type " str " -aliases " username "
$url_username = Get-AnsibleParam -obj $params -name " url_username " -type " str " -aliases " username "
$url_password = Get-AnsibleParam -obj $params -name " url_password " -type " str " -aliases " password "
$url_password = Get-AnsibleParam -obj $params -name " url_password " -type " str " -aliases " password "
$force_basic_auth = Get-AnsibleParam -obj $params -name " force_basic_auth " -type " bool " -default $false
$use_proxy = Get-AnsibleParam -obj $params -name " use_proxy " -type " bool " -default $true
$use_proxy = Get-AnsibleParam -obj $params -name " use_proxy " -type " bool " -default $true
$proxy_url = Get-AnsibleParam -obj $params -name " proxy_url " -type " str "
$proxy_url = Get-AnsibleParam -obj $params -name " proxy_url " -type " str "
$proxy_username = Get-AnsibleParam -obj $params -name " proxy_username " -type " str "
$proxy_username = Get-AnsibleParam -obj $params -name " proxy_username " -type " str "
@ -170,7 +175,12 @@ if ($proxy_url) {
$credentials = $null
$credentials = $null
if ( $url_username -and $url_password ) {
if ( $url_username -and $url_password ) {
if ( $force_basic_auth ) {
$credentials = [ convert ] :: ToBase64String ( [ System.Text.Encoding ] :: ASCII . GetBytes ( $url_username + " : " + $url_password ) )
} else {
$credentials = New-Object System . Net . NetworkCredential ( $url_username , $url_password )
$credentials = New-Object System . Net . NetworkCredential ( $url_username , $url_password )
}
}
}
# If skip_certificate_validation was specified, use validate_certs
# If skip_certificate_validation was specified, use validate_certs