shiro

Shiro权限验证说明

百般思念 提交于 2019-12-04 13:20:06
1、简介 shiro是一个安全框架,是Apache的一个子项目。shiro提供了:认证、授权、加密、会话管理、与web集成、缓存等模块。 1.1、模块介绍 Authentication:用户身份识别,可以认为是登录; Authorization:授权,即权限验证,验证某个已认证的用户是否拥有某个权限;即判断用户是否能做事情,常见的如:验证某个用户是否拥有某个角色。或者细粒度的验证某个用户对某个资源是否具有某个权限。 Session Manager:会话管理,即用户登录后就是一次会话,在没有退出之前,它的所有信息都在会话中;会话可以是普通 JavaSE 环境的,也可以是如 Web 环境的。 Cryptography:加密,保护数据的安全性,如密码加密存储到数据库,而不是明文存储。 Web Support:Web支持,可以非常容易的集成到 web 环境。 Caching:缓存,比如用户登录后,其用户信息、拥有的角色/权限不必每次去查,这样可以提高效率。 Concurrency:shiro 支持多线程应用的并发验证,即如在一个线程中开启另一个线程,能把权限自动传播过去。 Testing:提供测试支持。 Run As:允许一个用户假装为另一个用户(如果他们允许)的身份进行访问。 Remember Me:记住我,这个是非常常见的功能,即一次登录后,下次再来的话不用登录了。 注意

Apache Shiro credentials based security for Rest service

我是研究僧i 提交于 2019-12-04 12:29:56
问题 I'm creating a App using Shiro as the security framework. The app have two parts; Web and Rest. The Web is using Shiro's default FormAuthenticationFilter . I'm happy with the session based approach. The stand alone app which is using Rest, I want to limit from using the FormAuthenticationFilter and from creating a session, which I'm able to do via shiro.ini file I need to implement credentials based security on the rest service. Browsing on the web I saw some blogs suggesting that you create

Configuring Apache Shiro with Google Guice Servlet

空扰寡人 提交于 2019-12-04 10:51:09
问题 I'm starting to use Guice/Shiro instead of Spring/Spring Security. I have looked examples from Shiro site, and all configuration examples are made as INI-file examples. Is it possible to configure Shiro in plain Java, as Guice Servlets are meant to be configured? 回答1: Yes it is possible, but requires some glue code if you want Guice to create your Realms. Bind Realm implementation: bind(Realm.class).to(MyRealm.class).in(Singleton.class); Bind WebSecurityManager: @Provides @Singleton

Spring service with cacheable methods gets initialized without cache when autowired in Shiro realm

