-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
160 additions
and
38 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
48 changes: 48 additions & 0 deletions
48
backend/src/main/java/mouda/backend/auth/presentation/controller/AppleAuthController.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,48 @@ | ||
package mouda.backend.auth.presentation.controller; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import mouda.backend.auth.business.AppleAuthService; | ||
import mouda.backend.auth.util.TokenDecoder; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class AppleAuthController { | ||
|
||
private final AppleAuthService appleAuthService; | ||
private final ObjectMapper objectMapper; | ||
|
||
@PostMapping("/v1/oauth/apple") | ||
public ResponseEntity<Void> test( | ||
@RequestParam("code") String code, | ||
@RequestParam("id_token") String id_token, | ||
@RequestParam("user") String user | ||
) throws IOException { | ||
AppleUserInfoRequest request = objectMapper.readValue(user, AppleUserInfoRequest.class); | ||
|
||
String firstName = request.name().firstName(); | ||
String lastName = request.name().lastName(); | ||
Map<String, String> stringStringMap = TokenDecoder.parseIdToken(id_token); | ||
for (String s : stringStringMap.keySet()) { | ||
log.info("{} : {}", s, stringStringMap.get(s)); | ||
} | ||
log.error("firstName : {}, lastNAme: {}", firstName, lastName); | ||
String accessToken = appleAuthService.save(id_token, firstName, lastName); | ||
HttpHeaders httpHeaders = new HttpHeaders(); | ||
httpHeaders.add("Location", "https://dev.mouda.site/oauth/apple?token=" + accessToken); | ||
return new ResponseEntity<>(httpHeaders, HttpStatus.FOUND); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/mouda/backend/auth/presentation/controller/AppleUserInfoRequest.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,7 @@ | ||
package mouda.backend.auth.presentation.controller; | ||
|
||
public record AppleUserInfoRequest( | ||
AppleUserNameRequest name, | ||
String email | ||
) { | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/mouda/backend/auth/presentation/controller/AppleUserNameRequest.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,7 @@ | ||
package mouda.backend.auth.presentation.controller; | ||
|
||
public record AppleUserNameRequest( | ||
String firstName, | ||
String lastName | ||
) { | ||
} |
9 changes: 1 addition & 8 deletions
9
backend/src/main/java/mouda/backend/auth/presentation/request/AppleOauthRequest.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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
package mouda.backend.auth.presentation.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record AppleOauthRequest( | ||
Long memberId, | ||
|
||
@NotNull | ||
String code, | ||
|
||
@NotNull | ||
String name | ||
String nonce | ||
) { | ||
} |
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
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
24 changes: 24 additions & 0 deletions
24
backend/src/test/java/mouda/backend/darakbangmember/domain/DarakbangMemberTest.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,24 @@ | ||
package mouda.backend.darakbangmember.domain; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import mouda.backend.common.fixture.DarakbangSetUp; | ||
import mouda.backend.darakbangmember.exception.DarakbangMemberException; | ||
|
||
class DarakbangMemberTest extends DarakbangSetUp { | ||
|
||
@DisplayName("닉네임은 10글자 미만 이여야 한다.") | ||
@Test | ||
void invalidNickName() { | ||
assertThatThrownBy(() -> new DarakbangMember( | ||
darakbang, 10L, | ||
"hogeehogeehgoee", " ", | ||
" ", DarakBangMemberRole.MEMBER)) | ||
.isInstanceOf(DarakbangMemberException.class) | ||
.hasMessage("닉네임은 9글자 이하로만 가능합니다."); | ||
} | ||
|
||
} |