6
6
import org .springframework .beans .factory .annotation .Value ;
7
7
import org .springframework .context .annotation .Bean ;
8
8
import org .springframework .context .annotation .Configuration ;
9
+ import org .springframework .core .io .ClassPathResource ;
9
10
import org .springframework .security .crypto .password .PasswordEncoder ;
10
11
import org .springframework .security .oauth2 .config .annotation .configurers .ClientDetailsServiceConfigurer ;
11
12
import org .springframework .security .oauth2 .config .annotation .web .configuration .AuthorizationServerConfigurerAdapter ;
12
13
import org .springframework .security .oauth2 .config .annotation .web .configuration .EnableAuthorizationServer ;
13
14
import org .springframework .security .oauth2 .config .annotation .web .configurers .AuthorizationServerEndpointsConfigurer ;
14
15
import org .springframework .security .oauth2 .config .annotation .web .configurers .AuthorizationServerSecurityConfigurer ;
15
16
import org .springframework .security .oauth2 .provider .token .store .JwtAccessTokenConverter ;
17
+ import org .springframework .security .oauth2 .provider .token .store .KeyStoreKeyFactory ;
16
18
17
19
import javax .sql .DataSource ;
18
20
@@ -31,8 +33,8 @@ public class Oauth2AuthorizationConfig extends AuthorizationServerConfigurerAdap
31
33
private final DataSource dataSource ;
32
34
private final CustomUserDetailService userDetailService ;
33
35
34
- @ Value ("${security.oauth2.jwt.signkey}" )
35
- private String signKey ;
36
+ // @Value("${security.oauth2.jwt.signkey}")
37
+ // private String signKey;
36
38
37
39
@ Override
38
40
public void configure (AuthorizationServerSecurityConfigurer security ) {
@@ -69,10 +71,18 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws E
69
71
/**
70
72
* jwt converter를 등록
71
73
*/
74
+ // @Bean
75
+ // public JwtAccessTokenConverter jwtAccessTokenConverter() {
76
+ // JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
77
+ // converter.setSigningKey(signKey);
78
+ // return converter;
79
+ // }
80
+
72
81
@ Bean
73
82
public JwtAccessTokenConverter jwtAccessTokenConverter () {
83
+ KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory (new ClassPathResource ("jwt.jks" ), "mySecretKey" .toCharArray ());
74
84
JwtAccessTokenConverter converter = new JwtAccessTokenConverter ();
75
- converter .setSigningKey ( signKey );
85
+ converter .setKeyPair ( keyStoreKeyFactory . getKeyPair ( "jwt" ) );
76
86
return converter ;
77
87
}
78
88
}
0 commit comments