Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
.queryParam("refreshToken", refreshToken)
.build().toUriString();


response.sendRedirect(targetUri);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -44,7 +45,14 @@ public void redirectToProvider(
request.getSession().setAttribute("redirect_uri", redirect_uri);
}

response.sendRedirect("/oauth2/authorization/" + provider);
String target = UriComponentsBuilder.newInstance()
.scheme("https")
.host("ezcode.my")
.path("/oauth2/authorization/" + provider)
.build()
.toUriString();
response.sendRedirect(target);

Comment on lines +48 to +55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

URL 생성 로직은 올바르지만 하드코딩된 도메인을 개선할 수 있습니다.

UriComponentsBuilder를 사용한 절대 URL 생성은 올바르게 구현되었습니다. 하지만 "ezcode.my" 도메인이 하드코딩되어 있어 환경별 유연성이 떨어집니다.

다음과 같이 설정을 통해 도메인을 관리하는 것을 고려해보세요:

+@Value("${app.domain:ezcode.my}")
+private String appDomain;

 String target = UriComponentsBuilder.newInstance()
     .scheme("https")
-    .host("ezcode.my")
+    .host(appDomain)
     .path("/oauth2/authorization/" + provider)
     .build()
     .toUriString();

그리고 application.yml에서 환경별로 설정:

app:
  domain: ezcode.my  # 또는 환경별 도메인
🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/presentation/usermanagement/OAuth2Controller.java
around lines 48 to 55, the domain "ezcode.my" is hardcoded in the URL
construction, reducing flexibility across environments. Refactor the code to
inject the domain value from a configuration property, such as one defined in
application.yml under app.domain, and use this injected property in
UriComponentsBuilder instead of the hardcoded string.

}

private boolean isValidRedirectUri(String uri) {
Expand Down