Skip to content

Commit

Permalink
Merge pull request #47 from webmd-health-services/bugfix/http-auth-he…
Browse files Browse the repository at this point in the history
…ader-not-recognized-by-some-endpoints

Fixed: some of ProGet's API endpoints don't recognize the HTTP Authorization header.
  • Loading branch information
splatteredbits authored Sep 19, 2024
2 parents 4fb98d4 + 2351340 commit 9c438a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

# ProGetAutomation Changelog

## 3.0.1

* Fixed: some of ProGet's API endpoints don't recognize the HTTP `Authorization` header.


## 3.0.0

> Released 31 Jan 2024
Expand Down
15 changes: 10 additions & 5 deletions ProGetAutomation/Functions/Get-ProGetRequestHeader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ function Get-ProGetRequestHeader

$headers = @{}

if( $Session.ApiKey )
if ($Session.ApiKey)
{
$headers['X-ApiKey'] = $Session.ApiKey;
}

if( $Session.Credential )
if ($Session.Credential)
{
$bytes = [Text.Encoding]::UTF8.GetBytes(('{0}:{1}' -f $Session.Credential.UserName,$Session.Credential.GetNetworkCredential().Password))
$creds = 'Basic ' + [Convert]::ToBase64String($bytes)
$headers['Authorization'] = $creds
$credential = "$($Session.Credential.UserName):$($Session.Credential.GetNetworkCredential().Password)"
$bytes = [Text.Encoding]::UTF8.GetBytes($credential)
$headers['Authorization'] = "Basic $([Convert]::ToBase64String($bytes))"

if (-not $Session.ApiKey)
{
$headers['X-ApiKey'] = $credential
}
}

return $headers
Expand Down
2 changes: 1 addition & 1 deletion ProGetAutomation/ProGetAutomation.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'ProGetAutomation.psm1'

# Version number of this module.
ModuleVersion = '3.0.0'
ModuleVersion = '3.0.1'

# Supported PSEditions
CompatiblePSEditions = @( 'Desktop', 'Core' )
Expand Down

0 comments on commit 9c438a4

Please sign in to comment.