-
Notifications
You must be signed in to change notification settings - Fork 2
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
[BE] docs: GitHub 연동, 자신이 만든 리뷰 그룹 목록 조회 API 문서 작성 #1014
Open
donghoony
wants to merge
8
commits into
develop
Choose a base branch
from
be/docs/1013-github-api-docs
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ebe88bd
docs: 자신이 만든 리뷰 그룹 목록 조회 API 문서 작성
donghoony 7a88257
chore: 생성일자 최신순 정렬 할일
donghoony 772589e
fix: 문서에서 최신순 정렬
donghoony 98c0fff
fix: 문서에서 최신순 정렬
donghoony cfff7a4
docs: 인증 api 문서 작성
nayonsoso 2afa5a2
docs: 내 프로필 api 문서 작성
nayonsoso 6a7f683
refactor: 세션이 null인 경우 방지
nayonsoso 22827a3
refactor: 로그아웃 구현 제거
nayonsoso 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 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,7 @@ | ||
==== 깃허브로 로그인/회원가입 | ||
|
||
operation::github-auth[snippets="curl-request,request-fields,http-response"] | ||
|
||
==== 로그아웃 | ||
|
||
operation::logout[snippets="curl-request,request-cookies,http-response"] |
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 |
---|---|---|
|
@@ -40,3 +40,7 @@ include::review-gather.adoc[] | |
=== 답변 하이라이트 | ||
|
||
include::highlight-answers.adoc[] | ||
|
||
== 인증 | ||
|
||
include::auth.adoc[] |
49 changes: 49 additions & 0 deletions
49
backend/src/main/java/reviewme/auth/controller/AuthController.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,49 @@ | ||
package reviewme.auth.controller; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpSession; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.ResponseCookie; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import reviewme.auth.service.AuthService; | ||
import reviewme.auth.service.dto.GithubCodeRequest; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class AuthController { | ||
|
||
private final AuthService authService; | ||
|
||
@PostMapping("/v2/auth/github") | ||
public ResponseEntity<Void> authWithGithub( | ||
@Valid @RequestBody GithubCodeRequest request, | ||
HttpServletRequest httpRequest | ||
) { | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@PostMapping("/v2/auth/logout") | ||
public ResponseEntity<Void> logout( | ||
HttpServletRequest httpRequest | ||
) { | ||
HttpSession session = httpRequest.getSession(); | ||
session.invalidate(); | ||
nayonsoso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ResponseCookie cookie = ResponseCookie.from("JSESSIONID", "") | ||
.path("/") | ||
.maxAge(0) | ||
.secure(true) | ||
.httpOnly(true) | ||
.build(); | ||
|
||
return ResponseEntity | ||
.noContent() | ||
.header(HttpHeaders.SET_COOKIE, cookie.toString()) | ||
.build(); | ||
} | ||
nayonsoso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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,7 @@ | ||
package reviewme.auth.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class AuthService { | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/reviewme/auth/service/dto/GithubCodeRequest.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,8 @@ | ||
package reviewme.auth.service.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record GithubCodeRequest( | ||
@NotBlank(message = "깃허브 임시 코드를 입력해주세요.") | ||
String code) { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package reviewme.api; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; | ||
import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.restdocs.cookies.CookieDescriptor; | ||
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; | ||
import org.springframework.restdocs.payload.FieldDescriptor; | ||
|
||
public class AuthApiTest extends ApiTest { | ||
|
||
@Test | ||
void 깃허브로_인증한다() { | ||
String request = """ | ||
{ | ||
"code": "github_auth_code" | ||
} | ||
"""; | ||
|
||
FieldDescriptor[] requestFieldDescriptors = { | ||
fieldWithPath("code").description("깃허브 임시 인증 코드"), | ||
}; | ||
|
||
RestDocumentationResultHandler handler = document( | ||
"github-auth", | ||
requestFields(requestFieldDescriptors) | ||
); | ||
|
||
givenWithSpec().log().all() | ||
.body(request) | ||
.when().post("/v2/auth/github") | ||
.then().log().all() | ||
.apply(handler) | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
void 로그아웃한다() { | ||
CookieDescriptor[] cookieDescriptors = { | ||
cookieWithName("JSESSIONID").description("세션 ID") | ||
}; | ||
|
||
RestDocumentationResultHandler handler = document( | ||
"logout", | ||
requestCookies(cookieDescriptors) | ||
); | ||
|
||
givenWithSpec().log().all() | ||
.cookie("JSESSIONID", "SESSION12345678") | ||
.when().post("/v2/auth/logout") | ||
.then().log().all() | ||
.apply(handler) | ||
.statusCode(204) | ||
.header("Set-Cookie", containsString("JSESSIONID=; Path=/; Max-Age=0")); | ||
} | ||
} |
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.
산초가 올려준 디스커션의 인증 과정중 아래의 1~3번을 이 메서드에서 모두 하는것인지 궁금해요!(아직 구현이 안해서 헷갈려서 물어봅니당)
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.
네 맞아요👍
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.
혹시 이때 사용자 정보나 로그인 정보같은 것은 안내려줘도 괜찮나요?
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.
@Kimprodp
사용자 정보를 따로 넘겨주기보다, 클라이언트와는 JSESSION_ID로만 로그인한 사용자에 대한 통신을 하면 된다 생각해요!