Spring Security
文章平均质量分 52
magicproblem
自学中。。。。。。。。
展开
-
SpringSecurity配置及注解说明
一、配置准备1、引入相关pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> <version>2.0.4.RELEASE</version>原创 2021-10-25 22:27:47 · 1146 阅读 · 0 评论 -
Spring Security csrf的使用
1、在WebSecurityConfigurerAdapter配置类中不要配置(默认csrf是开启状态)//.and().csrf().disable(); /* 关闭csrf防护 */2、在登录页面加上一个隐藏域用于记录csrftoken(用来thymeleaf模板引擎)<input type="hidden" th:if="${_csrf}!=null" th:value="${_csrf.token}" name="_csrf">...原创 2021-01-15 10:50:31 · 507 阅读 · 0 评论 -
Spring Security自动登录笔记
一、Spring Security思想红色代表第一次登录自动保存token的流程蓝色代表关闭浏览器后第二次访问token的查找以及数据比对的流程二、实现自动登录1、在配置类中配置PersistentTokenRepository决定token数据的处理方式 //1、配置数据源 @Autowired private DataSource dataSource; //配置PersistentTokenRepository,该类用于配置token数据的处理方式 /原创 2021-01-15 10:11:57 · 126 阅读 · 0 评论 -
Spring Security权限配置
1、通过WebSecurityConfigurerAdapter配置类配置权限 public void configure(HttpSecurity httpSecurity) throws Exception {// httpSecurity.exceptionHandling().accessDeniedPage("/403"); /* 配置没有权限访问条状自定义页面 */ httpSecurity.authorizeRequests() /* 指定哪些ur原创 2021-01-14 15:59:57 · 878 阅读 · 0 评论 -
Spring Security登录注销配置
1、在继承了WebSecurityConfigurerAdapter的配置类中配置 public void configure(HttpSecurity httpSecurity) throws Exception { httpSecurity.formLogin() /* 自定义自己编写的登录界面 */ .loginPage("/login") /* 登录页面设置 */ .loginProcessingUrl原创 2021-01-14 10:34:48 · 167 阅读 · 0 评论 -
配置Spring Security的登录用户密码的三种方式
在这之前所需要的依赖以及其他配置maven依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency>原创 2021-01-13 09:54:55 · 1208 阅读 · 0 评论