I am working on converting WebAPI endpoints to Azure Functions. Our WebApi has several user attributes that handle authentication, how do I convert them to Azure Functions?
As an example, here is the AuthorizeAttribute attribute:
public class MyAuthorizationAttribute : AuthorizeAttribute
{
public override async Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
{
if (!AuthorizationHelper.SkipAuthorization(actionContext))
{
HttpContext.Current.User = principal;
await base.OnAuthorizationAsync(actionContext,cancellationToken);
}
}
}
In WebAPI: HttpContext.Current.Userto get the caller In Azure Function: no HttpContext
source
share