Skip to content

Commit 9aa0ea4

Browse files
authored
Merge pull request #362 from agree0002/refactor/#350
[refactor/#350] 스프링부트3 마이그레이션
2 parents 5d27a14 + da2dc72 commit 9aa0ea4

195 files changed

Lines changed: 1078 additions & 765 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.7.18'
3-
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
2+
id 'org.springframework.boot' version '3.3.5'
3+
id 'io.spring.dependency-management' version '1.1.6'
44
id 'java-library'
5-
id 'com.diffplug.spotless' version '6.13.0'
5+
id 'com.diffplug.spotless' version '6.25.0'
66
}
77

88
spotless {
@@ -20,7 +20,7 @@ spotless {
2020
//임포트 순서 정리
2121
importOrder(
2222
"java",
23-
"javax",
23+
"jakarta",
2424
"lombok",
2525
"org.springframework",
2626
"",
@@ -64,26 +64,33 @@ subprojects {
6464
}
6565
}
6666

67+
testing {
68+
suites {
69+
test {
70+
useJUnitJupiter()
71+
}
72+
}
73+
}
74+
6775
dependencies {
6876
annotationProcessor(
6977
'org.projectlombok:lombok',
7078
'org.springframework.boot:spring-boot-configuration-processor',
7179
'jakarta.persistence:jakarta.persistence-api',
7280
'jakarta.annotation:jakarta.annotation-api',
73-
"com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa"
81+
'com.querydsl:querydsl-apt:5.0.0:jakarta'
7482
)
7583

7684
implementation (
7785
'org.springframework.boot:spring-boot-starter-web',
7886
'org.springframework.boot:spring-boot-starter-validation',
79-
'org.springdoc:springdoc-openapi-ui:1.7.0',
87+
'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0',
8088
'com.google.code.findbugs:jsr305:3.0.2',
81-
'io.awspring.cloud:spring-cloud-starter-aws:2.4.4',
8289

8390
// cloud config
84-
'org.springframework.cloud:spring-cloud-starter-config:3.1.8',
91+
'org.springframework.cloud:spring-cloud-starter-config:4.1.4',
8592
'org.springframework.boot:spring-boot-starter-actuator',
86-
'org.springframework.cloud:spring-cloud-starter-bootstrap:3.1.8',
93+
'org.springframework.cloud:spring-cloud-starter-bootstrap:4.1.4',
8794

8895
// mail
8996
'org.springframework.boot:spring-boot-starter-mail',
@@ -104,10 +111,6 @@ subprojects {
104111
)
105112
}
106113

107-
test {
108-
useJUnitPlatform()
109-
}
110-
111114
}
112115

113116
project(':module-jpa') {
@@ -117,8 +120,8 @@ project(':module-jpa') {
117120
dependencies {
118121
api (
119122
'org.springframework.boot:spring-boot-starter-data-jpa',
120-
'com.querydsl:querydsl-jpa', // query dsl
121-
'com.jcraft:jsch:0.1.55', // 로컬 개발용 db ssh tunneling, https://mavenlibs.com/maven/dependency/com.jcraft/jsch
123+
'com.querydsl:querydsl-jpa:5.0.0:jakarta',
124+
'com.jcraft:jsch:0.1.55',
122125
// 'org.mariadb.jdbc:mariadb-java-client',
123126
'com.mysql:mysql-connector-j',
124127
'com.h2database:h2'
@@ -133,18 +136,18 @@ project(':module-auth') {
133136
dependencies {
134137
api project(':module-jpa')
135138
// jwt
136-
api 'io.jsonwebtoken:jjwt-api:0.11.2'
137-
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2',
139+
api 'io.jsonwebtoken:jjwt-api:0.11.5'
140+
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5',
138141
// Uncomment the next line if you want to use RSASSA-PSS (PS256, PS384, PS512) algorithms:
139142
//'org.bouncycastle:bcprov-jdk15on:1.60',
140-
'io.jsonwebtoken:jjwt-jackson:0.11.2' // or 'io.jsonwebtoken:jjwt-gson:0.11.2' for gson
143+
'io.jsonwebtoken:jjwt-jackson:0.11.5'
141144

142145
// security
143146
api 'org.springframework.boot:spring-boot-starter-security'
144147
api 'org.springframework.boot:spring-boot-starter-oauth2-client'
145-
api 'javax.xml.bind:jaxb-api'
148+
api 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
146149
testImplementation 'org.springframework.security:spring-security-test'
147-
testImplementation 'org.mockito:mockito-inline:2.13.0'
150+
testImplementation 'org.mockito:mockito-inline:5.2.0'
148151
}
149152
}
150153

@@ -155,9 +158,10 @@ project(':module-fileStorage') {
155158
dependencies {
156159
api project(':module-jpa')
157160

158-
api 'javax.xml.bind:jaxb-api'
161+
api 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
162+
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.188'
159163
testImplementation 'org.springframework.security:spring-security-test'
160-
testImplementation 'org.mockito:mockito-inline:2.13.0'
164+
testImplementation 'org.mockito:mockito-inline:5.2.0'
161165
}
162166
}
163167

@@ -167,14 +171,15 @@ project(':resource-server') {
167171
api project(':module-auth')
168172
api project(':module-fileStorage')
169173
api 'org.springframework.boot:spring-boot-starter-security'
174+
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.188'
170175
testImplementation 'org.springframework.security:spring-security-test'
171176
}
172177

173178
clean {
174179
delete file('src/main/generated')
175180
}
176181

177-
task cleanGeneratedDir(type: Delete) {
182+
tasks.register('cleanGeneratedDir', Delete) {
178183
delete file('src/main/generated')
179184
}
180185
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

module-auth/src/main/java/com/inhabas/api/auth/config/AuthBeansConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import lombok.RequiredArgsConstructor;
66

7+
import org.springframework.boot.ApplicationRunner;
78
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
89
import org.springframework.context.annotation.Bean;
910
import org.springframework.context.annotation.Configuration;
@@ -35,6 +36,11 @@ public class AuthBeansConfig {
3536
private final AuthProperties authProperties;
3637
private final RefreshTokenRepository refreshTokenRepository;
3738

39+
@Bean
40+
public ApplicationRunner jwtSecretKeyStrengthChecker(JwtTokenUtil jwtTokenUtil) {
41+
return args -> jwtTokenUtil.validateSecretKeyStrength();
42+
}
43+
3844
@Bean
3945
public HttpCookieOAuth2AuthorizationRequestRepository
4046
httpCookieOAuth2AuthorizationRequestRepository() {

module-auth/src/main/java/com/inhabas/api/auth/config/AuthSecurityConfig.java

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
import lombok.RequiredArgsConstructor;
44

5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
57
import org.springframework.context.annotation.Profile;
68
import org.springframework.core.annotation.Order;
79
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
810
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
9-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11+
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
1012
import org.springframework.security.config.http.SessionCreationPolicy;
1113
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
14+
import org.springframework.security.web.SecurityFilterChain;
1215
import org.springframework.web.cors.CorsUtils;
1316

1417
import com.inhabas.api.auth.domain.oauth2.CustomOAuth2UserService;
@@ -18,9 +21,10 @@
1821

1922
@Order(0) // 인증 관련 security filter chain 은 우선순위가 가장 높아야 함.
2023
@EnableWebSecurity
24+
@Configuration
2125
@RequiredArgsConstructor
2226
@Profile({"dev1", "dev2", "local", "prod1", "prod2"}) // 테스트에는 포함시키지 않음.
23-
public class AuthSecurityConfig extends WebSecurityConfigurerAdapter {
27+
public class AuthSecurityConfig {
2428

2529
private final CustomOAuth2UserService customOAuth2UserService;
2630
private final OAuth2AuthorizedClientService authorizedClientService;
@@ -29,62 +33,40 @@ public class AuthSecurityConfig extends WebSecurityConfigurerAdapter {
2933
private final HttpCookieOAuth2AuthorizationRequestRepository
3034
httpCookieOAuth2AuthorizationRequestRepository;
3135

32-
/**
33-
* 소셜 로그인 api <br>
34-
* <br>
35-
* 진행과정은 아래와 같다.<br>
36-
*
37-
* <ol>
38-
* <li>사용자가 소셜로그인 시작. (프론트에서 redirect_url 보내줘야함.)
39-
* <li>OAuth2 인증 진행 -> 기존 회원인지 검사
40-
* <ol style="list-style-type:lower-alpha">
41-
* <li>성공 -> OAuth2AuthenticationSuccessHandler
42-
* <ol>
43-
* <li>프론트에서 보내준 redirect_url 검증 (-> 실패하면 failure handler 에서 처리)
44-
* <li>jwt 토큰 발급 및 로그인 처리
45-
* <li>리다이렉트
46-
* </ol>
47-
* <li>실패 -> OAuth2AuthenticationFailureHandler
48-
* </ol>
49-
* </ol>
50-
*
51-
* 회원가입이나, jwt 토큰 발급을 위한 url 로 함부로 접근할 수 없게 하기 위해 jwt 토근이 발급되기 이전까지는 OAuth2 인증 결과를 세션을 통해서 유지함.
52-
* 따라서 critical 한 url 에 대해서 OAuth2 인증이 완료된 세션에 한해서만 허용.
53-
*/
54-
@Override
55-
protected void configure(HttpSecurity http) throws Exception {
36+
@Bean
37+
@Order(0)
38+
public SecurityFilterChain authSecurityFilterChain(HttpSecurity http) throws Exception {
5639

57-
http.requestMatchers()
58-
.antMatchers("/login/**")
59-
.and()
40+
http
41+
// /login/** 경로에만 이 보안 체인 적용
42+
.securityMatcher("/login/**")
6043
// 세션 생성 금지
61-
.sessionManagement()
62-
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
63-
.and()
64-
.cors()
65-
.and()
66-
.authorizeRequests()
67-
.requestMatchers(CorsUtils::isPreFlightRequest)
68-
.permitAll()
69-
.anyRequest()
70-
.permitAll()
71-
.and()
72-
.csrf()
73-
.disable()
74-
44+
.sessionManagement(
45+
session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
46+
.cors(cors -> {})
47+
.csrf(AbstractHttpConfigurer::disable)
48+
.authorizeHttpRequests(
49+
authorize ->
50+
authorize
51+
.requestMatchers(request -> CorsUtils.isPreFlightRequest(request))
52+
.permitAll()
53+
.anyRequest()
54+
.permitAll())
7555
// Oauth 로그인 설정
76-
.oauth2Login()
77-
.authorizedClientService(authorizedClientService)
78-
.authorizationEndpoint()
79-
.baseUri("/login/oauth2/authorization")
80-
.authorizationRequestRepository(httpCookieOAuth2AuthorizationRequestRepository)
81-
.and()
56+
.oauth2Login(
57+
oauth2 ->
58+
oauth2
59+
.authorizedClientService(authorizedClientService)
60+
.authorizationEndpoint(
61+
authorization ->
62+
authorization
63+
.baseUri("/login/oauth2/authorization")
64+
.authorizationRequestRepository(
65+
httpCookieOAuth2AuthorizationRequestRepository))
66+
.userInfoEndpoint(userInfo -> userInfo.userService(customOAuth2UserService))
67+
.failureHandler(oauth2AuthenticationFailureHandler)
68+
.successHandler(oauth2AuthenticationSuccessHandler));
8269

83-
// 사용자 정보를 가져오는 엔드포인트에 대한 설정
84-
.userInfoEndpoint()
85-
.userService(customOAuth2UserService)
86-
.and()
87-
.failureHandler(oauth2AuthenticationFailureHandler)
88-
.successHandler(oauth2AuthenticationSuccessHandler);
70+
return http.build();
8971
}
9072
}

module-auth/src/main/java/com/inhabas/api/auth/config/TemplateConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import org.springframework.context.annotation.Configuration;
55

66
import org.thymeleaf.TemplateEngine;
7-
import org.thymeleaf.spring5.SpringTemplateEngine;
8-
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
7+
import org.thymeleaf.spring6.SpringTemplateEngine;
8+
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
99
import org.thymeleaf.templatemode.TemplateMode;
1010

1111
@Configuration

0 commit comments

Comments
 (0)