protected override bool IsAuthorized(HttpActionContext actionContext) { var headers = actionContext.Request.Headers; var appId = GetHeader(headers, "AppId"); var secrect = GetHeader(headers, "Secrect"); //检验AppId和Secrect var platform = IPlatformManager.GetPlatformByAppSecrect(appId, secrect); if (platform == null) { throw new LoginFaildException("AppId和Secrect不存在!"); } //保存当前请求的用户信息 actionContext.RequestContext.Principal = new ClientPrincipal(platform) { AppId = platform.AppId, }; return(true); }