Is it possible to use the AllowAnonymous
attribute with Windows Azure AD?
I need a part of my web api to be anonymous, but not the actual website.
Any ideas?
Is it possible to use the AllowAnonymous
attribute with Windows Azure AD?
I need a part of my web api to be anonymous, but not the actual website.
Any ideas?
Ok, I could solve it by choosing in the Identity and Access windows that the auth should go in a controller. Then I added this code:
CustomAuthorize
This attribute goes now in my
FilterConfig
And in my web.config I added this
passiveRedirectEnabled="false"
inconfiguration/system.identityModel.services/federationConfiguration/wsFederation
that works perfect :)Azure AD does not need to support anonymous auth for you to be able to use the AllowAnonymous attribute in your WebAPI.
I believe what you desire is unauthenticated access to some controllers of the WebAPI. It is possible. See this .Net sample: https://github.com/AzureADSamples/WebAPI-ManuallyValidateJwt-DotNet/blob/master/TodoListService-ManualJwt/Global.asax.cs. It validates the token and sets the Thread.CurrentPrincipal if the token is valid and returns an error if it can't find a token.
For your WebAPI - you wont return an error here - but instead not set the Thread.CurrentPrincipal when no token is present. - then you will decorate your controllers with Authorize and AllowAnonymous attributes to disallow or allow anonymous access.
Hope this helps.
PS: Down vote wasn't mine :-)