| | |
| | | using System; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Security.Claims; |
| | |
| | | |
| | | // 验证是否拥有访问模块的权限 |
| | | // 有两种判断方式 一种是通过角色去判断,一种是通过用户去判断 目前暂时不做区分,后续可增加系统参数来进行区分 |
| | | |
| | | //string HModName = actionContext.Request.Headers.GetValues("x-hmodname")?.FirstOrDefault(); |
| | | // if (!string.IsNullOrWhiteSpace(HModName)) // 如果没有配置模组名字段,则默认为不需要鉴权 |
| | | // { |
| | | // //var operateAttr = actionContext.ActionDescriptor |
| | | // //.GetCustomAttributes<ModOperateAttribute>() |
| | | // //.FirstOrDefault(); |
| | | // //if(!string.IsNullOrWhiteSpace(operateAttr.Operate)) |
| | | // //{ |
| | | // //HModName += operateAttr.Operate; |
| | | // //} |
| | | // if (!DBUtility.ClsPub.Security_Log(HModName, 1, false, JWTHelper.getUserName(token))) |
| | | // { |
| | | // HandleForbidden(actionContext); |
| | | // return; |
| | | // } |
| | | // } |
| | | |
| | | |
| | | // 设置用户 |
| | | actionContext.RequestContext.Principal = principal; |
| | | } |
| | |
| | | var response = new HttpResponseMessage(HttpStatusCode.Forbidden); |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "当前角色无权限"; |
| | | objjson.Message = "您没有该模块权限,请与管理员联系!"; |
| | | response.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(objjson), |
| | | System.Text.Encoding.UTF8, "application/json"); |
| | | context.Response = response; |