-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/53 add volunteer signin signout #62
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
dd7dd47
refactor(package): ํจํค์ง ์ด๋
m-a-king 8fb254c
style(ApiResponse): ๋ถํ์ํ ๊ฐํ ์ ๊ฑฐ
m-a-king c54b569
feat(application.yml): front, back root url ์ถ๊ฐ
m-a-king e27ff41
refactor(package): ํจํค์ง ์ด๋
m-a-king 0304e08
feat(cookie): ์ฟ ํค ์ญ์ (๋ฎ์ด์์ฐ๊ธฐ), ํ ํฐ ํ์
์ถ๊ฐ(SIGNOUT), ํ์ผ๋ช
๋ณ๊ฒฝ
m-a-king 5be1096
feat(RefreshToken): ๋ฆฌํ๋ ์ ํ ํฐ ์ญ์ ์์
m-a-king a5c6dd6
feat(SignOut): ๋ก๊ทธ์์ ๋ก์ง ๊ตฌํ ๋ฐ ๋ฆฌํ๋ ์ ํ ํฐ ์ญ์ ์ฒ๋ฆฌ
m-a-king d1fa733
test(CookieService): ์ก์ธ์ค ํ ํฐ ์ค์ ๋ฐ ์ญ์ ๋ก์ง ํ
์คํธ ์ถ๊ฐ
m-a-king d5402ba
feat(OAuth): OAuth URL ์์ฑ ์๋น์ค ๊ตฌํ
m-a-king dc819bf
test(GenerateOAuthUrlService): OAuth URL ์์ฑ ๋ก์ง ํ
์คํธ ์ถ๊ฐ
m-a-king 3a027a9
test(SignOutVolunteerService): ๋ก๊ทธ์์ ๋์ ํ
์คํธ ์ถ๊ฐ
m-a-king 535e62a
feat(application.yml): front/back url ๋ณ์ ์ฒ๋ฆฌ
m-a-king 0e9e667
feat(VolunteerSignController): OAuth ๋ก๊ทธ์ธ ๋ฐ ๋ก๊ทธ์์ API ์ถ๊ฐ
m-a-king ec45506
feat(application.yml): naver-redirect-uri ๋ณ์ ์ฒ๋ฆฌ
m-a-king 317e6ac
CICD/ ํ๊ฒฝ ๋ณ์ ์ถ๊ฐ (#61)
7zrv 195e39c
refactor(package): C/Q ๊ตฌ๋ถ ์ญ์
m-a-king 300c301
feat(application.yml): UTF-8, KR ์ค์
m-a-king 10cd790
test(VolunteerSignController): OAuth ๋ก๊ทธ์ธ ๋ฐ ๋ก๊ทธ์์ ํตํฉ ํ
์คํธ ์ถ๊ฐ
m-a-king 6de2b86
test(@Transactional): ๋ถํ์ํ ํธ๋์ญ์
์ด๋
ธํ
์ด์
์ญ์
m-a-king 851a2c2
refactor: ๋ถํ์ํ ์ด๋
ธํ
์ด์
์ญ์
m-a-king 1b21234
refactor(package): ํจํค์ง ์ด๋
m-a-king d21e31f
style(ApiResponse): ๋ถํ์ํ ๊ฐํ ์ ๊ฑฐ
m-a-king 5bbb1fa
feat(application.yml): front, back root url ์ถ๊ฐ
m-a-king 72d5bb1
refactor(package): ํจํค์ง ์ด๋
m-a-king 7ffd3e2
feat(cookie): ์ฟ ํค ์ญ์ (๋ฎ์ด์์ฐ๊ธฐ), ํ ํฐ ํ์
์ถ๊ฐ(SIGNOUT), ํ์ผ๋ช
๋ณ๊ฒฝ
m-a-king e905d84
feat(RefreshToken): ๋ฆฌํ๋ ์ ํ ํฐ ์ญ์ ์์
m-a-king 10cf398
feat(SignOut): ๋ก๊ทธ์์ ๋ก์ง ๊ตฌํ ๋ฐ ๋ฆฌํ๋ ์ ํ ํฐ ์ญ์ ์ฒ๋ฆฌ
m-a-king ccf9c70
test(CookieService): ์ก์ธ์ค ํ ํฐ ์ค์ ๋ฐ ์ญ์ ๋ก์ง ํ
์คํธ ์ถ๊ฐ
m-a-king 833c61d
feat(OAuth): OAuth URL ์์ฑ ์๋น์ค ๊ตฌํ
m-a-king cb454b0
test(GenerateOAuthUrlService): OAuth URL ์์ฑ ๋ก์ง ํ
์คํธ ์ถ๊ฐ
m-a-king bf88735
test(SignOutVolunteerService): ๋ก๊ทธ์์ ๋์ ํ
์คํธ ์ถ๊ฐ
m-a-king e2d337d
feat(application.yml): front/back url ๋ณ์ ์ฒ๋ฆฌ
m-a-king ce63e59
feat(VolunteerSignController): OAuth ๋ก๊ทธ์ธ ๋ฐ ๋ก๊ทธ์์ API ์ถ๊ฐ
m-a-king 9a86240
feat(application.yml): naver-redirect-uri ๋ณ์ ์ฒ๋ฆฌ
m-a-king 8cd40c9
refactor(package): C/Q ๊ตฌ๋ถ ์ญ์
m-a-king 62f20b8
feat(application.yml): UTF-8, KR ์ค์
m-a-king 15d8dd0
test(VolunteerSignController): OAuth ๋ก๊ทธ์ธ ๋ฐ ๋ก๊ทธ์์ ํตํฉ ํ
์คํธ ์ถ๊ฐ
m-a-king c6fb434
test(@Transactional): ๋ถํ์ํ ํธ๋์ญ์
์ด๋
ธํ
์ด์
์ญ์
m-a-king 0c8bf5c
refactor: ๋ถํ์ํ ์ด๋
ธํ
์ด์
์ญ์
m-a-king fe96db1
refactor: ๋ถํ์ํ import ์ ๊ฑฐ
m-a-king ec42aa4
Merge remote-tracking branch 'origin/feature/53-add-volunteer-signin-โฆ
m-a-king 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
This file contains hidden or 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,36 @@ | ||
| package com.somemore.auth.cookie; | ||
|
|
||
| import com.somemore.auth.jwt.domain.TokenType; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.ResponseCookie; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class CookieService implements CookieUseCase { | ||
|
|
||
| @Override | ||
| public void setAccessToken(HttpServletResponse response, String value) { | ||
| ResponseCookie cookie = generateCookie(TokenType.ACCESS, value); | ||
| response.addHeader("Set-Cookie", cookie.toString()); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteAccessToken(HttpServletResponse response) { | ||
| ResponseCookie cookie = generateCookie(TokenType.SIGNOUT, TokenType.SIGNOUT.name()); | ||
| response.addHeader("Set-Cookie", cookie.toString()); | ||
| } | ||
|
|
||
| private static ResponseCookie generateCookie(TokenType tokenType, String value) { | ||
| return ResponseCookie.from(TokenType.ACCESS.name(), value) // ๋ฎ์ด์ฐ๊ธฐ ์ํด์ ๊ณ ์ ๊ฐ | ||
| .httpOnly(true) | ||
| .secure(true) | ||
| .path("/") | ||
| .maxAge(tokenType.getPeriodInSeconds()) | ||
| .sameSite("Lax") | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or 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,9 @@ | ||
| package com.somemore.auth.cookie; | ||
|
|
||
| import jakarta.servlet.http.HttpServletResponse; | ||
|
|
||
| public interface CookieUseCase { | ||
| void setAccessToken(HttpServletResponse response, String value); | ||
|
|
||
| void deleteAccessToken(HttpServletResponse response); | ||
| } |
30 changes: 0 additions & 30 deletions
30
src/main/java/com/somemore/auth/cookie/SetCookieService.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...main/java/com/somemore/auth/UserRole.java โ ...om/somemore/auth/jwt/filter/UserRole.java
This file contains hidden or 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,4 +1,4 @@ | ||
| package com.somemore.auth; | ||
| package com.somemore.auth.jwt.filter; | ||
|
|
||
| public enum UserRole { | ||
| VOLUNTEER, | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
53 changes: 53 additions & 0 deletions
53
src/main/java/com/somemore/volunteer/controller/query/VolunteerSignController.java
This file contains hidden or 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,53 @@ | ||
| package com.somemore.volunteer.controller.query; | ||
|
|
||
| import com.somemore.global.common.response.ApiResponse; | ||
| import com.somemore.global.exception.BadRequestException; | ||
| import com.somemore.volunteer.usecase.SignOutVolunteerUseCase; | ||
| import com.somemore.volunteer.usecase.GenerateOAuthUrlUseCase; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import org.springframework.web.servlet.view.RedirectView; | ||
|
|
||
| @RestController | ||
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/volunteer") | ||
| @Tag(name = "Volunteer OAuth API", description = "Handles Volunteer OAuth Sign-in, Sign-out") | ||
| public class VolunteerSignController { | ||
|
|
||
| private final GenerateOAuthUrlUseCase generateOAuthUrlUseCase; | ||
| private final SignOutVolunteerUseCase signOutVolunteerUseCase; | ||
|
|
||
| @PostMapping("/sign-in/oauth/{oauthProvider}") | ||
| public RedirectView signIn( | ||
| @Parameter(name = "oauthProvider", description = "OAuth ์ ๊ณต์ ์ ํ", example = "naver", required = true, schema = @Schema(allowableValues = {"naver"})) | ||
| @PathVariable("oauthProvider") String oauthProvider) { | ||
|
|
||
| String redirectUrl = switch (oauthProvider.toLowerCase()) { | ||
| case "naver" -> generateOAuthUrlUseCase.generateUrl(oauthProvider); | ||
|
|
||
| default -> throw new BadRequestException("์ง์๋์ง ์๋ OAuth ์ ๊ณต์: " + oauthProvider); | ||
| }; | ||
|
|
||
| return new RedirectView(redirectUrl); | ||
| } | ||
|
|
||
| @PostMapping("/sign-out") | ||
| public ApiResponse<?> signOut( | ||
| HttpServletResponse response, | ||
| @AuthenticationPrincipal String userId) { | ||
|
|
||
| signOutVolunteerUseCase.signOut(response, userId); | ||
|
|
||
| return ApiResponse.ok("๋ก๊ทธ์์๋์์ต๋๋ค"); | ||
| } | ||
| } |
4 changes: 2 additions & 2 deletions
4
...service/query/FindVolunteerIdService.java โ ...nteer/service/FindVolunteerIdService.java
This file contains hidden or 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
32 changes: 32 additions & 0 deletions
32
src/main/java/com/somemore/volunteer/service/GenerateOAuthUrlService.java
This file contains hidden or 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,32 @@ | ||
| package com.somemore.volunteer.service; | ||
|
|
||
| import com.somemore.volunteer.usecase.GenerateOAuthUrlUseCase; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.web.util.UriComponentsBuilder; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GenerateOAuthUrlService implements GenerateOAuthUrlUseCase { | ||
|
|
||
| @Value("${app.back-url}") | ||
| private String backendRootUrl; | ||
|
|
||
| @Override | ||
| public String generateUrl(String oAuthProvider) { | ||
| return UriComponentsBuilder.fromHttpUrl(generateBaseUrl()) | ||
| .pathSegment(oAuthProvider) | ||
| .build() | ||
| .toUriString(); | ||
| } | ||
|
|
||
| private String generateBaseUrl() { | ||
| return UriComponentsBuilder.fromHttpUrl(backendRootUrl) | ||
| .path("/oauth2/authorization") | ||
| .build() | ||
| .toUriString(); | ||
| } | ||
| } |
4 changes: 2 additions & 2 deletions
4
...ice/command/RegisterVolunteerService.java โ ...eer/service/RegisterVolunteerService.java
This file contains hidden or 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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/somemore/volunteer/service/SignOutVolunteerService.java
This file contains hidden or 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,30 @@ | ||
| package com.somemore.volunteer.service; | ||
|
|
||
| import com.somemore.auth.cookie.CookieUseCase; | ||
| import com.somemore.auth.jwt.refresh.manager.RefreshTokenManager; | ||
| import com.somemore.volunteer.usecase.SignOutVolunteerUseCase; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| public class SignOutVolunteerService implements SignOutVolunteerUseCase { | ||
|
|
||
| private final CookieUseCase cookieUseCase; | ||
| private final RefreshTokenManager refreshTokenManager; | ||
|
|
||
| @Override | ||
| public void signOut( | ||
| HttpServletResponse response, | ||
| @AuthenticationPrincipal String volunteerId) { | ||
|
|
||
| cookieUseCase.deleteAccessToken(response); | ||
| refreshTokenManager.removeRefreshToken(volunteerId); | ||
| } | ||
| } | ||
2 changes: 1 addition & 1 deletion
2
...usecase/query/FindVolunteerIdUseCase.java โ ...nteer/usecase/FindVolunteerIdUseCase.java
This file contains hidden or 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
Oops, something went wrong.
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.
์ปจํธ๋กค๋ฌ์์ @AuthenticationPrincipal ์ผ๋ก Id ์ฃผ์ ๋ฐ์์
์ฌ๊ธฐ์์๋ ์ด๋ ธํ ์ด์ ์์ด๋ ๋ ๊ฒ ๊ฐ์ต๋๋น.
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.
์ ๋ง๋ค์! ์ปจํธ๋กค๋ฌ์์ ๋ณต๋ถํ๋ค๊ฐ ์ด์ํจ์ ๋๋ผ์ง ๋ชปํ๋๋ด์