Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 500 Authenticating via HTTP basic auth, using a users file, causing error "Cannot validate argument on parameter 'Value'" #1009

Closed
pcgeek86 opened this issue Sep 7, 2022 · 4 comments

Comments

@pcgeek86
Copy link
Contributor

pcgeek86 commented Sep 7, 2022

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
@Badgerati
Copy link
Owner

Hi @pcgeek86,

I just tried this myself, and it worked as expected 🤔. Does Chrome for you show the credentials pop-up? The line the error is being thrown on suggests there's no password being sent for the basic auth.

(I replaced the password in your example file with UNhY4JhezH9gQYqvDMWrWH9CwlcKiECVqejMrND2VFw=, which is just "example")

@idanmashaal
Copy link

@Badgerati I was having the same issue. If your password works, can you share the code you are your passwords?
Would be great to receive an example for both SHA256 and SHA256+HMAC.
Thanks!

@idanmashaal
Copy link

@Badgerati I was having the same issue. If your password works, can you share the code you are your passwords? Would be great to receive an example for both SHA256 and SHA256+HMAC. Thanks!

Found the answer here:
#928

I think it would be great to link the documentation with issue928 (answer to how to generate a password). The reason is that if someone is looking at a different hasher, such as an online sha256 hasher, the hashed value is not the same.

@Badgerati Badgerati added this to the 2.8.0 milestone Dec 3, 2022
@Badgerati Badgerati moved this to Backlog in 🚀 Pode Roadmap Dec 3, 2022
@Badgerati Badgerati moved this from Backlog to Todo in 🚀 Pode Roadmap Dec 4, 2022
@Badgerati
Copy link
Owner

Documentation updated in #1057. Closing.

@github-project-automation github-project-automation bot moved this from Todo to Done in 🚀 Pode Roadmap Jan 4, 2023
@Badgerati Badgerati mentioned this issue Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants