fix: EgovLoginFailHandler 가 로그인 실패 URL 대신 접근거부 URL 로 보내는 문제 수정 - #360
Open
wantaekchoi wants to merge 1 commit into
Open
fix: EgovLoginFailHandler 가 로그인 실패 URL 대신 접근거부 URL 로 보내는 문제 수정#360wantaekchoi wants to merge 1 commit into
wantaekchoi wants to merge 1 commit into
Conversation
이 핸들러는 이름·기본값 상수·예외 메시지가 모두 로그인 실패를 가리키는데, 정작 설정에서 읽는 값은 접근거부 URL 이다. EgovSecurityConfig 에는 loginFailureUrl 이 따로 있고 필터체인의 formLogin 도 그 값을 쓴다. 쌍둥이 EgovAccessDeniedHandler 는 같은 자리에서 getAccessDeniedUrl 을 읽는데, 그쪽은 접근거부 핸들러라 맞다. 두 핸들러가 같은 프로퍼티를 읽고 있었다. 읽는 프로퍼티를 loginFailureUrl 로 바꾸고, 같은 이름을 가리키던 예외 메시지도 맞췄다. 미설정 시 DEFAULT_LOGIN_FAILURE_URL 로 떨어지는 폴백은 그대로다. 쌍둥이 테스트와 같은 형태로 회귀 테스트를 추가했다.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
수정 사유 Reason for modification
수정된 소스 내용 Modified source
EgovLoginFailHandler가 로그인 실패 URL 대신 접근거부 URL로 보냅니다.클래스 이름도, 기본값 상수 이름도 로그인 실패를 가리킵니다.
그런데 설정에서 읽는 값은 접근거부 URL입니다.
EgovSecurityConfig에는 로그인 실패용 항목이 따로 있고, 필터체인의formLogin도 그 값을 씁니다.쌍둥이인
EgovAccessDeniedHandler도 같은 자리에서getAccessDeniedUrl()을 읽습니다. 접근거부 핸들러니 그쪽은 맞는 값이고, 두 핸들러가 결과적으로 같은 프로퍼티 하나를 읽습니다.두 URL을 다르게 두고 로그인 실패를 일으키면 접근거부 화면으로 갑니다.
두 번째 단언에서 보듯 로그인 실패 URL을 비워도
DEFAULT_LOGIN_FAILURE_URL폴백에 닿지 못합니다. 접근거부 URL이 설정돼 있으면 그쪽이 먼저 걸리기 때문입니다.AS-IS / TO-BE
if (ObjectUtils.isEmpty(config)) { - throw new NoSuchBeanDefinitionException("### EgovLoginFailHandler getAccessDeniedUrl not found."); + throw new NoSuchBeanDefinitionException("### EgovLoginFailHandler getLoginFailureUrl not found."); } String failureUrl; - if (StringUtils.hasText(config.getAccessDeniedUrl())) { - failureUrl = config.getAccessDeniedUrl(); + if (StringUtils.hasText(config.getLoginFailureUrl())) { + failureUrl = config.getLoginFailureUrl(); } else { failureUrl = DEFAULT_LOGIN_FAILURE_URL; }영향 범위
이 핸들러가 forward하는 경로 하나입니다. 설정이 비어 있을 때
DEFAULT_LOGIN_FAILURE_URL로 떨어지는 폴백과 계정 열거 방지 메시지 처리는 그대로입니다.EgovSecurityConfiguration은 이 클래스를@Bean으로 노출합니다(:347). 자동 배선되는 자리가 없어, 값이 달라지는 쪽은 이 빈을 직접 주입해 쓰는 코드입니다.JUnit 테스트 JUnit tests
EgovAccessDeniedHandlerTest와 같은 형태로EgovLoginFailHandlerTest를 추가했습니다. 두 URL을 다르게 설정하고 어느 쪽으로 forward하는지, 로그인 실패 URL이 비었을 때 기본값으로 떨어지는지 봅니다.읽는 프로퍼티를 되돌리면 위 RED가 다시 나옵니다.
테스트 브라우저 Test Browser
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
화면이 없는 실행환경 모듈이라 첨부하지 않았습니다.