shiro

配置FactoryBean实例工厂

北慕城南 提交于 2019-12-18 10:47:27
1.实例化工厂 <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="filterChainDefinitionMap" ref="filterChainMap"/> <!--扩展Shiro的过滤器--> <property name="filters" ref="filtersMap"/> </bean> <!--实例化工厂--> <!-- 使用bean标签将类引入(托给spring创建对象)--> <bean id="filterChainDefinitionFactory" class="com.capcom.shiro.FilterChainDefinitionMapFactory"/> <!-- 引入类之后,再引入类的方法 --> <bean id="filterChainMap" factory-bean="filterChainDefinitionFactory" factory-method="getMap"/> <!-- 添加到shiro的实例工厂 --> <!-- 使用bean标签将类引入(托给spring创建对象) --> <bean id="filtersFactory" class="com.capcom

how to implement Shiro Security of Grails in my Project

爷,独闯天下 提交于 2019-12-18 04:23:18
问题 i m new to Grails and using some Shiro security. I have made a little site with login page and if login successful it redirects me to another loggedin page. now i want to implement Shiro Security. I have run that plugin and quick start app of Shiro on new Grails Project. what i want to achieve is that how can i implement my security on my own pages using the Quick Start Files and code. Please guide. a little. which files should i use from that quick start and what changing should i made. ?

Shiro Authorization Permission check using Annotation not working

纵饮孤独 提交于 2019-12-17 18:14:21
问题 Platform: Shiro 1.1.0, Spring 3.0.5 I'm trying to secure the MVC Controller methods using Shiro annotation. However something is wrong with annotations. Regular calls are just working OK. There is nothing specific in Shiro debug also. My shiro configuration: <!-- Security Manager --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="sessionMode" value="native" /> <property name="realm" ref="jdbcRealm" /> <property name="cacheManager" ref=

When to move from Container managed security to alternatives like Apache Shiro, Spring Security?

自古美人都是妖i 提交于 2019-12-17 08:59:30
问题 I am trying to secure my application which is built using JSF2.0. I am confused about when do people choose to go with security alternatives like Shiro, Spring Security or owasp's esapi leaving behind container managed security. Having seen some of related questions on Stack Overflow, where I realized that container based security was more preferred by JSF developers in past. But I have also been strongly recommended to use Apache Shiro. I am novice in terms of the security issues and have no

Shiro Realm 及相关对象

