ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
34 stars 2 forks source link

Endpoint testing returns 401 ClientError when testing from GUI with Authentication Enabled #3483

Closed RockoTheeHut closed 1 month ago

RockoTheeHut commented 1 month ago

Version

5.0.0-rc2

Severity

Low

Environment

msi

Steps to Reproduce

Create a basic GET endpoint that returns a dummy object. If Authentication is disabled, it works. If you add Authentication, no matter if you add roles or leave blank, the Test tab Invoke returns '401 ClientError'.

I can not find logs with the error.

Expected behavior

Authentication is inherited from the browser session and works

Actual behavior

401 error

Additional Environment data

Windows Server 2019, MSI, SQL Server 2022 back end, MS Entra OIDC. I have tried with environments and without environments.

Screenshots/Animations

image image

adamdriscoll commented 1 month ago

I noticed this too. It's kinda by design but we should have an easy way to use the current user's authentication and authorization.

One reason it's like this is so that you could use another user's authorization\authentication to do some tests to make sure it's been configured properly. Right now, you'd have to set the headers and app tokens and stuff and it's just not very straight forward.

RockoTheeHut commented 1 month ago

Completely understand. I think up front it would be ideal to default to the current users auth.

Looking forward it would be nice to also have something like a dropdown to quickly choose what role/token to run under. Or a way to add testing configurations per user where a user could create auth tokens, or be assigned auth tokens, with a unique name that you could quickly choose in a dropdown for testing. Something like that... The option for adding custom headers is pretty awesome, but we won't have need of that very often.

adamdriscoll commented 1 month ago

Totally agree. I'll at least get the default auth in for 5.0 GA. If it's easy enough to put in some additional controls I might sneak it in but might be a 5.1 thing.

adamdriscoll commented 1 month ago

image

This was pretty easy to get in. I just added an authentication tab that allows you to set a user name and set of roles.