-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/BSVR-232
# Conflicts: # .gitignore # application/build.gradle.kts # application/src/main/java/org/depromeet/spot/application/common/config/SecurityConfig.java # application/src/main/resources/application.yaml
- Loading branch information
Showing
43 changed files
with
1,077 additions
and
53 deletions.
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
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
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
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
6 changes: 6 additions & 0 deletions
6
application/src/main/java/org/depromeet/spot/application/common/jwt/JwtProperties.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,6 @@ | ||
package org.depromeet.spot.application.common.jwt; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "spring.jwt") | ||
public record JwtProperties(String secret) {} |
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
76 changes: 76 additions & 0 deletions
76
...ation/src/main/java/org/depromeet/spot/application/member/controller/OauthController.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,76 @@ | ||
package org.depromeet.spot.application.member.controller; | ||
|
||
import jakarta.validation.Valid; | ||
|
||
import org.depromeet.spot.application.common.jwt.JwtTokenUtil; | ||
import org.depromeet.spot.application.member.dto.request.RegisterV2Req; | ||
import org.depromeet.spot.application.member.dto.response.JwtTokenResponse; | ||
import org.depromeet.spot.domain.member.Member; | ||
import org.depromeet.spot.domain.member.enums.SnsProvider; | ||
import org.depromeet.spot.usecase.port.in.oauth.OauthUsecase; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@Tag(name = "(v2) Oauth") | ||
public class OauthController { | ||
|
||
private final OauthUsecase oauthUsecase; | ||
|
||
private final JwtTokenUtil jwtTokenUtil; | ||
|
||
@PostMapping("/api/v2/members") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "Member 회원가입 API") | ||
public JwtTokenResponse create(@RequestBody @Valid RegisterV2Req request) { | ||
|
||
Member member = request.toDomain(); | ||
Member memberResult = oauthUsecase.create(request.accessToken(), member); | ||
|
||
return new JwtTokenResponse(jwtTokenUtil.getJWTToken(memberResult)); | ||
} | ||
|
||
@GetMapping("/api/v2/members/{snsProvider}/{token}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Member 로그인 API") | ||
public JwtTokenResponse login( | ||
@PathVariable("snsProvider") | ||
@Parameter(name = "snsProvider", description = "KAKAO/GOOGLE", required = true) | ||
SnsProvider snsProvider, | ||
@PathVariable("token") | ||
@Parameter( | ||
name = "token", | ||
description = "sns 카카오는 accessToken, 구글은 authToken", | ||
required = true) | ||
String token) { | ||
|
||
Member member = oauthUsecase.login(snsProvider, token); | ||
return new JwtTokenResponse(jwtTokenUtil.getJWTToken(member)); | ||
} | ||
|
||
// TODO : /api/v2/members를 RequestMapping으로 빼면 구글 로그인에서 4xx Exception 발생 | ||
@GetMapping("/api/v2/members/authorization/{snsProvider}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "(백엔드용)accessToken을 받아오기 위한 API") | ||
public String getAccessToken2( | ||
@PathVariable("snsProvider") SnsProvider snsProvider, @RequestParam String code) { | ||
String token = oauthUsecase.getOauthAccessToken(snsProvider, code); | ||
log.info("snsProvider : {}", snsProvider); | ||
log.info("token : \n{}", token); | ||
return token; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...cation/src/main/java/org/depromeet/spot/application/member/dto/request/RegisterV2Req.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,35 @@ | ||
package org.depromeet.spot.application.member.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
import org.depromeet.spot.domain.member.Member; | ||
import org.depromeet.spot.domain.member.enums.SnsProvider; | ||
import org.hibernate.validator.constraints.Length; | ||
import org.hibernate.validator.constraints.Range; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record RegisterV2Req( | ||
@NotNull(message = "인가 accessToken는 필수 값입니다.") @Schema(description = "카카오 인증 accessToken") | ||
String accessToken, | ||
@NotNull(message = "닉네임 값은 필수입니다.") | ||
@Schema(description = "설정하려는 닉네임") | ||
@Length(min = 2, max = 10, message = "닉네임은 2글자에서 10글자 사이여야합니다.") | ||
@Pattern( | ||
regexp = "^[a-zA-Z0-9가-힣]*$", | ||
message = "닉네임은 알파벳 대소문자, 숫자, 한글만 허용하며, 공백은 불가능합니다.") | ||
String nickname, | ||
@Schema(description = "응원 팀 pk") | ||
@Range( | ||
min = 1, | ||
max = 10, | ||
message = "응원 팀은 null(모두 응원), 1번(두산 베어스)부터 10번(NC 다이노스)까지 입니다.") | ||
Long teamId, | ||
@NotNull(message = "SNS Provider는 필수 값입니다.") @Schema(description = "KAKAO/GOOGLE") | ||
SnsProvider snsProvider) { | ||
|
||
public Member toDomain() { | ||
return Member.builder().nickname(nickname).teamId(teamId).snsProvider(snsProvider).build(); | ||
} | ||
} |
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
Oops, something went wrong.