Skip to content

Commit 99ad625

Browse files
committed
Merge branch 'main' of https://github.com/prgrms-web-devcourse-final-project/WEB1_1_Bongdari_BE into refactor/60-modify-community-board-query
# Conflicts: # src/main/java/com/somemore/community/service/CommunityBoardQueryService.java
2 parents c8ccff0 + 3b5dce2 commit 99ad625

36 files changed

+495
-81
lines changed

.github/workflows/CD.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ jobs:
2323
NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }}
2424
NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }}
2525
NAVER_SCOPE: ${{ secrets.NAVER_SCOPE }}
26+
NAVER_REDIRECT_URL: ${{secrets.NAVER_REDIRECT_URL}}
2627
JWT_SECRET: ${{ secrets.JWT_SECRET }}
28+
FRONT_URL: ${{secrets.FRONT_URL}}
29+
BACK_URL: ${{secrets.BACK_URL}}
2730

2831
steps:
2932
- name: Github Repository 파일 불러오기

.github/workflows/CI.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ jobs:
3131
NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }}
3232
NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }}
3333
NAVER_SCOPE: ${{ secrets.NAVER_SCOPE }}
34+
NAVER_REDIRECT_URL: ${{secrets.NAVER_REDIRECT_URL}}
3435
JWT_SECRET: ${{ secrets.JWT_SECRET }}
36+
FRONT_URL: ${{secrets.FRONT_URL}}
37+
BACK_URL: ${{secrets.BACK_URL}}
3538

3639

3740
steps:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.somemore.auth.cookie;
2+
3+
import com.somemore.auth.jwt.domain.TokenType;
4+
import jakarta.servlet.http.HttpServletResponse;
5+
import lombok.RequiredArgsConstructor;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.http.ResponseCookie;
8+
import org.springframework.stereotype.Service;
9+
10+
@Service
11+
@RequiredArgsConstructor
12+
@Slf4j
13+
public class CookieService implements CookieUseCase {
14+
15+
@Override
16+
public void setAccessToken(HttpServletResponse response, String value) {
17+
ResponseCookie cookie = generateCookie(TokenType.ACCESS, value);
18+
response.addHeader("Set-Cookie", cookie.toString());
19+
}
20+
21+
@Override
22+
public void deleteAccessToken(HttpServletResponse response) {
23+
ResponseCookie cookie = generateCookie(TokenType.SIGNOUT, TokenType.SIGNOUT.name());
24+
response.addHeader("Set-Cookie", cookie.toString());
25+
}
26+
27+
private static ResponseCookie generateCookie(TokenType tokenType, String value) {
28+
return ResponseCookie.from(TokenType.ACCESS.name(), value) // 덮어쓰기 위해서 고정 값
29+
.httpOnly(true)
30+
.secure(true)
31+
.path("/")
32+
.maxAge(tokenType.getPeriodInSeconds())
33+
.sameSite("Lax")
34+
.build();
35+
}
36+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.somemore.auth.cookie;
2+
3+
import jakarta.servlet.http.HttpServletResponse;
4+
5+
public interface CookieUseCase {
6+
void setAccessToken(HttpServletResponse response, String value);
7+
8+
void deleteAccessToken(HttpServletResponse response);
9+
}

src/main/java/com/somemore/auth/cookie/SetCookieService.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/main/java/com/somemore/auth/cookie/SetCookieUseCase.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/main/java/com/somemore/auth/jwt/domain/TokenType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
@Getter
66
public enum TokenType {
77
ACCESS(1000 * 60 * 30),
8-
REFRESH(1000 * 60 * 60 * 24 * 7);
8+
REFRESH(1000 * 60 * 60 * 24 * 7),
9+
SIGNOUT(0);
910

1011
private final int period;
1112

src/main/java/com/somemore/auth/jwt/filter/JwtAuthFilter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.somemore.auth.jwt.filter;
22

3-
import com.somemore.auth.UserRole;
43
import com.somemore.auth.jwt.domain.EncodedToken;
54
import com.somemore.auth.jwt.exception.JwtErrorType;
65
import com.somemore.auth.jwt.exception.JwtException;

src/main/java/com/somemore/auth/UserRole.java renamed to src/main/java/com/somemore/auth/jwt/filter/UserRole.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.somemore.auth;
1+
package com.somemore.auth.jwt.filter;
22

33
public enum UserRole {
44
VOLUNTEER,

src/main/java/com/somemore/auth/jwt/refresh/manager/RedisRefreshTokenManager.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ public void save(RefreshToken refreshToken) {
2626
}
2727

2828
@Override
29-
public void removeRefreshToken(EncodedToken accessToken) {
30-
RefreshToken refreshToken = refreshTokenRepository.findByAccessToken(accessToken.value())
31-
.orElseThrow(() -> new JwtException(JwtErrorType.EXPIRED_TOKEN));
32-
33-
refreshTokenRepository.delete(refreshToken);
29+
public void removeRefreshToken(String userId) {
30+
refreshTokenRepository.findByUserId(userId)
31+
.ifPresent(refreshTokenRepository::delete);
3432
}
3533
}

0 commit comments

Comments
 (0)