两盒软妹~` 提交于 2019-12-04 10:44:21
After spending 2 days on this issue I really can't make any more progress on my own. I am working on a standard web application with Spring for dependency injection and the likes. I am also using Spring to cache several expensive methods I use a lot. After I introduced Apache Shiro for the security layer, I was experiencing a strange issue where @Cacheable methods in a certain service no longer got cached. To this point, I was able to strip the problem down to its core, but there's still a lot of code for you to look at - sorry for that... First, I configure all relevant packages (all classes

web应用安全框架选型:Spring Security与Apache Shiro

岁酱吖の 提交于 2019-12-04 10:26:50
一、 SpringSecurity 框架简介 官网: https://projects.spring.io/spring-security/ 源代码: https://github.com/spring-projects/spring-security/ Spring Security 是强大的,且容易定制的,基于Spring开发的实现认证登录与资源授权的应用安全框架。 SpringSecurity 的核心功能: Authentication:认证,用户登陆的验证(解决你是谁的问题) Authorization:授权,授权系统资源的访问权限(解决你能干什么的问题) 安全防护,防止跨站请求,session 攻击等 二、比较一下shiro与Spring Security 目前在java web应用安全框架中,与Spring Security形成直接竞争的就是shiro,二者在核心功能上几乎差不多,但从使用的角度各有优缺点。笔者认为:没有最好的,只有最合适的。 2.1 用户量 从使用情况上看,二者都在逐步提高使用量。shiro的使用量一直高于spring security. 2.2.使用的方便程度 通常来说,shiro入门更加容易,使用起来也非常简单,这也是造成shiro的使用量一直高于Spring Security的主要原因。但是从笔者的角度来看,二者其实都简单,我说说我的理由:

web应用安全框架选型:Spring Security与Apache Shiro

不羁岁月 提交于 2019-12-04 10:16:19
一、 SpringSecurity 框架简介 官网: https://projects.spring.io/spring-security/ 源代码: https://github.com/spring-projects/spring-security/ Spring Security 是强大的,且容易定制的,基于Spring开发的实现认证登录与资源授权的应用安全框架。 SpringSecurity 的核心功能: Authentication:认证,用户登陆的验证(解决你是谁的问题) Authorization:授权,授权系统资源的访问权限(解决你能干什么的问题) 安全防护,防止跨站请求,session 攻击等 二、比较一下shiro与Spring Security 目前在java web应用安全框架中,与Spring Security形成直接竞争的就是shiro,二者在核心功能上几乎差不多,但从使用的角度各有优缺点。笔者认为:没有最好的,只有最合适的。 2.1 用户量 从使用情况上看,二者都在逐步提高使用量。shiro的使用量一直高于spring security. 2.2.使用的方便程度 通常来说,shiro入门更加容易,使用起来也非常简单,这也是造成shiro的使用量一直高于Spring Security的主要原因。但是从笔者的角度来看,二者其实都简单,我说说我的理由:

Passing Values to Enumerated Properties in Shiro ini

一笑奈何 提交于 2019-12-04 10:15:18
I am using the JDBC Realm and storing authentication data in SQL. I am storing the salt in the users table and relying on the DEFAULT_SALTED_AUTHENICATION_QUERY. To invoke that query I must set the SaltStyle. Therefore, I need to pass the SaltStyle.COLUMN enumerated value to JdbcRealm through the INI. SaltStyle is not a class so I cannot create a reference Whatever I do pass generates this error = org.apache.shiro.config.UnresolveableReferenceException: Can't find examples from exstensive searching or reference in documentation. Any help is much appreciated. #==================================

Integrate Apache Shiro Security Library with Dropwizard based JAX-RS application

心已入冬 提交于 2019-12-04 08:45:10
问题 I am trying to change Dropwizard to support Shiro. I have read documentation and am little puzzled. I would like to utilize Shiro in conjunction with form login authentication and Apache Shiro Annotations. I think that I need to use Jersey Filters to support Shiro. Is this the correct way to support Shiro annotations at Jersey instead of classic Shiro Filter approach? Since Jersey Filters have decent access to resources with annotations, it seems perfect for me to use annotations. I rather

Vue + Spring Boot 项目实战(十三):使用 Shiro 实现用户信息加密与登录认证

橙三吉。 提交于 2019-12-04 06:26:48
重要链接: 「系列文章目录」 「项目源码(GitHub)」 本篇目录 前言 一、用户信息加密 1.hash 算法 2.加盐加密 3.核心代码 二、使用 Shiro 认证登录 1.Shiro 核心概念 2. Shiro 配置与登录验证 3.测试 三、下一步 前言 距离上次写文章已经快一个月了。突然感觉很对不起老读者,可能原本打算用它一两周做个小项目练练手,结果半年过去了这个沙雕作者居然还没更完。这里我诚挚地给各位道个歉,我在这儿立个 flag,只要不加班,以后我保证不会拖更超过两周。 不过说实话,不拖更还真感受不到这么多人等着我。读者大人们如果感到文章还算有一些价值,不妨点个赞、收个藏、转个发之类,这对我也是一种实打实的鼓励。 另外随着阅读量的增加,问我问题的读者也越来越多了,过去我基本上只要有时间就会帮忙看一下,但是现在真的应对不过来了,所以只能选择性回答啦。像 “为什么我运行xx会报错啊” 之类的问题,最好先有个思路再提问,有的同学甚至连错误信息都不说,以为我掐指一算就能得出结论,那我也太 six 了。还有其实我也挺势利的,一般要是一看诶这哥们儿也没给我点赞也没关注我,那一般就直接忽略啦。在此基础上还说话不好听的,我一怒之下就直接怼回去了,谁还不是网络暴民了咋的。刚好手上有个例子,给大家看一下: 讲道理这种情况下即使我发现他说的对,肯定评论一删悄悄改掉,这叫知错改错不认错

shiro授权、注解式开发

匆匆过客 提交于 2019-12-04 04:52:13
在ShiroUserMapper.xml中新增内容 <select id="getRolesByUserId" resultType="java.lang.String" parameterType="java.lang.Integer"> select r.roleid from t_shiro_user u,t_shiro_user_role ur,t_shiro_role r where u.userid = ur.userid and ur.roleid = r.roleid and u.userid = #{userid} </select> <select id="getPersByUserId" resultType="java.lang.String" parameterType="java.lang.Integer"> select p.permission from t_shiro_user u,t_shiro_user_role ur,t_shiro_role_permission rp,t_shiro_permission p where u.userid = ur.userid and ur.roleid = rp.roleid and rp.perid = p.perid and u.userid = #{userid} </select>