-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 프로파일 분리 및 운영환경 유틸리티 관련 기능 추가 (#36)
* chore: yaml 파일 프로파일에 따라 분리 * feat: 운영환경 체크 유틸리티 구현 * feat: 운영환경에 따른 CORS 설정 추가 * refactor: HttpSecurity 변수명 변경 * refactor: 운영환경 유틸리티 오타 수정 * feat: 운영환경에 따라 SameSite 정책 다르게 설정 * refactor: 응답 객체를 리턴하지 않도록 수정 * refactor: 스프링부트 쿠키 상수 사용하도록 변경 * refactor: 상수 클래스 인스턴스화 막기
- Loading branch information
Showing
10 changed files
with
187 additions
and
36 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/com/gdschongik/gdsc/global/common/constant/EnvironmentConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.gdschongik.gdsc.global.common.constant; | ||
|
||
import java.util.List; | ||
|
||
public class EnvironmentConstant { | ||
|
||
private EnvironmentConstant() {} | ||
|
||
public static final String PROD = "prod"; | ||
public static final String DEV = "dev"; | ||
public static final String LOCAL = "local"; | ||
public static final List<String> PROD_AND_DEV = List.of(PROD, DEV); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/gdschongik/gdsc/global/common/constant/UrlConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.gdschongik.gdsc.global.common.constant; | ||
|
||
public class UrlConstant { | ||
|
||
private UrlConstant() {} | ||
|
||
public static final String PROD_CLIENT_URL = "https://onboarding.gdschongik.com"; | ||
public static final String DEV_CLIENT_URL = "https://dev-onboarding.gdschongik.com"; | ||
public static final String LOCAL_REACT_CLIENT_URL = "http://localhost:3000"; | ||
public static final String LOCAL_VITE_CLIENT_URL = "http://localhost:5173"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/gdschongik/gdsc/global/util/EnvironmentUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.gdschongik.gdsc.global.util; | ||
|
||
import static com.gdschongik.gdsc.global.common.constant.EnvironmentConstant.*; | ||
|
||
import java.util.stream.Stream; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class EnvironmentUtil { | ||
|
||
private final Environment environment; | ||
|
||
public String getCurrentProfile() { | ||
return getActiveProfiles() | ||
.filter(profile -> profile.equals(PROD) || profile.equals(DEV)) | ||
.findFirst() | ||
.orElse(LOCAL); | ||
} | ||
|
||
public Boolean isProdProfile() { | ||
return getActiveProfiles().anyMatch(PROD::equals); | ||
} | ||
|
||
public Boolean isDevProfile() { | ||
return getActiveProfiles().anyMatch(DEV::equals); | ||
} | ||
|
||
public Boolean isProdAndDevProfile() { | ||
return getActiveProfiles().anyMatch(PROD_AND_DEV::contains); | ||
} | ||
|
||
private Stream<String> getActiveProfiles() { | ||
return Stream.of(environment.getActiveProfiles()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
spring: | ||
config: | ||
activate: | ||
on-profile: "dev" | ||
jpa: | ||
hibernate: | ||
ddl-auto: update | ||
|
||
logging: | ||
level: | ||
org.springframework.orm.jpa: DEBUG | ||
org.springframework.transaction: DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
spring: | ||
config: | ||
activate: | ||
on-profile: "local" | ||
|
||
jpa: | ||
hibernate: | ||
ddl-auto: update | ||
show-sql: ${SHOW_SQL:true} | ||
properties: | ||
hibernate: | ||
format_sql: ${FORMAT_SQL:true} | ||
defer-datasource-initialization: true | ||
open-in-view: false | ||
|
||
logging: | ||
level: | ||
org.springframework.orm.jpa: DEBUG | ||
org.springframework.transaction: DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
spring: | ||
config: | ||
activate: | ||
on-profile: "redis" | ||
|
||
data: | ||
redis: | ||
host: ${REDIS_HOST:localhost} | ||
port: ${REDIS_PORT:6379} | ||
password: ${REDIS_PASSWORD:} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
spring: | ||
config: | ||
activate: | ||
on-profile: "security" | ||
|
||
security: | ||
oauth2: | ||
client: | ||
registration: | ||
github: | ||
client-id: ${GITHUB_CLIENT_ID:default} | ||
client-secret: ${GITHUB_CLIENT_SECRET:default} | ||
|
||
jwt: | ||
token: | ||
ACCESS_TOKEN: | ||
secret: ${JWT_ACCESS_TOKEN_SECRET:} | ||
expiration-time: ${JWT_ACCESS_TOKEN_EXPIRATION_TIME:7200} | ||
REFRESH_TOKEN: | ||
secret: ${JWT_REFRESH_TOKEN_SECRET:} | ||
expiration-time: ${JWT_REFRESH_TOKEN_EXPIRATION_TIME:604800} | ||
issuer: ${JWT_ISSUER:} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
spring: | ||
profiles: | ||
group: | ||
local: "datasource" | ||
dev: "datasource" | ||
test: "test" | ||
security: | ||
oauth2: | ||
client: | ||
registration: | ||
github: | ||
client-id: ${GITHUB_CLIENT_ID:default} | ||
client-secret: ${GITHUB_CLIENT_SECRET:default} | ||
data: | ||
redis: | ||
host: ${REDIS_HOST:localhost} | ||
port: ${REDIS_PORT:6379} | ||
password: ${REDIS_PASSWORD:} | ||
test: "test" | ||
local: "local, datasource" | ||
dev: "dev, datasource" | ||
include: | ||
- redis | ||
- storage | ||
- security | ||
|
||
jwt: | ||
token: | ||
ACCESS_TOKEN: | ||
secret: ${JWT_ACCESS_TOKEN_SECRET:} | ||
expiration-time: ${JWT_ACCESS_TOKEN_EXPIRATION_TIME:7200} | ||
REFRESH_TOKEN: | ||
secret: ${JWT_REFRESH_TOKEN_SECRET:} | ||
expiration-time: ${JWT_REFRESH_TOKEN_EXPIRATION_TIME:604800} | ||
issuer: ${JWT_ISSUER:} | ||
logging: | ||
level: | ||
com.gdschongik.gdsc.domain.*.api.*: debug |