shiro

shiro之缓存

独自空忆成欢 提交于 2019-11-26 23:38:16
1 细说shiro之七:缓存:https://www.cnblogs.com/nuccch/p/8044226.html 2 Shiro缓存使用Redis、Ehcache、自带的MpCache实现的三种方式实例:https://www.cnblogs.com/zfding/p/8536480.html 3 Shiro缓存(十三) - QiaoZhi - 博客园:https://www.cnblogs.com/qlqwjy/p/7257653.html 4 shiro-redis实现session存储到redis - QiaoZhi - 博客园:https://www.cnblogs.com/qlqwjy/p/10392268.html 5 SpringBoot搭建基于Apache Shiro+Redis的分布式Session共享功能 - nbfujx - 博客园:https://www.cnblogs.com/nbfujx/p/7773833.html 来源: https://www.cnblogs.com/xy-ouyang/p/11335400.html

How to easily implement “who is online” in Grails or Java Application?

丶灬走出姿态 提交于 2019-11-26 22:44:45
问题 I am building a community website in grails (using Apache Shiro for security and authentication system) and I would like to implement the feature "who is online?". This url http://cksource.com/forums/viewonline.php (see snapshot below if you do not have acess to this Url) gives an example of what I would like to achieve. How can I do that in the most simple way? Is there any existing solution in Grails or in Java ? Thank you. Snapshot : Snapshot of Who is online page http://www

SpringBoot2.0集成Shiro

混江龙づ霸主 提交于 2019-11-26 20:49:46
1、shiro的三个核心概念:   1)Subject:代表当前正在执行操作的用户,但Subject代表的可以是人,也可以是任何第三方系统帐号。当然每个subject实例都会被绑定到SercurityManger上。   2)SecurityManger:SecurityManager是Shiro核心,主要协调Shiro内部的各种安全组件,这个我们不需要太关注,只需要知道可以设置自定的Realm。   3)Realm:用户数据和Shiro数据交互的桥梁。比如需要用户身份认证、权限认证。都是需要通过Realm来读取数据。 2、springboot中集成shiro相对简单,只需要两个类:一个是ShiroConfig类,一个是自定义Realm类。   1)ShiroConfig类:shiro的一些配置,相对于之前的xml配置。包括: ShiroFilter 的配置,密码加密的算法,支持注解的配置等功能。   2)自定义Realm类:继承AuthorizingRealm。并且重写父类中的doGetAuthorizationInfo(权限认证)、doGetAuthenticationInfo(身份认证)这两个方法。 3、demo   项目结构:      依赖: <dependency> <groupId>org.apache.shiro</groupId> <artifactId

54-Shiro-3

馋奶兔 提交于 2019-11-26 19:24:44
1.授权 Subject Resource Permission Role 关于授权这一块,按照前后端分离的概念,我们在后台里面不再进行权限设置,而是进行权限查询或者搞权限缓存,但是道理是一样的,后天不搞,前端肯定要搞,前端要搞授权,肯定也是有res,permission,role的设置 2.关于一系列的权限注解 @RequireRoles等,这些全部都是前端来写。。这里就不看了 3.shiro会话管理 功能=> 会话管理,会话时间监听,会话存储/持久化,容器无关的集群,失效/过期支持,对web的透明支持,SSO单点登录的支持 下面详细来看: ①Subject.getSession(true/false)创建session ②session.getId() ③session.getHost() ④session.getTimeout(),session.setTimeout() ⑤session.getStartTimestamp(),sesson.getLastAccessTime();还有session.touch()会更新最后访问时间,session.stop()销毁session ⑥属性操作,sesson有getAttribute,setAttribute,removeAttribute ⑦SessionListener:session的监听器

aise5

