spring-security-jwt-guide
spring-security-jwt-guide copied to clipboard
从零入门 !Spring Security With JWT(含权限验证)后端部分代码。
SpringSecurity介绍.md文件中给出的配置类SecurityConfig和项目代码中的SecurityConfig内容不一样啊。 ``` @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired UserDetailsServiceImpl userDetailsServiceImpl; /** * 密码编码器 */ @Bean public BCryptPasswordEncoder bCryptPasswordEncoder() { return new BCryptPasswordEncoder(); } @Bean public...
后台肯定是希望用户登录一段时间没操作后失效了,如果有操作要续期,如果使用jwt的过期时间每次续期都要重新生成,如果用redis管理过期时间,那jwt就没有什么意义了
你这样配置了这个context-path为api,然后白名单里面又设置/api/auth/login放行,但是这个配置不会生效。 springsecurity默认匹配url的时候,不会携带项目名,也就是你的/api。 这里问题很大,我调试了很久才找到问题。不明白你测试的时候怎么会通过的,你登录的时候接口不会报错吗。
我看您的代码,第一次登录时是在controller层对于密码和用户名进行检查.但是在SpringSecurity中似乎是通过过滤器去验证UsernamePasswordToken成功之后才到达controller层执行之后的请求.这样的话SpringSecurity的作用似乎就体现不出来了
jwt生成的token是可以通过绑定的加密算法Hmac直接校验的,为什么要把token存在redis去校验,这样子与其他方案生成加密串作为token有什么区别呢?
过滤器和配置均搭配好,postman无论是post还是get,请求后没有任何响应,把SecurityConfig.configure(HttpSecurity http)中的代码注释掉 获取用户接口可以使用,但是注册就报403权限了
循环依赖
最近在学习这个项目中的Spring Security,用其中的代码做了一个自己的项目,在线下用`mvn package`和`java -jar`都运行正常,使用DevOps部署到线上出现了循环依赖的异常。(为了使idea生成下面的图,加了几处`@Autowired`注解) 1. 要生成`userController`,就需要通过自动装配方式使用`userService` ```java public class UserController { private final UserService userService; ``` 2. 其中`userService`需要`bCryptPasswordEncoder`,也是通过`@Autowired`方式装配 ```java public class UserService { @Autowired private final BCryptPasswordEncoder bCryptPasswordEncoder; ``` 3....
错误: at github.javaguide.springsecurityjwtguide.security.filter.JWTAuthenticationFilter.successfulAuthentication(JWTAuthenticationFilter.java:73) ~[classes/:na] http 响应 `{ "timestamp": "2019-10-14T01:23:26.399+0000", "status": 500, "error": "Internal Server Error", "message": "No message available", "path": "/auth/login" }`