-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: 프로파일 분리 및 운영환경 유틸리티 관련 기능 추가 #36
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c93c7ca
chore: yaml 파일 프로파일에 따라 분리
uwoobeat 2b11614
feat: 운영환경 체크 유틸리티 구현
uwoobeat 369e07f
feat: 운영환경에 따른 CORS 설정 추가
uwoobeat a7ac8b6
refactor: HttpSecurity 변수명 변경
uwoobeat 35dad33
refactor: 운영환경 유틸리티 오타 수정
uwoobeat 193cecf
feat: 운영환경에 따라 SameSite 정책 다르게 설정
uwoobeat e82787f
refactor: 응답 객체를 리턴하지 않도록 수정
uwoobeat e334785
refactor: 스프링부트 쿠키 상수 사용하도록 변경
uwoobeat cc05751
refactor: 상수 클래스 인스턴스화 막기
uwoobeat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 수정 필요없나요?
.cors().configurationSource(corsConfigurationSource())
가 되어야 하는게 아닌가요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.withDefaults()
사용하더라도 커스터마이징된 설정을 로드하기 때문에 괜찮습니다.