惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
大猫的无限游戏
大猫的无限游戏
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Jina AI
Jina AI
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
Last Week in AI
Last Week in AI
The Cloudflare Blog
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 叶小钗
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recorded Future
Recorded Future
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
罗磊的独立博客
雷峰网
雷峰网
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
小众软件
小众软件
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Announcements
Recent Announcements
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
量子位
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
宝玉的分享
宝玉的分享
D
DataBreaches.Net
T
The Exploit Database - CXSecurity.com
Vercel News
Vercel News
IT之家
IT之家
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
aimingoo的专栏
aimingoo的专栏

博客园 - craboYang

JVM: can not create native thread SqlInXml 动态配置化 ElasticSearch5集群部署指南 Solr5 DataImport 处理1对多关系 C# XMPP客户端与openfire通信(Matrix Xmpp 授权破解教程) 响应式编程 Part.01 (Layout and MVVM) Mono.Ceil 无法保存Silverlight 程序集 基于system.diagnostics Trace的日志输出 Dappers 开发入门 (5) - 缓存 Dappers 开发入门 (4) - 明细编辑 Dappers 开发入门(3)- 列表界面 Dappers 开发入门(2) - Mapping Dappers 开发入门(1) - 接口 Dappers : 基于Dapper.net 扩展的Dao - Part II Dappers : 基于Dapper.net 扩展的Dao B/S页面 通用权限控制(2) B/S页面 通用数据权限控制 由于ContractFilter在EndpointDispatcher不匹配,因此Action为<BtsActionMapping...的消息无法在接收方处理 - craboYang - 博客园 WinForm DataGridView 绑定后仅显示许多空行和空格
注解式功能权限控制机制
craboYang · 2017-02-10 · via 博客园 - craboYang
  1. 权限定义表:  定义一个SysUser.GetAclMap 的方法, 返回的是[{code,name}, {code2,name2} ...] 的json结构。
    在功能权限中, code对应url, 而name则是当前用户是否拥有权限: null 没有; Y 有权限.
  2. 在Controller中配置Authorize注解, 可以在class上定义, 也可以在action中定义
    通过order控件校验顺序
  3. 通过actionKey指定
  4. 权限验证方式:
    1. 验证当前ActionKey是否存在于“权限定义表”    (ContainsKey)
      1. --Yes , 判断权限定义表中, 用户授权值(get): null  (未授权),或者not null (已授权)
      2. -- No,  认定为无需校验项, 返回 (已授权)
    2. 如果Action未定义Authorize注解, 则向上使用Controller上的Authorize注解定义。
    3. Authorize可以定义 order和actionKey, 实现重定向的检测。
       如页面功能:列表页, 编辑页, 保存, 删除。  
          为删除Action设定  一组order{ 保存, 编辑页  } 。 由于首先总是检测当前action, 所以等同于 order={ 删除, 保存, 编辑页  }
      1. 检测权限  “删除” , 若已ContainsKey, 直接返回 授权值。   若未定义, 继续向下执行;
      2. 检测权限 “保存” , 若已ContainsKey,  直接返回 授权值。   若未定义, 继续向下执行;
      3. 检测权限 “编辑页” , 若已ContainsKey,  直接返回 授权值。   若未定义, 继续向下执行;
      4. 认定无需校验, 返回 (已授权)
  5. 若要禁用当前Action的权限检测
    1. 在action上设置 order=-1 且action=""
  6. 最后, 为启用以上功能, 在jfinal 启动时配置:

    public void configInterceptor(Interceptors me) {
              me.addGlobalActionInterceptor(new AuthorityValidateInterceptor());//进行所有Action与权限配置表的匹配检测
              me.addGlobalActionInterceptor(new ControllerInViewInterceptor());//允许FreeMaker访问到session的值
    }

注意: 权限项设置(菜单定义)时, 不得将 /portal/user/index 简写为 /portal/user/ 否则导致权限判断为“无权限”。导致排查困难。