Beispiel #1
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            var authHeader = actionContext.Request.Headers.Authorization;

            if (authHeader != null)
            {
                if (authHeader.Scheme == SCHEME)
                {
                    var rawCredentials = authHeader.Parameter;
                    if (AuthHelper.CheckCredentials(rawCredentials))
                    {
                        Thread.CurrentPrincipal = GetClientPrincipal(rawCredentials);
                        ((ApiController)actionContext.ControllerContext.Controller).User = Thread.CurrentPrincipal;
                        return;
                    }
                }
            }

            HandleUnauthorized(actionContext);
        }