Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d559180

Browse files
committed
Enable JWT Settings
1 parent f0d8146 commit d559180

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

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

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
1313
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
1414
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
15-
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
1615
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
1716

1817
import javax.sql.DataSource;
@@ -36,17 +35,14 @@ public class Oauth2AuthorizationConfig extends AuthorizationServerConfigurerAdap
3635
private String signKey;
3736

3837
@Override
39-
public void configure(AuthorizationServerSecurityConfigurer security) throwsException{
38+
public void configure(AuthorizationServerSecurityConfigurer security) {
4039
security.tokenKeyAccess("permitAll()")
4140
.checkTokenAccess("isAuthenticated()") //allow check token
4241
.allowFormAuthenticationForClients();
4342
}
4443

4544
/**
4645
* 클라이언트 정보 주입 방식을 jdbcdetail로 변경
47-
*
48-
* @param clients
49-
* @throws Exception
5046
*/
5147
@Override
5248
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
@@ -55,35 +51,28 @@ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
5551

5652
/**
5753
* 토큰 정보를 DB를 통해 관리한다.
58-
*
59-
* @return
6054
*/
61-
@Override
62-
public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
63-
endpoints.tokenStore(new JdbcTokenStore(dataSource)).userDetailsService(userDetailService);
64-
}
55+
// @Override
56+
// public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
57+
// endpoints.tokenStore(new JdbcTokenStore(dataSource)).userDetailsService(userDetailService);
58+
// }
6559

6660
/**
6761
* 토큰 발급 방식을 JWT 토큰 방식으로 변경한다. 이렇게 하면 토큰 저장하는 DB Table은 필요가 없다.
68-
*
69-
* @param endpoints
70-
* @throws Exception
7162
*/
72-
// @Override
73-
// public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
74-
// super.configure(endpoints);
75-
// endpoints.accessTokenConverter(jwtAccessTokenConverter()).userDetailsService(userDetailService);
76-
// }
63+
@Override
64+
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
65+
super.configure(endpoints);
66+
endpoints.accessTokenConverter(jwtAccessTokenConverter()).userDetailsService(userDetailService);
67+
}
7768

7869
/**
7970
* jwt converter를 등록
80-
*
81-
* @return
8271
*/
83-
// @Bean
84-
// public JwtAccessTokenConverter jwtAccessTokenConverter() {
85-
// JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
86-
// converter.setSigningKey(signKey);
87-
// return converter;
88-
// }
72+
@Bean
73+
public JwtAccessTokenConverter jwtAccessTokenConverter() {
74+
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
75+
converter.setSigningKey(signKey);
76+
return converter;
77+
}
8978
}

‎src/main/java/com/rest/oauth2/config/SecurityConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.rest.oauth2.config;
22

3-
import com.rest.oauth2.service.security.CustomUserDetailService;
43
import lombok.RequiredArgsConstructor;
54
import org.springframework.context.annotation.Configuration;
65
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /