Skip to content

Commit da89c75

Browse files
authored
Merge pull request #68 from GP-DriveU/setting/#67/server-transfer
feat: new server swagger and health check endpoint
2 parents 6b404a9 + f718b2e commit da89c75

3 files changed

Lines changed: 50 additions & 41 deletions

File tree

build.gradle

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
11
plugins {
2-
id 'java'
3-
id 'org.springframework.boot' version '3.4.5'
4-
id 'io.spring.dependency-management' version '1.1.7'
2+
id 'java'
3+
id 'org.springframework.boot' version '3.4.5'
4+
id 'io.spring.dependency-management' version '1.1.7'
55
}
66

77
group = 'com.driveu'
88
version = '0.0.1-SNAPSHOT'
99

1010
java {
11-
toolchain {
12-
languageVersion = JavaLanguageVersion.of(21)
13-
}
11+
toolchain {
12+
languageVersion = JavaLanguageVersion.of(21)
13+
}
1414
}
1515

1616
configurations {
17-
compileOnly {
18-
extendsFrom annotationProcessor
19-
}
17+
compileOnly {
18+
extendsFrom annotationProcessor
19+
}
2020
}
2121

2222
repositories {
23-
mavenCentral()
23+
mavenCentral()
2424
}
2525

2626
dependencies {
27-
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
28-
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
29-
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
30-
implementation 'org.springframework.boot:spring-boot-starter-security'
31-
implementation 'org.springframework.boot:spring-boot-starter-web'
27+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
28+
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
29+
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
30+
implementation 'org.springframework.boot:spring-boot-starter-security'
31+
implementation 'org.springframework.boot:spring-boot-starter-web'
3232
implementation 'org.springframework.boot:spring-boot-starter-aop'
3333

34-
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
34+
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
3535

36-
implementation platform("software.amazon.awssdk:bom:2.25.17") // 최신 버전 BOM (버전은 필요 시 조정)
37-
implementation "software.amazon.awssdk:s3"
38-
implementation "software.amazon.awssdk:auth"
39-
implementation "software.amazon.awssdk:regions"
36+
implementation platform("software.amazon.awssdk:bom:2.25.17") // 최신 버전 BOM (버전은 필요 시 조정)
37+
implementation "software.amazon.awssdk:s3"
38+
implementation "software.amazon.awssdk:auth"
39+
implementation "software.amazon.awssdk:regions"
4040

41-
compileOnly 'org.projectlombok:lombok'
42-
runtimeOnly 'com.mysql:mysql-connector-j'
41+
compileOnly 'org.projectlombok:lombok'
42+
runtimeOnly 'com.mysql:mysql-connector-j'
4343

44-
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
45-
implementation 'org.jetbrains:annotations:24.0.0'
46-
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
47-
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
48-
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
44+
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
45+
implementation 'org.jetbrains:annotations:24.0.0'
46+
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
47+
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
48+
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
4949
implementation 'org.springframework.boot:spring-boot-starter-webflux'
50+
implementation 'org.springframework.boot:spring-boot-starter-actuator'
5051

51-
annotationProcessor 'org.projectlombok:lombok'
52-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
53-
testImplementation 'org.springframework.security:spring-security-test'
54-
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
52+
annotationProcessor 'org.projectlombok:lombok'
53+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
54+
testImplementation 'org.springframework.security:spring-security-test'
55+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
5556
}
5657

5758
tasks.named('test') {
58-
useJUnitPlatform()
59+
useJUnitPlatform()
5960
}

src/main/java/com/driveu/server/global/config/SwaggerConfig.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
import io.swagger.v3.oas.models.security.SecurityRequirement;
88
import io.swagger.v3.oas.models.security.SecurityScheme;
99
import io.swagger.v3.oas.models.servers.Server;
10+
import java.util.List;
1011
import org.springframework.context.annotation.Bean;
1112
import org.springframework.context.annotation.Configuration;
1213

13-
import java.util.List;
14-
1514
@OpenAPIDefinition(
1615
info = @Info(
1716
title = "API 명세서",
@@ -22,7 +21,7 @@
2221
@Configuration
2322
public class SwaggerConfig {
2423
@Bean
25-
public OpenAPI openAPI(){
24+
public OpenAPI openAPI() {
2625

2726
SecurityScheme apiKey = new SecurityScheme()
2827
.type(SecurityScheme.Type.HTTP)
@@ -34,6 +33,9 @@ public OpenAPI openAPI(){
3433
SecurityRequirement securityRequirement = new SecurityRequirement()
3534
.addList("Bearer Token");
3635

36+
Server newHttpsServer = new Server();
37+
newHttpsServer.setUrl("https://api.driveu.site");
38+
newHttpsServer.setDescription("driveu https new server url");
3739

3840
Server httpsServer = new Server();
3941
httpsServer.setUrl("https://www.driveu.site");
@@ -50,7 +52,9 @@ public OpenAPI openAPI(){
5052
return new OpenAPI()
5153
.components(new Components().addSecuritySchemes("Bearer Token", apiKey))
5254
.addSecurityItem(securityRequirement)
53-
.servers(List.of(httpsServer, localServer, prodServer));}
55+
.servers(List.of(newHttpsServer, httpsServer, localServer, prodServer));
56+
}
57+
5458
;
5559

5660
}

src/main/java/com/driveu/server/global/config/security/SecurityConfig.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.driveu.server.domain.auth.enhancer.JwtAuthenticationFilter;
44
import com.driveu.server.domain.auth.infra.JwtProvider;
55
import com.driveu.server.global.util.TokenExtractor;
6+
import java.util.List;
67
import lombok.RequiredArgsConstructor;
78
import org.springframework.context.annotation.Bean;
89
import org.springframework.context.annotation.Configuration;
@@ -19,8 +20,6 @@
1920
import org.springframework.web.cors.CorsConfigurationSource;
2021
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
2122

22-
import java.util.List;
23-
2423
@RequiredArgsConstructor
2524
@Configuration
2625
@EnableWebSecurity
@@ -33,7 +32,10 @@ public class SecurityConfig {
3332
@Bean
3433
public WebSecurityCustomizer webSecurityCustomizer() {
3534
return web -> web.ignoring()
36-
.requestMatchers("/h2-console/**","/error", "/favicon.ico");
35+
.requestMatchers(
36+
"/h2-console/**", "/error", "/favicon.ico",
37+
"/actuator/health"
38+
);
3739
}
3840

3941
@Bean
@@ -59,7 +61,8 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
5961
.authorizeHttpRequests((registry) ->
6062
registry
6163
.requestMatchers("/api/auth/google", "/api/auth/code/google").permitAll() // 로그인 api 허용
62-
.requestMatchers("/v3/api-docs/**", "/swagger-ui.html", "/swagger-ui/**", "/swagger-resources/**", "/webjars/**").permitAll() // 스웨거 허용
64+
.requestMatchers("/v3/api-docs/**", "/swagger-ui.html", "/swagger-ui/**",
65+
"/swagger-resources/**", "/webjars/**").permitAll() // 스웨거 허용
6366
.anyRequest().authenticated()
6467
)
6568
.addFilterBefore(new JwtAuthenticationFilter(jwtProvider, tokenExtractor),
@@ -71,7 +74,8 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
7174
@Bean
7275
public CorsConfigurationSource corsConfigurationSource() {
7376
CorsConfiguration config = new CorsConfiguration();
74-
config.setAllowedOriginPatterns(List.of("*")); // or use List.of("http://localhost:3000") if you want to restrict
77+
config.setAllowedOriginPatterns(
78+
List.of("*")); // or use List.of("http://localhost:3000") if you want to restrict
7579
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
7680
config.setAllowedHeaders(List.of("*"));
7781
config.setAllowCredentials(true); // Authorization 헤더 포함 허용

0 commit comments

Comments
 (0)