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
+ import org .springframework .core .io .FileSystemResource ;
10
10
import org .springframework .security .crypto .password .PasswordEncoder ;
11
11
import org .springframework .security .oauth2 .config .annotation .configurers .ClientDetailsServiceConfigurer ;
12
12
import org .springframework .security .oauth2 .config .annotation .web .configuration .AuthorizationServerConfigurerAdapter ;
@@ -33,8 +33,8 @@ public class Oauth2AuthorizationConfig extends AuthorizationServerConfigurerAdap
33
33
private final DataSource dataSource ;
34
34
private final CustomUserDetailService userDetailService ;
35
35
36
- // @Value("${security.oauth2.jwt.signkey}")
37
- // private String signKey;
36
+ @ Value ("${security.oauth2.jwt.signkey}" )
37
+ private String signKey ;
38
38
39
39
@ Override
40
40
public void configure (AuthorizationServerSecurityConfigurer security ) {
@@ -69,7 +69,7 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws E
69
69
}
70
70
71
71
/**
72
- * jwt converter를 등록
72
+ * jwt converter - signKey 공유 방식
73
73
*/
74
74
// @Bean
75
75
// public JwtAccessTokenConverter jwtAccessTokenConverter() {
@@ -78,11 +78,14 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws E
78
78
// return converter;
79
79
// }
80
80
81
+ /**
82
+ * jwt converter - 비대칭 키 sign
83
+ */
81
84
@ Bean
82
85
public JwtAccessTokenConverter jwtAccessTokenConverter () {
83
- KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory (new ClassPathResource ( "jwt .jks" ), "mySecretKey " .toCharArray ());
86
+ KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory (new FileSystemResource ( "src/main/resources/oauth2jwt .jks" ), "oauth2jwtpass " .toCharArray ());
84
87
JwtAccessTokenConverter converter = new JwtAccessTokenConverter ();
85
- converter .setKeyPair (keyStoreKeyFactory .getKeyPair ("jwt " ));
88
+ converter .setKeyPair (keyStoreKeyFactory .getKeyPair ("oauth2jwt " ));
86
89
return converter ;
87
90
}
88
91
}
0 commit comments