Skip to content

Commit

Permalink
Merge pull request #32 from GDG-Hackathon-77ia/fix/kakaoFront
Browse files Browse the repository at this point in the history
fix: hard coding
  • Loading branch information
GitJIHO authored Nov 15, 2024
2 parents 1febbae + 8601209 commit 8997124
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions src/main/java/com/gdg/kkia/auth/service/KakaoApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@ public class KakaoApiService {
private final KakaoProperties kakaoProperties;

public String getAuthorizationUrl(HttpServletRequest httpServletRequest) {
String requestUrl = httpServletRequest.getHeader("Referer");
if (requestUrl == null) {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
}
String redirectUri;

if (requestUrl.contains(LOCALHOST_URL)) {
redirectUri = kakaoProperties.devRedirectUri();
} else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
redirectUri = kakaoProperties.redirectUri();
} else {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
}

// String requestUrl = httpServletRequest.getHeader("Referer");
// if (requestUrl == null) {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
// }
// String redirectUri;
//
// if (requestUrl.contains(LOCALHOST_URL)) {
// redirectUri = kakaoProperties.devRedirectUri();
// } else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
// redirectUri = kakaoProperties.redirectUri();
// } else {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
// }

String redirectUri = "https://ry-supabase.godopu.net/redirection";
//
return KAKAO_AUTH_BASE_URL + "/authorize?response_type=code&client_id="
+ kakaoProperties.clientId() + "&redirect_uri=" + redirectUri;
}
Expand All @@ -51,19 +53,21 @@ public KakaoTokenResponse getAccessToken(String authorizationCode, HttpServletRe
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

String requestUrl = httpServletRequest.getHeader("Origin");
if (requestUrl == null) {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
}
String redirectUri;

if (requestUrl.contains(LOCALHOST_URL)) {
redirectUri = kakaoProperties.devRedirectUri();
} else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
redirectUri = kakaoProperties.redirectUri();
} else {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
}
// String requestUrl = httpServletRequest.getHeader("Origin");
// if (requestUrl == null) {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
// }
// String redirectUri;
//
// if (requestUrl.contains(LOCALHOST_URL)) {
// redirectUri = kakaoProperties.devRedirectUri();
// } else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
// redirectUri = kakaoProperties.redirectUri();
// } else {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
// }

String redirectUri = "https://ry-supabase.godopu.net/redirection";

LinkedMultiValueMap<String, String> body = new LinkedMultiValueMap<>();
body.add("grant_type", "authorization_code");
Expand Down

0 comments on commit 8997124

Please sign in to comment.