随笔分类 -  Spring Security

摘要:@Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserDetailsService userDetailsService; @Override 阅读全文
posted @ 2021-07-24 20:20 xl4ng 阅读(320) 评论(0) 推荐(0) 编辑
摘要:第一种方式:通过配置文件 spring: security: user: name: root password: root 第二种方式:通过配置类 @Configuration public class SecurityConfig extends WebSecurityConfigurerAda 阅读全文
posted @ 2021-07-24 16:35 xl4ng 阅读(1299) 评论(0) 推荐(0) 编辑
摘要:1.引入数据库依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <group 阅读全文
posted @ 2020-11-07 22:55 xl4ng 阅读(119) 评论(0) 推荐(0) 编辑
摘要:1.创建验证码相关的异常类ValidateCodeException package com.mengxuegu.security.authentication.code; import org.springframework.security.core.AuthenticationExceptio 阅读全文
posted @ 2020-11-07 21:34 xl4ng 阅读(314) 评论(0) 推荐(0) 编辑
摘要:1.导入依赖 <dependency> <groupId>com.github.penggle</groupId> <artifactId>kaptcha</artifactId> </dependency> 2.创建KaptchaImageCodeConfig package com.mengxu 阅读全文
posted @ 2020-11-07 21:24 xl4ng 阅读(196) 评论(0) 推荐(0) 编辑
摘要:CustomAuthenticationSuccessHandler package com.mengxuegu.security.authentication; import com.mengxuegu.base.result.MengxueguResult; import com.mengxue 阅读全文
posted @ 2020-11-07 19:35 xl4ng 阅读(320) 评论(0) 推荐(0) 编辑
摘要:自定义认证失败处理器 package com.mengxuegu.security.authentication; import com.mengxuegu.base.result.MengxueguResult; import org.springframework.http.HttpStatus 阅读全文
posted @ 2020-11-07 13:58 xl4ng 阅读(975) 评论(0) 推荐(0) 编辑
摘要:创建CustomAuthenticationSuccessHandler package com.mengxuegu.security.authentication; import com.mengxuegu.base.result.MengxueguResult; import org.sprin 阅读全文
posted @ 2020-11-05 22:01 xl4ng 阅读(548) 评论(0) 推荐(0) 编辑
摘要:新建CustomUserDetailsService类 package com.mengxuegu.security; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans. 阅读全文
posted @ 2020-11-05 21:37 xl4ng 阅读(163) 评论(0) 推荐(0) 编辑
摘要:application.yml server: port: 80 spring: thymeleaf: cache: false #关闭Thymeleaf缓存 mengxuegu: security: authentication: loginPage: /login/page #响应认证(登录)页 阅读全文
posted @ 2020-11-03 22:22 xl4ng 阅读(623) 评论(0) 推荐(0) 编辑
摘要:<div th:if="${param.error}"> <span th:text="${session.SPRING_SECURITY_LAST_EXCEPTION?.message}" style="color: red">用户名或者密码错误</span> </div> package com 阅读全文
posted @ 2020-11-03 21:23 xl4ng 阅读(677) 评论(0) 推荐(0) 编辑
摘要:package com.mengxuegu.security.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; im 阅读全文
posted @ 2020-11-01 23:08 xl4ng 阅读(194) 评论(0) 推荐(0) 编辑
摘要:WebSecurityConfig package com.chenmuxin.springdemo.configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; imp 阅读全文
posted @ 2020-10-26 22:57 xl4ng 阅读(131) 评论(0) 推荐(0) 编辑