Example #1
0
 public void OwinContextShouldBeCreatedFromHttpRequestMessage()
 {
     using (var request = new HttpRequestMessage())
     {
         request.Properties.Add("MS_OwinEnvironment", new Dictionary <string, object>());
         var owinAccessor = new HttpRequestMessageOwinContextAccessor(request);
         Assert.IsNotNull(owinAccessor.Context);
     }
 }
        /// <inheritdoc />
        protected override bool IsAuthorized(HttpActionContext actionContext)
        {
            if (actionContext == null)
            {
                throw new ArgumentNullException(nameof(actionContext));
            }

            var controller   = actionContext.ControllerContext.Controller as IAuthorizationController;
            var user         = (ClaimsPrincipal)actionContext.RequestContext.Principal;
            var owinAccessor = new HttpRequestMessageOwinContextAccessor(actionContext.Request);
            var helper       = new AuthorizationHelper(owinAccessor);

            return(helper.IsAuthorizedAsync(controller, user, this, actionContext).Result);
        }