owin self-host with windows authentication - AllowAnonymous not working

北城以北 提交于 2019-12-13 03:09:58

问题


I've enabled Windows authentication as described here

It all works fine, there's just a tiny issue: Doing so makes every controller method protected by windows authentication. NO problem I thought, just use the [AllowAnonymous] adorner on the few controller methods where anonymous access is okay, but that won't work.

Is there any way to get the self-host to not authorized every method on every controller?


回答1:


You have to enable Windows auth and anonymous auth. documentation. As is, you have told Owin to require Windows auth and disallow anything else.

In the code you cited, you would change this:

listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication 
                               | AuthenticationSchemes.Anonymous;


来源:https://stackoverflow.com/questions/45485454/owin-self-host-with-windows-authentication-allowanonymous-not-working

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