Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
843 stars 91 forks source link

Set-PodeOAGlobalAuth failure on launch #1406

Open tylrtrst opened 1 day ago

tylrtrst commented 1 day ago

Describe the Bug

After upgrading from 2.10.1 to 2.11.0, Pode fails to launch and outputs the following error to console:

Pode v2.11.0 (PID: 1)
Set-PodeOAGlobalAuth: /usr/local/share/powershell/Modules/Pode/Public/Authentication.ps1:1645
Line |
1645 |      Set-PodeOAGlobalAuth -DefinitionTag $DefinitionTag -Name $Authent …
     |                                          ~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'DefinitionTag' because it is an empty
     | string.

reverting back to 2.10.1 corrects the problem.

Steps To Reproduce

Update from 2.10.1 to 2.11.0 Run Pode View console

Expected Behavior

Expecting Pode to launch without error

Platform

Additional Context

I am not making use of the OpenAPI feature and have not enabled it. I have defined 2 auth schemes, both of type: API Key. Only one of which is being applied via middleware.

mdaneri commented 1 day ago

I’m not able to reproduce the issue can you please give a sample?

tylrtrst commented 1 day ago

I've been doing some work to narrow down the problem: In my case it appears to show up when an auth scheme is applied via auth middleware.

Troubleshooting Steps:

Structure:

My scheme is added via Use-PodeAuth -path './podeAuth' in my configuration and then applied with:

Add-PodeAuthMiddleware -Name 'globalAuthValidation' -Authentication 'authenticateExample' -Route '/api/*'

Example scheme as tested:

file: ./podeAuth/authenticateExample.ps1

New-PodeAuthScheme -ApiKey | Add-PodeAuth -Name 'authenticateExample' -Sessionless -ScriptBlock {
    param($key)
        return $null
}
mdaneri commented 1 day ago

Let me try it

mdaneri commented 21 hours ago

I'm able to reproduce it. Workaround: Add a server.psd1 file with at least this content:

@{
    Web    = @{
        OpenApi     = @{
        }
    }
}
tylrtrst commented 16 hours ago

I can confirm that the issue is fixed for me after applying the above workaround. Thanks for the quick responses, and your work on this project!