我正在使用 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());
}
}
uj5u.com熱心網友回復:
實際上,整個Spring Security OAuth 專案都被棄用了。我假設您需要授權服務器的替代方案。如果是這種情況,您可以嘗試使用Spring Authorization Server
由 Spring Security 團隊領導的 Spring Authorization Server 專案專注于向 Spring 社區提供 OAuth 2.1 Authorization Server 支持。
它現在支持許多功能,您可以等待下一個版本中完全支持的 OIDC 實作。
uj5u.com熱心網友回復:
我將 pom.xml 調整為該依賴項:
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
</dependency>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/352364.html
