Spring Security 指定登陆入口
spring security除通过form-login的熟悉指定登陆还可以通过entry-point-ref 指定登陆入口。具体配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- entry-point-ref指定登录入口 -->
<security:http entry-point-ref="authEntryPoint">
<security:logout delete-cookies="JSESSIONID" />
<security:intercept-url pattern="/login*.jsp*"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/**" access="ROLE_USER" />
<!-- 添加自己定义的AuthenticationFilter到FilterChain的FORM_LOGIN_FILTER位置 -->
<security:custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/>
</security:http>
<!-- AuthenticationEntryPoint,引导用户进行登录 -->
<bean id="authEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/login.jsp">
</property>
</bean> <!-- 认证过滤器 -->
<bean id="authenticationFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManager" />
<property name="usernameParameter" value="username"/>
<property name="passwordParameter" value="password"/>
<property name="filterProcessesUrl" value="/login.do" />
</bean> <security:authentication-manager alias="authenticationManager">
<security:authentication-provider user-service-ref="userDetailsService">
<security:password-encoder hash="md5"></security:password-encoder>
</security:authentication-provider>
</security:authentication-manager>
<bean id="userDetailsService" class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"></property>
</bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/security"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
<property name="acquireIncrement" value="5"></property> <!-- 当连接池中的连接用完时,C3P0一次性创建新连接的数目2 -->
<property name="initialPoolSize" value="10"></property> <!-- 初始化时创建的连接数,必须在minPoolSize和maxPoolSize之间 -->
<property name="minPoolSize" value="5"></property>
<property name="maxPoolSize" value="20"></property>
<!-- 最大空闲时间,超过空闲时间的连接将被丢弃
[需要注意:mysql默认的连接时长为8小时(28800)【可在my.ini中添加 wait_timeout=30(单位秒)设置连接超时】,这里设置c3p0的超时必须<28800]
-->
<property name="maxIdleTime" value="300"></property>
<property name="idleConnectionTestPeriod" value="60"></property> <!-- 每60秒检查连接池中的空闲连接 -->
<property name="maxStatements" value="20"></property> <!-- jdbc的标准参数 用以控制数据源内加载的PreparedStatement数量,但由于预缓存的Statement属 于单个Connection而不是整个连接 -->
</bean>
</beans>
本文配置摘自:http://haohaoxuexi.iteye.com/blog/2161648
Spring Security 指定登陆入口的更多相关文章
- Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”
编写好继承了WebSecurityConfigurerAdapter类的WebSecurityConfig类后,我们需要在configure(AuthenticationManagerBuilder ...
- bug日志-天坑,Spring Security的登陆报错:An internal error occurred while trying to authenticate the user.
在学习Spring Security的时候,我的编辑器给我报错:An internal error occurred while trying to authenticate the user. 明明 ...
- (一)Spring Security Demo 登陆与退出
文章目录 配置springSecurityFilterChain过滤器 配置身份验证 加载配置 登陆项目 退出 下面的代码需要spring环境的支持: 看这个系列博客之前,需要这个博客,大概了解下 s ...
- Spring Security 自定义 登陆 权限验证
转载于:https://www.jianshu.com/p/6b8fb59b614b 项目简介 基于Spring Cloud 的项目,Spring Cloud是在Spring Boot上搭建的所以按照 ...
- Spring Security登陆
本文参考或摘录自:http://haohaoxuexi.iteye.com/blog/2154714 在上一篇中使用Spring Security做了一些安全控制,如Spring Security 自 ...
- Spring Security(二) —— Guides
摘要: 原创出处 https://www.cnkirito.moe/spring-security-2/ 「老徐」欢迎转载,保留摘要,谢谢! 2 Spring Security Guides 上一篇文 ...
- Spring Boot (22) Spring Security
除了使用拦截器.过滤器实现对没有权限访问的页面跳转到登陆页外,还可以通过框架实现:Spring Security. 使用Spring Security 完成登陆验证: 1.pom.xml添加依赖 &l ...
- 用Spring Security, JWT, Vue实现一个前后端分离无状态认证Demo
简介 完整代码 https://github.com/PuZhiweizuishuai/SpringSecurity-JWT-Vue-Deom 运行展示 后端 主要展示 Spring Security ...
- (二)spring Security 自定义登录页面与校验用户
文章目录 配置 security 配置下 MVC 自定义登录页面 自定义一个登陆成功欢迎页面 效果图 小结: 使用 Spring Boot 的快速创建项目功能,勾选上本篇博客需要的功能:web,sec ...
随机推荐
- iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3)
iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3) 2.使用代码添加按钮实现的响应 使用代码添加的按钮,实现响应需要使用到addTarget(_:action:for:)方法,其语法形 ...
- Luogu2570 [ZJOI2010]贪吃的老鼠 ---- 网络流
Luogu2570 [ZJOI2010]贪吃的老鼠 题面描述 https://www.luogu.org/problemnew/show/P2570 然后题意大概就是m只老鼠,然后吃n个奶酪,已知 ...
- BZOJ.2109.[NOI2010]航空管制(拓扑 贪心)
题目链接 双倍经验(没有第一问) \(Description\) \(Solution\) 第一问拓扑排序即可. 第二问,即让一个元素在拓扑序中尽量靠前,好像不好做. 但是可以让一个元素出现尽量靠后. ...
- 11.7 NOIP模拟赛
目录 2018.11.7 NOIP模拟 A 序列sequence(two pointers) B 锁lock(思路) C 正方形square(埃氏筛) 考试代码 B C 2018.11.7 NOIP模 ...
- BZOJ.1875.[SDOI2009]HH去散步(DP 矩阵乘法)
题目链接 比较容易想到用f[i][j]表示走了i步后到达j点的方案数,但是题目要求不能走上一条走过的边 如果这样表示是不好转移的 可以考虑边,f[i][j]表示走了i步后到达第j条边的方案数,那么有 ...
- Python3NumPy——常用函数
Python3NumPy的常用函数 1. txt文件 (1) 单位矩阵,即主对角线上的元素均为1,其余元素均为0的正方形矩阵. 在NumPy中可以用eye函数创建一个这样的二维数组,我们只需要给定一个 ...
- Java多线程:AQS
在Java多线程:线程间通信之Lock中我们提到了ReentrantLock是API级别的实现,但是没有说明其具体实现原理.实际上,ReentrantLock的底层实现使用了AQS(AbstractQ ...
- Linux kernel engineer--trace
http://oliveryang.net/ https://github.com/yangoliver
- phpstorm10使用服务激活
现在官网已经更新到WebStorm 11.PhpStorm 10,找到一个很便捷的方法,不需要注册码了.安装完成,打开软件看到输入注册码界面的时候,切换到第二个选项,输入:http://idea.la ...
- Oracle 12c: RMAN restore/recover pluggable database
查看数据库状态 运行在归档模式,可拔插数据库name=pdborcl SQL> archive log list; Database log mode Archive Mode Automati ...