fix: 비밀번호 인코더 선택이 로케일에 따라 달라지는 문제 수정 - #332
Open
wantaekchoi wants to merge 1 commit into
Open
Conversation
EgovSecurityConfiguration.passwordEncoder는 설정값 hash를 소문자로 정규화해
switch 키로 쓴다. 인자 없는 toLowerCase()는 JVM 기본 로케일을 따르므로,
터키어·아제르바이잔어 로케일에서 "PLAINTEXT"는 점 없는 ı가 섞인 "plaıntext"가
되어 case "plaintext"에 걸리지 않는다.
그러면 default 분기로 빠지고 securityHash.startsWith("sha")도 아니므로
NoOpPasswordEncoder 대신 BCryptPasswordEncoder가 선택된다. 평문으로 저장된
비밀번호를 BCrypt로 검증하게 되어 로그인이 전부 실패한다.
같은 파일이 이미 정답을 갖고 있다. xframeOptions 분기는 같은 종류의 정규화를
Locale.ROOT로 한다.
:488 switch (xfo.trim().toUpperCase(Locale.ROOT))
hash 쪽 정규화 두 곳과 알고리즘 이름 대문자화에 Locale.ROOT를 명시했다.
switch 문의 securityHash.toLowerCase()는 바로 위에서 이미 정규화한 값을 다시
소문자화하던 것이라 함께 지웠다.
같은 결함 클래스를 Locale.ROOT로 고친 선례가 이 저장소에 있다 —
DefaultMapUserDetailsMapping의 컬럼명 소문자화(eGovFramework#321).
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
EgovSecurityConfiguration.passwordEncoder는 설정값hash를 소문자로 정규화해switch키로 씁니다. 인자 없는toLowerCase()는 JVM 기본 로케일을 따르므로, 터키어·아제르바이잔어 로케일에서"PLAINTEXT"는 점 없는ı가 섞인"plaıntext"가 되어case "plaintext"에 걸리지 않습니다.그러면
default분기로 빠지고securityHash.startsWith("sha")도 아니므로NoOpPasswordEncoder대신BCryptPasswordEncoder가 선택됩니다. 평문으로 저장된 비밀번호를 BCrypt로 검증하게 되어 로그인이 실패합니다.같은 파일이 이미 정답을 갖고 있습니다.
xframeOptions분기는 같은 종류의 정규화를Locale.ROOT로 합니다.AS-IS
TO-BE
switch문의securityHash.toLowerCase()는 바로 위에서 이미 정규화한 값을 다시 소문자화하던 것이라 함께 지웠습니다.authenticationManager의 같은 정규화에도Locale.ROOT를 넣었습니다.같은 결함 클래스를
Locale.ROOT로 고친 선례가 이 저장소에 있습니다 —DefaultMapUserDetailsMapping의 컬럼명 소문자화(#321).영향 범위
ASCII 설정값은 기본 로케일이 무엇이든 결과가 같습니다. 바뀌는 것은 터키어 계열 로케일에서
i/I가 든 값뿐이고, 현재 switch 케이스 중에는plaintext가 해당합니다.JUnit 테스트 JUnit tests
EgovSecurityConfigurationHashLocaleTest1건을 추가했습니다. 기본 로케일을tr-TR로 바꾼 상태와 영어 로케일에서 각각hash=PLAINTEXT가NoOpPasswordEncoder로 해석되는지 봅니다.수정 지점만 되돌린 상태(RED)
수정 후(GREEN, 모듈 전체)