Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🌱 관련 이슈
📌 작업 내용 및 특이사항
OAuth2AuthorizationRequestRedirectFilter
에 의해 강제로oauth2/authorization/github
로 리다이렉트 되도록 설정되어 있기 때문입니다.BasicAuthenticationEntryPoint
가 작동해야 하지만, 이는ExceptionTranslationFilter
에서 수행됩니다. 해당 필터는 OAuth 필터보다 뒤에 존재하기 때문에 oauth의 리다이렉트 요청이 먼저 처리되는 것입니다.swaggerFilterChain
을 타도록 해주었지만 이때 oauthLogin 옵션을 disable 처리해주지 않아 해당 문제가 발생했습니다.filterChain
에서도 리다이렉트 문제가 발생하기 때문에 이를 해결해주어야 합니다. 인증 예외가 발생했을 때 대부분의 예외는 디폴트로LoginUrlAuthenticationEntryPoint
에 의해서 처리됩니다. 실제로 해당 클래스의commence()
에서 리다이렉트 로직을 확인할 수 있습니다.HttpSecurity
의exceptionHandling
에서authenticationEntryPoint
를 커스텀해주면 스프링 시큐리티는 이렇게 커스텀된 설정을 우선합니다. 간단하게 인라인으로(request, response, authException) -> response.setStatus(401)
와 같이 설정하여 401을 내려주도록 해두었습니다.📝 참고사항
📚 기타