ASP.NET Core web app URL is case-sensitive when authenticating users

落花浮王杯 提交于 2020-01-25 04:43:27

问题


I have a test ASP.NET Core 2.0 web application that authenticates the user using SAML. All is well if the URL typed in the browser matches the case of the web app name in IIS 10 (ex. .../MyTestSite). However, if the user types a different case (ex. .../mytestsite) they will fail to authenticate.

In code, the point of failure is in the OnGetCallbackAsync method of the ExternalLogin class at this line:

var info = await _signInManager.GetExternalLoginInfoAsync();

Since info == null in these cases the user is redirected back to the login page.

I have noticed that the .AspNetCore.Antiforgery token has the path value from the url (/mytestsite) but Identity.External path value is the site name (/MyTestSite).

I'm not sure why this happens or why case would even matter.


回答1:


(Assuming you are using Authentication Schemes)

By default all authentication schemes are case sensitives that is why it matches case while authenticating. If you want to make URL case insensitive you can add routing options like this:

services.Configure<RouteOptions>(options => options.LowercaseUrls = true);

Note: This will provide support of URLs but you can try this.

Hope this helps!



来源:https://stackoverflow.com/questions/54245265/asp-net-core-web-app-url-is-case-sensitive-when-authenticating-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!