Pode
Pode copied to clipboard
HTTP 500 Authenticating via HTTP basic auth, using a users file, causing error "Cannot validate argument on parameter 'Value'"
Describe the Bug
I've added HTTP basic authentication to a single route, via a JSON users file. When I attempt to load the route in my web browser, I get the following error on the Pode server.
Date: 2022-09-07 01:41:23
Level: Error
ThreadId: 1
Server: codespaces-8cac4e
Category: InvalidData: (:) [Invoke-PodeScriptBlock], ParameterBindingValidationException
Message: Cannot validate argument on parameter 'Value'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
StackTrace: at <ScriptBlock>, /home/codespace/.local/share/powershell/Modules/Pode/2.7.1/Private/Authentication.ps1: line 729
at Invoke-PodeScriptBlock, /home/codespace/.local/share/powershell/Modules/Pode/2.7.1/Public/Utilities.ps1: line 642
at <ScriptBlock>, /home/codespace/.local/share/powershell/Modules/Pode/2.7.1/Private/Authentication.ps1: line 1163
at Invoke-PodeScriptBlock, /home/codespace/.local/share/powershell/Modules/Pode/2.7.1/Public/Utilities.ps1: line 634
at Invoke-PodeMiddleware, /home/codespace/.local/share/powershell/Modules/Pode/2.7.1/Private/Middleware.ps1: line 45
at <ScriptBlock>, <No file>: line 87
Steps To Reproduce
Pode
Start-PodeServer -ScriptBlock {
Add-PodeEndpoint -Address 0.0.0.0 -Port 8080 -Protocol Http
New-PodeAuthScheme -Basic | Add-PodeAuthUserFile -Name Login -Sessionless
Add-PodeRoute -Method Get -Authentication Login -Path /nameform -ScriptBlock {
Write-PodeHtmlResponse -Value @'
<form action = "/name" method = "post">
<input id = "username" type = "text" />
<input id = "password" type = "password" />
<input type = "submit" value = "Create Name" />
</form>
'@
}
}
users.json
[
{
"Username": "trevor",
"Name": "trevor",
"Email": "xxxxxxxxxxxxxx",
"Password": "87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7",
"Groups": ["Admins"]
}
]
Expected Behavior
User authentication should work properly.
Platform
- OS: [e.g. iOS, Windows] Windows 11
- Browser: [e.g. Chrome, Safari] Chrome
- Versions:
- Pode: [e.g. Pode v1.7.3] 2.7.1
- PowerShell: [e.g. PS6.2.1] 7.2.6