跟風遠走 提交于 2019-11-26 19:12:26
1. 授权从数据库查询权限(掌握) 查询出所有数据权限 对登录用户权限处理 根据用户的ID拿到权限 根据登录用户查询用户权限 自定义权限拦截器 (1)shiro把所有的权限从数据库查询出来 (2)当前用户的它具备的权限查询出来交给shiro管理 (3)当我们来访问的时候,根据url(key) --去shiro是否有对应的value (shiro里面做判断处理,如果 发现你没有权限,返回的没有权限的页面) 2.如果没有权限返回权限页面 不能适用ajax(掌握) 我们重写shiro 的权限拦截器 PermissionsAuthorizationFilter (1)写一个类去继承PermissionsAuthorizationFilter (2)覆写处理失败的方法 ​ 判断如果是ajax 就返回对应的json字符串 ​ 否则返回原来的页面 3.菜单操作 从数据读取出菜单,每个人的菜单都不一样; 在页面展示的菜单的json 需要自己去构造出来; [外链图片转存失败(img-mPp5YwzW-1565398185638)(C:\Users\0427\AppData\Roaming\Typora\typora-user-images\1565330778275.png)] Menu里面 – 配置parent --配置children 发送sql 查询数据库菜单 @Query ( "select

day5权限与菜单

谁都会走 提交于 2019-11-26 17:55:48
权限的判断: 1.shiro根据登录的用户名把所有的权限从数据库查询出来 //通过用户主体ID查询数据库权限Set<String> permissionsByLoginUser = iPermissionService.findPermissionsByLoginUser(employee.getId()); 2.当前用户具备的权限查询出来交给shiro管理 SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(); 3.把查询出来的结果放在map集合里面 //查询出所有权限List<Permission> all = iPermissionService.findAll();for (Permission permission : all) { String url = permission.getUrl(); String sn = permission.getSn(); mp.put(url, "perms["+sn +"]");} 3当我们来访问的时候,根据url(key) --去shiro是否有对应的value (shiro里面做判断处理,如果 发现你没有权限,返回的没有权限的页面) 复写底层的方法解决 @Overrideprotected boolean

Jeecg-Boot 2.0 版本发布,基于Springboot+Vue 前后端分离快速开发平台

こ雲淡風輕ζ 提交于 2019-11-26 16:37:21
目录 Jeecg-Boot项目简介 源码下载 升级日志 Issues解决 v1.1升级到v2.0不兼容地方 系统截图 Jeecg-Boot项目简介 Jeecg-boot 是一款基于代码生成器的智能开发平台!采用前后端分离技术:SpringBoot,Mybatis,Shiro,JWT,Vue & Ant Design。提供强大的代码生成器, 前端页面和后台代码一键生成,不需要写任何代码,保持jeecg一贯的强大,绝对是全栈开发者福音!! JeecgBoot的宗旨是降低前后端分离的开发成本,提高UI能力的同时提高开发效率,追求更高的能力,No代码概念,一系列智能化在线开发。 源码下载 源码: https://github.com/zhangdaiscott/jeecg-boot 在线演示: http://boot.jeecg.org 文档: http://jeecg-boot.mydoc.io 入门必看: http://jeecg-boot.mydoc.io/?t=345660 QQ群: 284271917 升级日志 本版本JAVA后台项目拆分成maven多模块module模式,前端UI封装各种组件和报表控件,增加很多高级功能示例: java项目结构重构,采用maven多模块module构建 数据库兼容专项改造工作,支持mysql、oracle、SqlServer提供了对应脚步

Apache Shiro

假装没事ソ 提交于 2019-11-26 14:53:33
10 Minute Tutorial on Apache Shiro:http://shiro.apache.org/10-minute-tutorial.html 1、What is Apache Shiro?   Apache Shiro is a powerful and easy to use Java security framework that offers developers an intuitive yet comprehensive solution to authentication, authorization, cryptography, and session management.   Shiro:java安全框架,提供认证、授权、加密和回话管理。   获取当前用户: Subject currentUser = SecurityUtils.getSubject();   获取用户session: Session session = currentUser.getSession(); session.setAttribute( "someKey", "aValue" );   用户认证: if ( !currentUser.isAuthenticated() ) { //collect user principals and credentials

Shiro权限管理框架(三):Shiro中权限过滤器的初始化流程和实现原理

孤街醉人 提交于 2019-11-26 12:08:37
本篇是Shiro系列第三篇,Shiro中的过滤器初始化流程和实现原理。Shiro基于URL的权限控制是通过Filter实现的,本篇从我们注入的 ShiroFilterFactoryBean 开始入手,翻看源码追寻Shiro中的过滤器的实现原理。 初始化流程 ShiroFilterFactoryBean 实现了FactoryBean接口,那么Spring在初始化的时候必然会调用ShiroFilterFactoryBean的getObject()获取实例,而ShiroFilterFactoryBean也在此时做了一系列初始化操作。 关于FactoryBean的介绍和实现方式另外也记了一篇: https://www.guitu18.com/post/2019/04/28/33.html 在getObject()中会调用createInstance(),初始化相关的东西都在这里了,代码贴过来去掉了注释和校验相关的代码。 protected AbstractShiroFilter createInstance() throws Exception { SecurityManager securityManager = getSecurityManager(); FilterChainManager manager = createFilterChainManager();