-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 요청실패시 /login?error 로 리다이렉팅 되는 에러 수정
기본 FailureHandler가 위 url로 리다이렉팅 되도록 구현되어 있으므로 직접 구현해서 200응답을 반환하도록 변경하였다.
- Loading branch information
1 parent
374b4a8
commit 0e0a2fd
Showing
2 changed files
with
35 additions
and
1 deletion.
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
31 changes: 31 additions & 0 deletions
31
backend/src/main/java/aimo/backend/common/security/oAuth/OAuth2LoginFailureHandler.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,31 @@ | ||
package aimo.backend.common.security.oAuth; | ||
|
||
import java.io.IOException; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.core.AuthenticationException; | ||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; | ||
import org.springframework.stereotype.Component; | ||
|
||
import aimo.backend.common.dto.DataResponse; | ||
import aimo.backend.common.util.responseWriter.ResponseWriter; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Component | ||
public class OAuth2LoginFailureHandler extends SimpleUrlAuthenticationFailureHandler { | ||
|
||
@Override | ||
public void onAuthenticationFailure( | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
AuthenticationException exception | ||
) { | ||
|
||
log.error("OAuth2 authentication failed", exception); | ||
|
||
ResponseWriter.writeResponse(response, DataResponse.ok(), HttpStatus.OK); | ||
} | ||
} |