郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.gk.hotwork.Config.Oauth2;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
 
/**
 * 配置jwt
 */
@Configuration
public class JwtConfig {
 
    @Autowired
    JwtAccessTokenConverter jwtAccessTokenConverter;
 
    @Bean
    @Qualifier("tokenStore")
    public TokenStore tokenStore() {
        return new JwtTokenStore(jwtAccessTokenConverter);
    }
 
    @Bean
    protected JwtAccessTokenConverter jwtTokenEnhancer() {
        JwtAccessToken converter = new JwtAccessToken();
        converter.setSigningKey("springCloud_oauth_service");
        return converter;
    }
}