-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor: MSA 전환에 유리하게 구조를 수정 #20
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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/project/flipnote/auth/controller/docs/AuthControllerDocs.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 project.flipnote.auth.controller.docs; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
| import project.flipnote.auth.model.ChangePasswordRequest; | ||
| import project.flipnote.auth.model.EmailVerificationConfirmRequest; | ||
| import project.flipnote.auth.model.EmailVerificationRequest; | ||
| import project.flipnote.auth.model.PasswordResetCreateRequest; | ||
| import project.flipnote.auth.model.PasswordResetRequest; | ||
| import project.flipnote.auth.model.UserLoginRequest; | ||
| import project.flipnote.auth.model.UserLoginResponse; | ||
| import project.flipnote.auth.model.UserRegisterRequest; | ||
| import project.flipnote.auth.model.UserRegisterResponse; | ||
| import project.flipnote.common.security.dto.AuthPrinciple; | ||
| import project.flipnote.user.model.SocialLinksResponse; | ||
|
|
||
| public interface AuthControllerDocs { | ||
|
|
||
| @Operation(summary = "회원가입") | ||
| ResponseEntity<UserRegisterResponse> register(UserRegisterRequest req); | ||
|
|
||
| @Operation(summary = "로그인") | ||
| ResponseEntity<UserLoginResponse> login(UserLoginRequest req); | ||
|
|
||
| @Operation(summary = "로그아웃", security = { @SecurityRequirement(name = "access-token") }) | ||
| ResponseEntity<Void> logout(); | ||
|
|
||
| @Operation(summary = "이메일 인증번호 전송") | ||
| ResponseEntity<Void> sendEmailVerificationCode(EmailVerificationRequest req); | ||
|
|
||
| @Operation(summary = "이메일 인증번호 확인") | ||
| ResponseEntity<Void> confirmEmailVerificationCode(EmailVerificationConfirmRequest req); | ||
|
|
||
| @Operation(summary = "토큰 갱신") | ||
| ResponseEntity<UserLoginResponse> refreshToken(String refreshToken); | ||
|
|
||
| @Operation(summary = "비밀번호 재설정 링크 전송") | ||
| ResponseEntity<Void> requestPasswordReset(PasswordResetCreateRequest req); | ||
|
|
||
| @Operation(summary = "비밀번호 재설정") | ||
| ResponseEntity<Void> resetPassword(PasswordResetRequest req); | ||
|
|
||
| @Operation(summary = "내 비밀번호 변경", security = { @SecurityRequirement(name = "access-token") }) | ||
| ResponseEntity<Void> updatePassword(AuthPrinciple userAuth, ChangePasswordRequest req); | ||
|
|
||
| @Operation(summary = "내 소셜 연동 계정 목록 조회", security = { @SecurityRequirement(name = "access-token") }) | ||
| ResponseEntity<SocialLinksResponse> getSocialLinks(AuthPrinciple userAuth); | ||
|
|
||
| @Operation(summary = "소셜 연동 해제", security = { @SecurityRequirement(name = "access-token") }) | ||
| ResponseEntity<Void> deleteSocialLink(AuthPrinciple userAuth, Long socialLinkId); | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/project/flipnote/auth/controller/docs/OAuthControllerDocs.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,28 @@ | ||
| package project.flipnote.auth.controller.docs; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import project.flipnote.common.security.dto.AuthPrinciple; | ||
|
|
||
| @Tag(name = "OAuth", description = "OAuth API") | ||
| public interface OAuthControllerDocs { | ||
|
|
||
| @Operation(summary = "소셜 인증 URL로 리다이렉트") | ||
| ResponseEntity<Void> redirectToProviderAuthorization( | ||
| String provider, | ||
| HttpServletRequest request, | ||
| AuthPrinciple userAuth | ||
| ); | ||
|
|
||
| @Operation(summary = "소셜 계정 연동 및 로그인") | ||
| ResponseEntity<Void> handleCallback( | ||
| String provider, | ||
| String code, | ||
| String state, | ||
| String codeVerifier, | ||
| HttpServletRequest request | ||
| ); | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/java/project/flipnote/auth/entity/AccountRole.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,14 @@ | ||
| package project.flipnote.auth.entity; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public enum AccountRole { | ||
| USER, ADMIN; | ||
|
|
||
| public static AccountRole from(String role) { | ||
| return Arrays.stream(AccountRole.values()) | ||
| .filter(r -> r.name().equalsIgnoreCase(role)) | ||
| .findFirst() | ||
| .orElse(null); | ||
| } | ||
| } | ||
8 changes: 8 additions & 0 deletions
8
src/main/java/project/flipnote/auth/entity/AccountStatus.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,8 @@ | ||
| package project.flipnote.auth.entity; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum AccountStatus { | ||
| ACTIVE, WITHDRAWN; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package project.flipnote.auth.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import project.flipnote.common.entity.SoftDeletableEntity; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Table(name = "user_auth") | ||
| @Entity | ||
| public class UserAuth extends SoftDeletableEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(unique = true, nullable = false) | ||
| private String email; | ||
|
|
||
| private String password; | ||
|
|
||
| @Column(unique = true, nullable = false) | ||
| private Long userId; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false) | ||
| private AccountStatus status; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false) | ||
| private AccountRole role; | ||
|
|
||
| @Column(nullable = false) | ||
| private long tokenVersion; | ||
|
|
||
| @Builder | ||
| public UserAuth( | ||
| String email, | ||
| String password, | ||
| Long userId | ||
| ) { | ||
| this.email = email; | ||
| this.password = password; | ||
| this.userId = userId; | ||
| this.status = AccountStatus.ACTIVE; | ||
| this.role = AccountRole.USER; | ||
| this.tokenVersion = 0L; | ||
| } | ||
|
|
||
| public void withdraw() { | ||
| super.softDelete(); | ||
|
|
||
| this.status = AccountStatus.WITHDRAWN; | ||
|
|
||
| increaseTokenVersion(); | ||
| } | ||
|
|
||
| public void increaseTokenVersion() { | ||
| this.tokenVersion++; | ||
| } | ||
|
|
||
| public void changePassword(String password) { | ||
| this.password = password; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.