Repository navigation
Feature/#28 gogole apple login #32
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
Changes from all commits
2f9b3f0
b0115dd
a258e51
4e769a7
0cd921f
238a625
af1e5b6
2b0e0e5
ee4ba51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,9 @@ | |
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.security.oauth2.jwt.Jwt; | ||
| import org.springframework.security.oauth2.jwt.JwtDecoder; | ||
| import org.springframework.security.oauth2.jwt.JwtException; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
|
|
@@ -47,8 +49,8 @@ public class AuthService { | |
| private final JwtDecoder appleJwtDecoder; | ||
| private final NicknameGenerator nicknameGenerator; | ||
|
|
||
| // @Value("${apple.client-id}") | ||
| // private String appleClientId; | ||
| @Value("${apple.client-id}") | ||
| private String appleClientId; | ||
|
|
||
| @Value("${google.android-id}") | ||
| private String googleAndroidId; | ||
|
|
@@ -224,10 +226,35 @@ private String getEmailFromIdToken(String idToken, PlatformType platformType, Lo | |
|
|
||
| } catch (GeneralSecurityException | IOException e) { | ||
| throw BusinessException.of(AuthErrorCode.GOOGLE_LOGIN_ERROR); | ||
| } catch (Exception e) { | ||
| throw BusinessException.of(AuthErrorCode.INVALID_TOKEN); | ||
| } | ||
| } | ||
| case APPLE -> { | ||
| //TODO Apple ๊ตฌํ ์์ | ||
| String clientId = appleClientId; | ||
|
|
||
| try { | ||
| Jwt jwt = appleJwtDecoder.decode(idToken); | ||
|
|
||
| if(!"https://appleid.apple.com".equals(jwt.getIssuer().toString())) { | ||
| throw BusinessException.of(AuthErrorCode.INVALID_TOKEN); | ||
| } | ||
|
|
||
| String aud = jwt.getAudience().get(0); | ||
| if (!aud.equals(clientId)) { | ||
| throw BusinessException.of(AuthErrorCode.INVALID_TOKEN); | ||
| } | ||
|
|
||
| Object emailObject = jwt.getClaims().get("email"); | ||
| if(emailObject == null) { | ||
| throw BusinessException.of(AuthErrorCode.NOT_EXISTS_EMAIL); | ||
| } | ||
| return emailObject.toString(); | ||
| } catch (JwtException e) { | ||
| throw BusinessException.of(AuthErrorCode.INVALID_TOKEN); | ||
| } catch (Exception e) { | ||
| throw BusinessException.of(AuthErrorCode.APPLE_LOGIN_ERROR); | ||
| } | ||
|
Comment on lines
+253
to
+257
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BusinessException์ ๋ค์ ์ก์์ ์๋ฌ ์ ๋ณด๊ฐ ์์ค๋ฉ๋๋ค.
} catch (JwtException e) {
+ log.warn("Apple JWT decoding failed: {}", e.getMessage());
throw BusinessException.of(AuthErrorCode.INVALID_TOKEN);
} catch (BusinessException e) {
- throw BusinessException.of(AuthErrorCode.APPLE_LOGIN_ERROR);
+ throw e;
+} catch (Exception e) {
+ log.error("Apple login error: {}", e.getMessage());
+ throw BusinessException.of(AuthErrorCode.APPLE_LOGIN_ERROR);
}๐ค Prompt for AI Agents |
||
| } | ||
| } | ||
| return null; | ||
|
|
||
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.
Audience ๋ฆฌ์คํธ ๋น์ด์๋ ๊ฒฝ์ฐ ๋ฐฉ์ด ์ฝ๋ ์ถ๊ฐ
jwt.getAudience()๊ฐ ๋น ๋ฆฌ์คํธ๋ฅผ ๋ฐํํ๋ฉดIndexOutOfBoundsException์ด ๋ฐ์ํ ์ ์์ต๋๋ค.๐ Committable suggestion
๐ค Prompt for AI Agents