|
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.FileSystemResource; |
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 |
|
@@ -67,12 +69,23 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws E
|
67 | 69 | }
|
68 | 70 |
|
69 | 71 | /**
|
70 |
| - * jwt converter를 등록 |
| 72 | + * jwt converter - signKey 공유 방식 |
| 73 | + */ |
| 74 | +// @Bean |
| 75 | +// public JwtAccessTokenConverter jwtAccessTokenConverter() { |
| 76 | +// JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); |
| 77 | +// converter.setSigningKey(signKey); |
| 78 | +// return converter; |
| 79 | +// } |
| 80 | + |
| 81 | + /** |
| 82 | + * jwt converter - 비대칭 키 sign |
71 | 83 | */
|
72 | 84 | @Bean
|
73 | 85 | public JwtAccessTokenConverter jwtAccessTokenConverter() {
|
| 86 | + KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new FileSystemResource("src/main/resources/oauth2jwt.jks"), "oauth2jwtpass".toCharArray()); |
74 | 87 | JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
75 |
| - converter.setSigningKey(signKey); |
| 88 | + converter.setKeyPair(keyStoreKeyFactory.getKeyPair("oauth2jwt")); |
76 | 89 | return converter;
|
77 | 90 | }
|
78 | 91 | }
|
0 commit comments