Skip to content

Commit 7d6072f

Browse files
committed
refactor: kernelsquare 쪽으로 redirect-uri하는 부분은 암호화하고 OAuth2LoginSuccessHandler에서 쿠키 도메인에 로컬과 prod 환경을 구분해서 넣어야 하는 변수를 각자의 application에서 받도록 수정
1 parent 06367ad commit 7d6072f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

member-api/src/main/java/com/kernelsquare/memberapi/common/oauth2/handler/OAuth2LoginSuccessHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class OAuth2LoginSuccessHandler implements AuthenticationSuccessHandler {
3838

3939
@Value("${custom.github.redirect}")
4040
private String githubRedirectUrl;
41+
@Value("${custom.cookie.domain}")
42+
private String cookieDomain;
4143

4244
@Override
4345
@Transactional
@@ -66,7 +68,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
6668
String encodedJson = Base64.getEncoder().encodeToString(json.getBytes());
6769

6870
String cookieValue = ResponseCookie.from("loginResponse", encodedJson) // 쿠키 이름과 값 설정
69-
.domain(".kernelsquare.live") // 쿠키 도메인 설정 / 로컬에서 돌리실 땐 .localhost로 변경하셔야 합니다.
71+
.domain(cookieDomain) // 쿠키 도메인 설정 / 로컬에서 돌리실 땐 .localhost로 변경하셔야 합니다.
7072
.maxAge(600) // 최대 유효 시간 설정 (초 단위)
7173
.path("/") // 쿠키 경로 설정
7274
.build()

member-api/src/main/resources/application-prod1.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spring:
1010
github:
1111
client-id: ENC(66P9N3wtvCajPG+go6PfTyX93lPHVjwx1E/soPaKe8C1v6EYP5DYGTcbKfhk0vSE7yOO4tN1aM3E8QvX3dQ6Cg==)
1212
client-secret: ENC(oeI907n31VpY63HGp2WEzN4WX9dAdUktP57hj6lEYnvWIVMECUNzALVOEGJgecLGoFzcN8sAOo8Ew5KZrmOit+mH2J7x5OXZiuGkhhJ031g=)
13-
redirect-uri: https://kernelsquare.live:8000/login/oauth2/code/github
13+
redirect-uri: ENC(07XBSlAlpOcNxm9iKpe2P63qgWmjRyFP9mK4TGb5ocvaj7OSLcPx5O92LTP0OVRe8eAeJz9Tg5Zwn42ZP/EGQsRLBI/drqFH3QG1nfdawQMzhd8Drt4wx55sUJpjqgUa)
1414
scope:
1515
- user:email
1616

@@ -36,6 +36,8 @@ kafka:
3636
custom:
3737
github:
3838
redirect: https://kernelsquare.live/oauth/github
39+
cookie:
40+
domain: .kernelsquare.live
3941

4042
dbInfo: rds
4143

member-api/src/main/resources/application-prod2.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spring:
1010
github:
1111
client-id: ENC(66P9N3wtvCajPG+go6PfTyX93lPHVjwx1E/soPaKe8C1v6EYP5DYGTcbKfhk0vSE7yOO4tN1aM3E8QvX3dQ6Cg==)
1212
client-secret: ENC(oeI907n31VpY63HGp2WEzN4WX9dAdUktP57hj6lEYnvWIVMECUNzALVOEGJgecLGoFzcN8sAOo8Ew5KZrmOit+mH2J7x5OXZiuGkhhJ031g=)
13-
redirect-uri: https://kernelsquare.live:8000/login/oauth2/code/github
13+
redirect-uri: ENC(07XBSlAlpOcNxm9iKpe2P63qgWmjRyFP9mK4TGb5ocvaj7OSLcPx5O92LTP0OVRe8eAeJz9Tg5Zwn42ZP/EGQsRLBI/drqFH3QG1nfdawQMzhd8Drt4wx55sUJpjqgUa)
1414
scope:
1515
- user:email
1616

@@ -36,6 +36,8 @@ kafka:
3636
custom:
3737
github:
3838
redirect: https://kernelsquare.live/oauth/github
39+
cookie:
40+
domain: .kernelsquare.live
3941

4042
dbInfo: rds
4143

0 commit comments

Comments
 (0)