不羁岁月 提交于 2019-12-17 07:39:04
Realm 【Realm】及【Authorizer】部分都已经详细介绍过 Realm 了,接下来再来看一下一般真实环境下的 Realm 如何实现。 1、定义实体及关系 即用户 - 角色之间是多对多关系,角色 - 权限之间是多对多关系;且用户和权限之间通过角色建立关系;在系统中验证时通过权限验证,角色只是权限集合,即所谓的显示角色;其实权限应该对应到资源(如菜单、URL、页面按钮、Java 方法等)中,即应该将权限字符串存储到资源实体中,但是目前为了简单化,直接提取一个权限表,【综合示例】部分会使用完整的表结构。 用户实体包括:编号 (id)、用户名 (username)、密码 (password)、盐 (salt)、是否锁定 (locked);是否锁定用于封禁用户使用,其实最好使用 Enum 字段存储,可以实现更复杂的用户状态实现。 角色实体包括:、编号 (id)、角色标识符(role)、描述(description)、是否可用(available);其中角色标识符用于在程序中进行隐式角色判断的,描述用于以后再前台界面显示的、是否可用表示角色当前是否激活。 权限实体包括:编号(id)、权限标识符(permission)、描述(description)、是否可用(available);含义和角色实体类似不再阐述。 另外还有两个关系实体:用户 - 角色实体(用户编号、角色编号

SpringBoot(十四):springboot整合shiro-登录认证和权限管理

橙三吉。 提交于 2019-12-17 03:16:47
原文出处: 纯洁的微笑 这篇文章我们来学习如何使用Spring Boot集成Apache Shiro。安全应该是互联网公司的一道生命线,几乎任何的公司都会涉及到这方面的需求。在Java领域一般有Spring Security、Apache Shiro等安全框架,但是由于Spring Security过于庞大和复杂,大多数公司会选择Apache Shiro来使用,这篇文章会先介绍一下Apache Shiro,在结合Spring Boot给出使用案例。 Apache Shiro What is Apache Shiro? Apache Shiro是一个功能强大、灵活的,开源的安全框架。它可以干净利落地处理身份验证、授权、企业会话管理和加密。 Apache Shiro的首要目标是易于使用和理解。安全通常很复杂,甚至让人感到很痛苦,但是Shiro却不是这样子的。一个好的安全框架应该屏蔽复杂性,向外暴露简单、直观的API,来简化开发人员实现应用程序安全所花费的时间和精力。 Shiro能做什么呢? 验证用户身份 用户访问权限控制,比如:1、判断用户是否分配了一定的安全角色。2、判断用户是否被授予完成某个操作的权限 在非 web 或 EJB 容器的环境下可以任意使用Session API 可以响应认证、访问控制,或者 Session 生命周期中发生的事件

ssh框架整合shiro权限

纵饮孤独 提交于 2019-12-16 15:57:48
写在前面:    最近项目中使用了Shiro,虽然不是自己在负责这一块,但还是抽空学习了下,也可以让自己对shiro有基本的了解。毕竟Shiro安全框架在项目中还是挺常用的。    对于Apache Shiro的基本概念就不在这里一一描述了,资料网上都有,主要还是记录下代码相关的,能够先让自己快速学会使用。   这里的demo(可以测试登录认证,登出,以及授权)主要使用的是ssh框架,所以前提是要将ssh的项目框架搭起来,并导入shiro相关的jar包,然后才是编写配置shiro的相关代码。    1.shiro相关配置文件的编写    web.xml <!-- shiro 过滤器 start --> <!--spring容器查找名字为shiroFilter(filter-name)的bean并把所有Filter的操作委托给它。--> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <!-- 设置true由servlet容器控制filter的生命周期 --> <init-param> <param-name>targetFilterLifecycle</param-name

springBoot整合shiro

孤街醉人 提交于 2019-12-16 00:19:25
依赖包 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.3.2</version> </dependency> 数据库表 一切从简,用户 user 表,以及角色 role 表 Shiro 相关类 Shiro 配置类 @Configuration public class ShiroConfig { @Bean public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); // 必须设置 SecurityManager shiroFilterFactoryBean.setSecurityManager(securityManager); // setLoginUrl 如果不设置值,默认会自动寻找Web工程根目录下的"/login.jsp"页面 或 "/login" 映射 shiroFilterFactoryBean.setLoginUrl("/notLogin"); // 设置无权限时跳转的

spring+shiro搭建简单安全框架

核能气质少年 提交于 2019-12-16 00:18:39
一、简介: shiro是一个安全框架,顾名思义就是对系统的访问进行安全控制,包含用户身份认证(登录),用户权限控制(通过角色,权限字符串等)。 权限里面很关键的两个东西:认证和授权。 1. 认证没什么好说的,目的就是判断用户的账号密码是否正确之类的,授权的作用嘛,简单的解释就是给用户赋予相应的权限。 2. 判断一个用户有没有权限访问,无非是拦截URL能否访问,分为以下几个操作 ①判断当前URL是否需要拦截,不需要则放行,需要则进入下一步 ②判断用户是否已登陆,有则下一步,无则抛出401未认证 ④从资源表/权限表读取当前登陆用户的可访问地址,进入下一步判断是否包含用户当前访问的地址,有则放行,无则抛出403无权限。 二、简单搭建 1.maven工程,版本自行选择 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>1.3.2</version> </dependency> <dependency>

第一节:Shiro HelloWorld 实现

人走茶凉 提交于 2019-12-15 11:38:14
1、新建maven工程,pom配置maven jar包 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.2.4</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.12</version> </dependency> 2.resourses下新建文件配置shiro.ini,配置如下 [users]java1234=123456jack=123 3.resourses下新建文件配置log4g.properties,配置如下 ## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF