【发布时间】:2021-12-19 21:29:58
【问题描述】:
我正在使用 Spring Security 创建一个应用程序。我需要将 JWT 与 JwtAccessTokenConverter 和 JwtTokenStore 一起使用。当我导入时,它表明它已折旧。可以用什么代替?
package com.devsuperior.dscatalog.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
@Configuration
public class AppConfig {
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(); // return a instance
}
// Objects can access a token JWT: ready, write, create, etc
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
JwtAccessTokenConverter tokenConverter = new JwtAccessTokenConverter();
tokenConverter.setSigningKey("MY-JWT-SECRET");
return tokenConverter;
}
@Bean
public JwtTokenStore tokenStore() {
return new JwtTokenStore(accessTokenConverter());
}
}
【问题讨论】: