Sending large POST requests with integrated Windows authentication in OWIN self-host

廉价感情. 提交于 2020-02-05 06:16:06

问题


I'm trying to set up an endpoint for authenticated HTTP POST requests that will handle requests whose bodies sit at around 15 kB.

I followed the description on MSDN and defined

var httpListener = (OwinHttpListener) appBuilder.Properties[typeof(OwinHttpListener).FullName];
httpListener.Listener.AuthenticationSchemeSelectorDelegate = request =>
    request.HttpMethod == "POST"
        ? AuthenticationSchemes.IntegratedWindowsAuthentication
        : AuthenticationSchemes.Anonymous;

in my Startup.Configuration. This works like a charm for smaller requests, but I end up with HTTP 400 Bad Requests the moment I try to send through a request with a body size of about 15 kB. To test this, I'm using

curl -v --ntlm --negotiate -u {username}:{password} -d @myfile.txt http://localhost:8080/my-endpoint

where myfile.txt is about 15 kB. At first, I assumed this was an issue about Content-Length being limited and implemented the middleware suggested in this answer to change the limit; this was a red herring, though, as the middleware ends up being invoked only for smaller requests. Indeed, if I get rid of the authentication entirely, everything works as expected.

Moreover, if I use AuthenticationSchemes.Ntlm instead of AuthenticationSchemes.IntegratedWindowsAuthentication, then the curl request does goes through without any issues, so I have a functioning workaround, but I am still curious what is causing the issue in the first place, and if there is a workaround that doesn't rely on falling back to NTLM.

来源:https://stackoverflow.com/questions/59707967/sending-large-post-requests-with-integrated-windows-authentication-in-owin-self

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