Skip to content

Commit

Permalink
Merge pull request #144 from Nexters/feature/140
Browse files Browse the repository at this point in the history
common ํŒจํ‚ค์ง€ Global ํŒจํ‚ค์ง€๋กœ ๋ถ„๋ฆฌ ๋ฐ ์˜ˆ์™ธ์ฒ˜๋ฆฌ ํ”Œ๋กœ์šฐ ์žฌ์„ค๊ณ„
  • Loading branch information
RokwonK authored Aug 21, 2023
2 parents 5c91029 + c708c7e commit e397d3a
Show file tree
Hide file tree
Showing 226 changed files with 1,154 additions and 1,077 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nexters.keyme.domain.auth.application;


import com.nexters.keyme.domain.auth.presentation.dto.request.LoginRequest;
import com.nexters.keyme.domain.member.presentation.dto.response.MemberWithTokenResponse;

public interface AuthService {
MemberWithTokenResponse getMemberWithToken(LoginRequest request);
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.nexters.keyme.auth.application;
package com.nexters.keyme.domain.auth.application;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nexters.keyme.auth.domain.client.AppleClient;
import com.nexters.keyme.auth.domain.client.KakaoClient;
import com.nexters.keyme.auth.domain.internaldto.AppleJwtBodyInfo;
import com.nexters.keyme.auth.domain.internaldto.OAuthUserInfo;
import com.nexters.keyme.auth.presentation.dto.request.LoginRequest;
import com.nexters.keyme.auth.presentation.dto.response.AppleAuthKeysResponse;
import com.nexters.keyme.auth.presentation.dto.response.KakaoUserInfoResponse;
import com.nexters.keyme.auth.presentation.dto.response.TokenResponse;
import com.nexters.keyme.auth.domain.helper.ApplePublicKeyProvider;
import com.nexters.keyme.common.util.JwtTokenProvider;
import com.nexters.keyme.common.enums.OAuthType;
import com.nexters.keyme.member.application.MemberService;
import com.nexters.keyme.member.presentation.dto.response.MemberWithTokenResponse;
import com.nexters.keyme.domain.auth.domain.client.AppleClient;
import com.nexters.keyme.domain.auth.domain.client.KakaoClient;
import com.nexters.keyme.domain.auth.domain.exceptions.InvalidAppleTokenException;
import com.nexters.keyme.domain.auth.domain.internaldto.AppleJwtBodyInfo;
import com.nexters.keyme.domain.auth.domain.internaldto.OAuthUserInfo;
import com.nexters.keyme.domain.auth.presentation.dto.request.LoginRequest;
import com.nexters.keyme.domain.auth.presentation.dto.response.AppleAuthKeysResponse;
import com.nexters.keyme.domain.auth.presentation.dto.response.KakaoUserInfoResponse;
import com.nexters.keyme.domain.auth.presentation.dto.response.TokenResponse;
import com.nexters.keyme.domain.auth.domain.helper.ApplePublicKeyProvider;
import com.nexters.keyme.global.util.JwtTokenProvider;
import com.nexters.keyme.global.enums.OAuthType;
import com.nexters.keyme.domain.member.application.MemberService;
import com.nexters.keyme.domain.member.presentation.dto.response.MemberWithTokenResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -49,8 +50,6 @@ public MemberWithTokenResponse getMemberWithToken(LoginRequest request) {
TokenResponse tokenObject = new TokenResponse(jwtToken);
memberResponse.setToken(tokenObject);

// refresh ํ† ํฐ์ •์ฑ… ์žˆ์œผ๋ฉด member์— ์ €์žฅ

return memberResponse;
}

Expand All @@ -60,18 +59,20 @@ private OAuthUserInfo getOAuthInfoOfApple(String identityToken) {
PublicKey key = applePublicKeyProvider.getPublicKey(jwtHeaderString, authKeys);
Boolean isVerified = jwtTokenProvider.verifyToken(identityToken, key);

if (!isVerified) { throw new RuntimeException(); }
if (!isVerified) {
throw new InvalidAppleTokenException();
}

String jwtBodyString = jwtTokenProvider.extractJwtBodyString(identityToken);
try {
String jwtBodyString = jwtTokenProvider.extractJwtBodyString(identityToken);
AppleJwtBodyInfo jwtBody = objectMapper.readValue(jwtBodyString, AppleJwtBodyInfo.class);

return OAuthUserInfo.builder()
.id(jwtBody.getSub())
.oauthType(OAuthType.APPLE)
.build();
} catch(JsonProcessingException e) {
throw new RuntimeException();
throw new InvalidAppleTokenException();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.nexters.keyme.auth.domain.client;
package com.nexters.keyme.domain.auth.domain.client;

import com.nexters.keyme.auth.presentation.dto.response.AppleAuthKeysResponse;
import com.nexters.keyme.domain.auth.presentation.dto.response.AppleAuthKeysResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.nexters.keyme.auth.domain.client;
package com.nexters.keyme.domain.auth.domain.client;

import com.nexters.keyme.auth.presentation.dto.response.KakaoUserInfoResponse;
import com.nexters.keyme.domain.auth.presentation.dto.response.KakaoUserInfoResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.nexters.keyme.domain.auth.domain.exceptions;

import com.nexters.keyme.domain.auth.domain.exceptions.code.AuthErrorCode;
import com.nexters.keyme.global.exceptions.KeymeBadRequestException;

public class InvalidAppleKeyException extends KeymeBadRequestException {
public InvalidAppleKeyException() {
super(AuthErrorCode.INVALID_APPLE_KEY.getMessage(), AuthErrorCode.INVALID_APPLE_KEY.getCode());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.nexters.keyme.domain.auth.domain.exceptions;

import com.nexters.keyme.domain.auth.domain.exceptions.code.AuthErrorCode;
import com.nexters.keyme.global.exceptions.KeymeBadRequestException;
import org.springframework.http.HttpStatus;

public class InvalidAppleTokenException extends KeymeBadRequestException {
public InvalidAppleTokenException() {
super(AuthErrorCode.INVALID_APPLE_TOKEN.getMessage(), AuthErrorCode.INVALID_APPLE_TOKEN.getCode());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.nexters.keyme.domain.auth.domain.exceptions.code;


import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum AuthErrorCode {
INVALID_APPLE_TOKEN(400, "์ž˜๋ชป๋œ IdentityToken ์ž…๋‹ˆ๋‹ค."),
INVALID_APPLE_KEY(400, "IdentityToken ๊ฒ€์ฆ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.");

private final int code;
private final String message;
}
Loading

0 comments on commit e397d3a

Please sign in to comment.