Shiro 修改权限,刷新权限
shiro 访问鉴权:Realm
AuthorizingRealm->doGetAuthorizationInfo
doGetAuthorizationInfo
protected abstract AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)
Retrieves the AuthorizationInfo for the given principals from the underlying data store. When returning an instance from this method, you might want to consider using an instance of SimpleAuthorizationInfo, as it is suitable in most cases.
Parameters:
principals - the primary identifying principals of the AuthorizationInfo that should be retrieved.
Returns:
the AuthorizationInfo associated with this principals.
See Also:
SimpleAuthorizationInfo
shiro 需要访问数据库查询权限信息。
结合缓存框架,第一次查询权限信息后缓存,在缓存生存期内,访问鉴权使用缓存中的权限信息。
优点:减少数据库查询,缓存快速获取,提升了每次访问效率,减少了数据库压力。
缺点:涉及权限修改,生效会有一个最大缓存生存周期的间隔期。
解决方法:
每次修改权限后,调用 clearCachedAuthorizationInfo 刷新权限:
clearCachedAuthorizationInfo
protected void clearCachedAuthorizationInfo(PrincipalCollection principals)
Clears out the AuthorizationInfo cache entry for the specified account.
This method is provided as a convenience to subclasses so they can invalidate a cache entry when they change an account's authorization data (add/remove roles or permissions) during runtime. Because an account's AuthorizationInfo can be cached, there needs to be a way to invalidate the cache for only that account so that subsequent authorization operations don't used the (old) cached value if account data changes.
After this method is called, the next authorization check for that same account will result in a call to getAuthorizationInfo, and the resulting return value will be cached before being returned so it can be reused for later authorization checks.
If you wish to clear out all associated cached data (and not just authorization data), use the CachingRealm.clearCache(org.apache.shiro.subject.PrincipalCollection) method instead (which will in turn call this method by default).
Parameters:
principals - the principals of the account for which to clear the cached AuthorizationInfo. 示例项目:https://github.com/windwant/spring-dubbo-service https://github.com/windwant/spring-boot-service
Shiro 修改权限,刷新权限的更多相关文章
- 7. 整合shiro,搭建粗粒度权限管理
shiro是一个易用的权限管理框架,只需提供一个Realm即可在项目中使用,本文就将结合上一篇中搭建的权限模块.角色模块和用户模块来搭建一个粗粒度的权限管理系统,具体如下:1. 添加shiro依赖和与 ...
- 将 Shiro 作为应用的权限基础
Shiro 是 Java 世界中新近出现的权限框架,较之 JAAS 和 Spring Security,Shiro 在保持强大功能的同时,还在简单性和灵活性方面拥有巨大优势.本文介绍了 Shiro 的 ...
- mysql修改数据库表权限
ps:通常我用的是:1.“grant all on *.* to root@'%' identified by 'yourpassword';”——这个还可以顺带设置密码.2.“flush privi ...
- 使用Mongodb+Shiro+SpringMVC实现动态权限分配
此次的文档只对Mongodb整合Shiro并且实现动态权限分配做整理,其它的内容以后会补上. 第一步.创建在web.xml中配置 Spring .Shiro shiroFilter 过滤器是用来将请求 ...
- JAVAEE——BOS物流项目11:在realm中授权、shiro的方法注解权限控制、shiro的标签权限控制、总结shiro的权限控制方式、权限管理
1 学习计划 1.在realm中进行授权 2.使用shiro的方法注解方式权限控制 n 在spring文件中配置开启shiro注解支持 n 在Action方法上使用注解 3.★使用shiro的标签进行 ...
- 修改linux文件权限
Linux系统中的每个文件和目录都有访问许可权限,用它来确定谁可以通过何种方式对文件和目录进行访问和操作. 文件或目录的访问权限分为只读,只写和可执行三种.以文件为例,只读权限表示只允许读其内容,而禁 ...
- 60-chmod 修改文件的权限
修改文件的权限 chmod [options] who operator permission file-list (符号模式) chmod [options] mode file-list (绝对模 ...
- chmod修改文件的权限/chown修改文件和目录的所有者
ll指令的显示的信息为(当前目录下只有nameservice1一个目录): drwxr-xr-x 3 hdfs hdfs 4096 4月 14 16:19 nameservice1 上述信息分别表示: ...
- linux 修改目录文件权限,目录文件所属用户,用户组
1:查看命令:ll drwxr-xr-x 4 gamer ftp 4096 Mar 7 16:56 gstore drwxrwxrwx 10 root ftp 4096 De ...
随机推荐
- utils.js文件;一些常用方法的备份
一些常用方法备份: function _(value) { value = '0' + value; return value.substr(value.length - 2); } Date.pro ...
- Mybatis Plus启动注入 SQL 原理分析
1) 问题: xxxMapper 继承了 BaseMapper<T>, BaseMapper 中提供了通用的 CRUD 方法, 方法来源于 BaseMapper, 有方法就必须有 SQL, ...
- 使用Apache HttpClient 4.x发送Json数据
Apache HttpClient是Apache提供的一个开源组件,使用HttpClient可以很方便地进行Http请求的调用.自4.1版本开始,HttpClient的API发生了较大的改变,很多方法 ...
- 【luogu P1955 [NOI2015]程序自动分析】 题解
题目链接:https://www.luogu.org/problemnew/show/P1955 并查集操作,1e9要离散化,数组要开大一些,操作前先执行合并操作 样例好毒啊(全是排好序的) #inc ...
- SDWebImage的一些简单使用
SDWebImage是一个三方类库, 所以要使用它首先要把它引入我们的工程, 其托管在github上: https://github.com/rs/SDWebImage 有几种引入的方法, 一种是直接 ...
- DataFrame概念与创建
一 概念 Pandas是一个开源的Python数据分析库.Pandas把结构化数据分为了三类: Series,1维序列,可视作为没有column名的.只有一个column的DataFrame: Dat ...
- IIS - 虚拟目录与应用程序的异同
在Windows 7 IIS7中,对服务器建立站点后,有二种添加子站点的方式 A. 虚拟目录 B. 应用程序 简单总结下二者之间的异同 A.虚拟目录 虚拟目录是指在站点下建立一个虚拟子目录 ...
- linux内核追踪(trace)(QEMU+gdb)
1.引言 Linux内核是一个很大的模块,如果只是看源码有时会难以理解Linux内核的一些代码设计情况,如果可以结合Linux内核运行同时阅读源码再好不过,本文大致介绍Linux内核追踪方式,采用工具 ...
- MVC 当中 [ValidateAntiForgeryToken] 的作用
ValidateAntiForgeryToken 防止CSRF(跨网站请求伪造) 用途:防止CSRF(跨网站请求伪造). 用法:在View->Form表单中:<%:Html.AntiFo ...
- 01迷宫题解(bfs,联通块)
题目https://www.luogu.org/problemnew/show/P1141 这个题解主要针对我个人出现的一些问题和注意的地方. 解题思路 首先说一下联通块 联通块这个比较抽象,举个例子 ...