aspnet / AspNetKatana

Microsoft's OWIN implementation, the Katana project
Apache License 2.0
967 stars 334 forks source link

LoginPath directs to port 80 when redirecting user to login #361

Closed ShovelHand closed 4 years ago

ShovelHand commented 4 years ago

Pardon me, I'm not sure what I've missed here. This became an issue recently after months of working as expected. We have an OAuth flow set up between a Gmail Add-on we wrote, and our resource server. When an unauthorized user tries to connect, things go as expected until our Authorize method in OAuthController (just like in the example documentation) returns an HttpUnauthorizedResult, at which point the login view should get displayed, but instead a 404 error is shown. According to the error message shown by IIS, the requested URL is http://localhost:80/Account/Login, but our server is not running on port 80. Our LoginPath is defined in Startup.Auth.cs as "/Account/Login": app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Application", AuthenticationMode = AuthenticationMode.Passive, LoginPath = new PathString("/Account/Login"), LogoutPath = new PathString("/Account/Logout"), });

So I guess my question is what is happening between the HttpUnauthorizedResult being returned, and the server attempting to fetch the LoginView? I've had a good pour through all the documentation I can find, but I'm completely confused as to why my server is trying to return any view from port 80. I've reverted to previous releases of our code base and still hand the same problem, so I'm suspicious that some update to Visual Studio or some other bit of infrastructure is to blame, but that's a complete guess. I am using IIS version 10 and Visual Studio Professional 2019 version 16.6.2 Please let me know what other information would be helpful.

Tratcher commented 4 years ago

Can you capture and share a network trace using Fiddler to show the flow?

You say the server isn't listening on port 80. Where is it listening, 443 (https)? Are there any proxies involved?

ShovelHand commented 4 years ago

Hi, Chris. Sorry to leave you hanging. I deleted my local copy of the source code and pulled from our repo. Now I'm getting lots of errors from Owin.Loader.Default loader that some Googling suggests may be the result of some reference passing a date in a bad format or something like that, so I'm currently looking into that. It may be appropriate to close this issue.