spring security2中对url进行拦截的配置
2009-07-23 17:15
323 查看
1、配置web.xml文件:
2、配置spring-security.xml(该文件名字与web.xml中的<context-param />中的相对应) :
<!-- 指定spring security的配置文件--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-security.xml</param-value> </context-param> <!-- spring security 的 Filter Chain 代理 --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 取得Spring的Context --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
2、配置spring-security.xml(该文件名字与web.xml中的<context-param />中的相对应) :
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <http auto-config="true"> <!-- 登录页面不拦截,任何人都可以访问到 --> <intercept-url pattern="/login.jsp" filters="none" /> <!-- 需要拦截的路径,pattern表示要拦截的路径,access表示能够访问的角色 --> <intercept-url pattern="/a/*" access="ROLE_A,ROLE_ADMIN,ROLE_SUPER" /> <intercept-url pattern="/a/aa/*" access="ROLE_AA,ROLE_ADMIN,ROLE_SUPER" /> <intercept-url pattern="/b/*" access="ROLE_B,ROLE_ADMIN,ROLE_SUPER" /> <intercept-url pattern="/b/bb/*" access="ROLE_BB,ROLE_ADMIN,ROLE_SUPER" /> <!-- 指定登录页面 --> <form-login login-page="/login.jsp" /> <!-- 指定退出后要显示的页面 --> <logout logout-success-url="/index.jsp"></logout> <!-- 同步session控制 --> <concurrent-session-control max-sessions="1" /> </http> <!-- 认证提供器 --> <authentication-provider> <password-encoder hash="plaintext"></password-encoder> <user-service> <user password="super" name="super" authorities="ROLE_SUPER" /> <user password="admin" name="admin" authorities="ROLE_ADMIN" /> <user password="a" name="a" authorities="ROLE_A" /> <user password="b" name="b" authorities="ROLE_B" /> <user password="aa" name="aa" authorities="ROLE_AA" /> <user password="bb" name="bb" authorities="ROLE_BB" /> </user-service> </authentication-provider> </beans:beans>
相关文章推荐
- Spring mvc + Spring Security 拦截 Restful格式的URL并进行验证,支持Remember me token数据库存储
- spring mvc 拦截器的配置 对某个url进行拦截
- spring security2中对method进行拦截的配置
- SpringBoot通过自己的配置文件或者从数据库spring security动态配置url权限
- Spring Security(08)——intercept-url配置
- Spring Security(08)——intercept-url配置
- Spring Security表单配置中的loginProcessingUrl
- WCF配置后支持通过URL进行http方式调用
- spring security插件--获取 登录前被拦截的URL
- 关于cas-client单点登录客户端拦截请求和忽略/排除不需要拦截的请求URL的问题(不需要修改任何代码,只需要一个配置)
- Spring Security(08)——intercept-url配置
- web.xml配置监听器来进行shiro拦截
- android web view的学习 2 通过WebChomeClient 实现进度条和title,通过WebViewClient 来进行url的拦截,和javascript的交互
- Spring Security-利用URL地址进行权限控制
- SpringMVC 配置url pattern为 /* 之后返回的modelandview也会被拦截
- 关于cas-client单点登录客户端拦截请求和忽略/排除不需要拦截的请求URL的问题(不需要修改任何代码,只需要一个配置)
- 读取配置文件,对每一个url进行检查,并行
- 使用Apache shiro进行权限管理时如何对同一个URL配置多个角色的或关系
- Spring Security(08)——intercept-url配置
- 普元 EOS Platform Governor HTTP接入不拦截Url配置规则