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

推荐订阅源

云风的 BLOG
云风的 BLOG
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
博客园 - 司徒正美
美团技术团队
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
U
Unit 42
T
Tailwind CSS Blog
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Google DeepMind News
Google DeepMind News
H
Help Net Security
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Y
Y Combinator Blog
罗磊的独立博客
D
DataBreaches.Net
有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
博客园_首页
博客园 - 三生石上(FineUI控件)
G
Google Developers Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
博客园 - Franky
M
MIT News - Artificial intelligence
B
Blog
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
S
SegmentFault 最新的问题
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - lodestar

一张图掌握数据存储 使用xtrabackup实现mysql定时热备份 开发篇1:使用原生api和Langchain调用大模型 预热篇2:从RNN到Transformmer 预热篇1:大模型训练显卡选型 macbook安装scala、hadoop、saprk环境 centos6.5 squid安装 一次linux服务器黑客入侵后处理 linux上搭建svn服务器 Windows系统下Oracle每天自动备份 android中listView的几点总结 使用template method模式简化android列表页面 andorid进度条使用 andorid定时器应用 - lodestar Android网络应用(第一部分) - lodestar 错误数据导致java.lang.IllegalArgumentException:Unsupported configuration attributes 使用ACEGI搭建权限系统:第三部分 使用ACEGI实现权限控制,第一部分 ajax实现用户名存在校验
acegi安全框架使用:第二部分
lodestar · 2011-12-31 · via 博客园 - lodestar

二、dbms实现鉴权
1.dbms鉴权,修改FilterSecurityInterceptor中的objectDefinitionSource属性,注入rdbmsFilterInvocationDefinitionSource,可加入Ehcahe提高性能
<!-- 权限过滤,基于URL的过滤器,使用RDBMS和Ehcache实现 -->
 <bean id="securityInterceptor"
  class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
  <!-- 修改默认值,防止没有授权的角色导致的错误 -->
  <property name="validateConfigAttributes" value="true" />
  <property name="authenticationManager" ref="authenticationManager" />
  <property name="accessDecisionManager" ref="accessDecisionManager" />
  <property name="objectDefinitionSource" ref="rdbmsFilterInvocationDefinitionSource" />
 </bean>
 <bean id="rdbmsFilterInvocationDefinitionSource" class="com.hengtian.security.RdbmsFilterInvocationDefinitionSource">
  <property name="dataSource" ref="dataSource" />
  <property name="webresdbCache" ref="webresCacheBackend" />
 </bean>
 
 <bean id="webresCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  <property name="cacheManager" ref="cacheManager" />
  <property name="cacheName">
   <value>webresdbCache</value>
  </property>
 </bean>

RdbmsFilterInvocationDefinitionSource是objectDefinitionSource的dbms实现,这个要自己实现


2.aop实现方法过滤
 如果不想对action,url等资源过滤,也可对调用方法过滤,实现特定角色只能实现特定方法。在applicationContext.xml中配置,注意这里是用BeanNameAutoProxyCreator实现aop的.
  <bean id="serviceSecurityInterceptor"
  class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
  <property name="validateConfigAttributes" value="true" /> <property
  name="authenticationManager" ref="authenticationManager" /> <property
  name="accessDecisionManager" ref="accessDecisionManager" /> <property
  name="objectDefinitionSource"> <value>
  com.role.action.RoleAction.operateRole=ROLE_ADMIN </value> </property>
  </bean>
 

 <bean id="serviceSecurityInterceptor"
  class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
  <property name="validateConfigAttributes" value="true" />
  <property name="authenticationManager" ref="authenticationManager" />
  <property name="accessDecisionManager" ref="accessDecisionManager" />
  <property name="objectDefinitionSource" ref="rdbmsMethodDefinitionSource" />
 </bean>
 <bean id="rdbmsMethodDefinitionSource" class="com.hengtian.security.RdbmsMethodDefinitionSource">
  <property name="dataSource" ref="dataSource" />
  <property name="webresdbCache" ref="webresCacheBackend" />
 </bean>
 <bean id="webresCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  <property name="cacheManager" ref="cacheManager" />
  <property name="cacheName">
   <value>webresdbCache</value>
  </property>
 </bean>

 <bean id="autoProxyCreator"
  class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  <property name="interceptorNames">
   <list>
    <value>serviceSecurityInterceptor</value>
   </list>
  </property>
  <property name="beanNames">
   <list>
    <value>*Action</value>
   </list>
  </property>
 </bean>

3.表结构设置
 按照常规的权限模型设计:用户表、角色表、用户角色关系表、角色功能关系表;系统表、模块表、菜单表、按钮表、按钮资源表(在一个操作做个url的情况使用)
 权限这块的表结构所有的系统都查不多,这里只是在功能表里面多加上了url字段。对外显示为特定角色有执行某模块、某菜单、界面中的某个按钮的权限,对内则是某个角色和action的映射关系供acegi鉴权使用