Skip to content

Commit 285489c

Browse files
authored
Merge pull request #2 from codej99/feature/jks
Feature/jks
2 parents b39b6ca + 0c94b3b commit 285489c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/main/java/com/rest/oauth2/config/Oauth2AuthorizationConfig.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
import org.springframework.beans.factory.annotation.Value;
77
import org.springframework.context.annotation.Bean;
88
import org.springframework.context.annotation.Configuration;
9+
import org.springframework.core.io.FileSystemResource;
910
import org.springframework.security.crypto.password.PasswordEncoder;
1011
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
1112
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
1213
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
1314
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
1415
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
1516
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
17+
import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
1618

1719
import javax.sql.DataSource;
1820

@@ -67,12 +69,23 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws E
6769
}
6870

6971
/**
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
7183
*/
7284
@Bean
7385
public JwtAccessTokenConverter jwtAccessTokenConverter() {
86+
KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new FileSystemResource("src/main/resources/oauth2jwt.jks"), "oauth2jwtpass".toCharArray());
7487
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
75-
converter.setSigningKey(signKey);
88+
converter.setKeyPair(keyStoreKeyFactory.getKeyPair("oauth2jwt"));
7689
return converter;
7790
}
7891
}

src/main/resources/oauth2jwt.jks

2.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)