shiro

前后端分离 springboot整合shiro

耗尽温柔 提交于 2019-12-07 15:43:27
实现前后端的跨域,我是在后端配置类里实现 创建配置类 WebMvcConfig import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; // 配置全局跨域 @Configuration public class WebMvcConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("http://localhost:8081") .allowedMethods("*") .allowedHeaders("*") .allowCredentials(true); } } Shiro的配置 创建配置类 ShiroConfig import cn.xej.util

how to get/set the salt for a JdbcRealm

谁说胖子不能爱 提交于 2019-12-07 12:35:15
问题 I am attempting to use the Shiro JdbcRealm and SHA256 hashedcredentialsMatcher. I need to update a legacy database and assign the appropriate salt for each user (via a batch routine). how do I get/set the salt for a given account using the Shiro framework? 回答1: With Shiro 1.2.3 all you need to do is: Extend JdbcRealm and set salt style. public class JdbcSaltRealm extends JdbcRealm { public JdbcSaltRealm() { setSaltStyle(SaltStyle.COLUMN); } } Update shiro.ini to use extended realm and to get

springboot和shiro整合

孤街醉人 提交于 2019-12-07 10:51:59
虽然网上一大堆这方面的文章,可是自己去整合还是会遇到这样那样的问题。今天写出来等待和我一样遇到相同问题的人看见。 首先明白一点springboot之后,web.xml配置基本上就是用不上了。那么,我们的shiro整合需要将那些xml和web.xml文件里面的内容整合到系统中。 我把我这方面的代码全部贴出来,然后再一一阐述我遇到的问题。 package com.framework.demo.web.boot.shiro; import com.framework.demo.web.controller.collection.MyFilter; import org.apache.shiro.cache.spring.SpringCacheManagerWrapper; import org.apache.shiro.realm.UserRealm; import org.apache.shiro.session.mgt.OnlineSessionFactory; import org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator; import org.apache.shiro.session.mgt.eis.OnlineSessionDAO; import org.apache.shiro.spring

【Shiro】- springmvc 整合 shiro

浪尽此生 提交于 2019-12-07 10:51:48
shiro shiro是apache开源的安全框架,可方便用来处理用户信息认证、用户授权控制、信息加密等功能。 springmvc整合shiro步骤: servlet容器提供访问的入口(web.xml):DelegatingFilterProxy <filter> <filter-name>shiroFilter</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 工作原理:web.xml中配置DelegatingFilterProxy的Servlet对象,其代理的目标Serlvet其实是org.apache.shiro.spring.web.ShiroFilterFactoryBean

springboot的shiro配置之过滤器

拟墨画扇 提交于 2019-12-07 10:51:25
springboot整合shiro的文章到处都是。包括springboot的官网都有相应的例子。但是这块有个注意点,需要那些从springmvc迁到springboot的朋友注意下。这个问题困扰我了两三天,今天分享出来让后来人少踩坑。 spring整合shiro的时候我们会配置一个shiro.xml文件,将shiro的配置信息全部配置进去然后在web.xml里面配置一个过滤器代理就足够了。 <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <async-supported>true</async-supported> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> 但是到了springboot情况有所不同。之前我按照之前的方法原原本本的将shiro配置都写到了java文件中,并没有发现什么问题。可是真的使用的时候我发现了一个问题--过滤器链在无限次的自循环执行!

Shiro

妖精的绣舞 提交于 2019-12-07 10:33:29
1. 简单介绍   Apache Shiro是一个功能强大的开源安全框架,可以进行身份验证(登录)、授权(访问权限)、会话管理和加密,含有单点登录SSO、记住我、注销和缓存功能。 2. shiro架构   A. Subject :当前与软件进行交互的实体;   B. SecurityManage :用于协调其托管组件以确保他们能够顺利进行协同工作;   C. Authenticator:用于验证用户的真实身份;   D. Authorizer:确定用户在该应用程序中的访问控制;   E. SessionManager:创建和管理用户的session生命周期;   F. CacheManager:创建和管理Cache组件使用实例的生命周期;   G. Cryptography:加密数据;   H. Realms :充当Shrio与应用程序之间的安全桥梁,交互身份验证和授权。 3. 来源: https://www.cnblogs.com/ruhuanxingyun/p/12000820.html

JFinal-Beetl-Shiro(JdbcRealm)-例子

主宰稳场 提交于 2019-12-07 08:25:53
JFinal-Shiro-JDBC-Demo http://git.oschina.net/yinjun622/JFinal-Shiro-JDBC-Demo 简单实现@JFinal与Shiro整合例子 1、工程通过Eclipse直接导入,部署到tomcat中; 2、新建jfinal_shiro数据库,执行jfinal_shiro.sql; 3、修改配置文件中数据库用户名和密码 ~/jfinal_shiro/resource/jfinal.properties ~/jfinal_shiro/resource/shiro.ini 4、运行。 例子中有3个用户xiaoming、xiaohong、xiaohuang密码分别是用户名(木有进行加密存储) roles:admin和user permissions:addUser、showUser、editUser、deleteUser 表结构: 使用到的插件: jfinalshiroplugin:在JFinal可以采用shiro注释 @玛雅牛 源码 http://git.oschina.net/myaniu/jfinalshiroplugin 使用 http://my.oschina.net/myaniu/blog/137205 Beetl 模板引擎 @Beetl http://www.oschina.net/p/beetl

Spring MongoDB and Apache Shiro

為{幸葍}努か 提交于 2019-12-07 07:33:45
问题 I am attempting to use Apache Shiro with Spring and MongoDB. I am using Spring Data Repositories which are autowired. I have created my own custom realm for Shiro which uses a Spring Data repository to talk to Mongo: public class PlatformRealm extends AuthorizingRealm { @Autowired(required = true) protected UserRepository userRepository = null; @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { ... } } The problem I'm

Could not autowire field: can't to com.sun.proxy.$Proxy22

不羁岁月 提交于 2019-12-07 07:01:06
问题 Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.cms.service.FolderService com.cms.action.BaseAction.folderService; nested exception is java.lang.IllegalArgumentException: Can not set com.cms.service.FolderService field com.cms.action.BaseAction.folderService to com.sun.proxy.$Proxy22 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor

Spring is ignoring @Transactional annotations in Apache Shiro Realm class

巧了我就是萌 提交于 2019-12-07 03:44:52
问题 I am using Spring for IOC and transaction management, and am planning to use Apache Shiro as the security library. Whenever I want to check a user's permissions, I call subject.isPermitted("right") , whereupon Shiro checks for the permission using a datastore. Within these calls, a database connection is established, and I have annotated the method with @Transactional . However, I always receive an error that there is no Hibernate session bound to the thread whenever I execute the permission