403 Forbidden Error viewing Swagger API documentation

Product: PowerShell Universal
Version: 2.3.0

Not sure when this started, but I noticed an 403 error when trying to view the API documentation at this URL:
http://localhost:5000/swagger/

It might be worth noting that we have Windows Auth enabled, but I’m pretty sure we’ve been able to access Swagger in previous builds with it enabled.

We started to enforce authentication of the swagger dashboard in 2.3 but not sure why Windows auth wouldn’t work. I’ve opened an issue for this to see if we can get to the bottom of it.

I might need a log. I just tried this locally and can access the swagger docs with Windows Auth enabled.

Let me know if this is enough, I can crank up the log level and reproduce too

2021-09-21T08:04:29.1847840-03:00 0HMBPPIOLV508:00000002 [INF] Request starting HTTP/1.1 GET http://localhost:5000/swagger/ - - (ca22a1cb)
2021-09-21T08:04:29.1855247-03:00 0HMBPPIOLV508:00000002 [INF] AuthenticationScheme: "Negotiate" was forbidden. (212684b8)
2021-09-21T08:04:29.1870112-03:00 0HMBPPIOLV508:00000002 [INF] AuthenticationScheme: "Negotiate" was forbidden. (212684b8)
2021-09-21T08:04:29.1871007-03:00 0HMBPPIOLV508:00000002 [INF] Request finished HTTP/1.1 GET http://localhost:5000/swagger/ - - - 403 0 - 2.3774ms (791a596a)
2021-09-21T08:04:39.9767618-03:00 0HMBPPIOLV509:00000002 [INF] Request starting HTTP/1.1 GET http://localhost:5000/ - - (ca22a1cb)
2021-09-21T08:04:39.9792481-03:00 0HMBPPIOLV509:00000002 [INF] Executing ChallengeResult with authentication schemes ([]). (f3dca807)
2021-09-21T08:04:39.9793160-03:00 0HMBPPIOLV509:00000002 [INF] AuthenticationScheme: "Negotiate" was challenged. (d45f1f38)
2021-09-21T08:04:39.9810421-03:00 0HMBPPIOLV509:00000002 [INF] Executing ChallengeResult with authentication schemes ([]). (f3dca807)
2021-09-21T08:04:39.9810955-03:00 0HMBPPIOLV509:00000002 [INF] AuthenticationScheme: "Negotiate" was challenged. (d45f1f38)
2021-09-21T08:04:39.9811685-03:00 0HMBPPIOLV509:00000002 [INF] Request finished HTTP/1.1 GET http://localhost:5000/ - - - 401 0 - 4.4325ms (791a596a)

Strange. It’s attempting and failing the challenge. You can access the admin console just fine?

Can you try cranking it up to Debug to see if that provides any more information?

Here it is with log level set to Debug

2021-09-21T11:28:01.3767552-03:00 0HMBT1DBDUQKV:00000002 [INF] Request starting HTTP/1.1 GET http://localhost:5000/swagger/ - - (ca22a1cb)
2021-09-21T11:28:01.3768868-03:00 0HMBT1DBDUQKV:00000002 [DBG] AuthenticationScheme: "Negotiate" was not authenticated. (1152f827)
2021-09-21T11:28:01.3771007-03:00 0HMBT1DBDUQKV:00000002 [DBG] The request path "/swagger/" does not match a supported file type (4910e68e)
2021-09-21T11:28:01.3771593-03:00 0HMBT1DBDUQKV:00000002 [INF] AuthenticationScheme: "Negotiate" was forbidden. (212684b8)
2021-09-21T11:28:01.3772599-03:00 0HMBT1DBDUQKV:00000002 [DBG] The request path "/swagger/" does not match a supported file type (4910e68e)
2021-09-21T11:28:01.3772818-03:00 0HMBT1DBDUQKV:00000002 [INF] AuthenticationScheme: "Negotiate" was forbidden. (212684b8)
2021-09-21T11:28:01.3773323-03:00 0HMBT1DBDUQKV:00000002 [DBG] Connection id ""0HMBT1DBDUQKV"" completed keep alive response. (9784cde9)
2021-09-21T11:28:01.3773882-03:00 0HMBT1DBDUQKV:00000002 [INF] Request finished HTTP/1.1 GET http://localhost:5000/swagger/ - - - 403 0 - 0.6574ms (791a596a)

If you auth to the admin console first and then go to the swagger page is it any different or you just can never get to swagger?

I think I might have an idea on how to fix this in the code but it’s weird it doesn’t work for you and works for me.

That does work, I would not have thought to try that :slight_smile:

Ok. Good! Then I know what’s happening. This will be fixed in 2.4 so you’ll be able to go directly to it.

1 Like