随笔分类 - Spring security
摘要:1. User @Entity @Table(name = "user") public class User implements UserDetails{ /** * */ private static final long serialVersionUID = 1L; @Id @Generat
阅读全文
摘要:1. pom.xml 中的 Spring Security 依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dep
阅读全文
摘要://允许前端获取自定义的header //设置Header:Access-Control-Expose-Headers response.setHeader("Access-Control-Expose-Headers", "Authorization,userid"); //装载自定义key re
阅读全文
摘要:在Filter中注入依赖失败: @Autowired private UserRepository userRep; 原因是Filter初始化更早。 * 解决方法一:使用缓存 * 解决方法二:自己获取bean * 解决方法三:使用这个作为构造函数的参数
阅读全文
摘要:1. 配置放行不起作用 @Override protected void configure(HttpSecurity http) throws Exception { http.cors() .and().csrf().disable()//csrf针对的是session的攻击,使用jwt就不需要
阅读全文