• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

authenticationProvider, secret_key 관련 질문

23.04.07 23:14 작성 조회수 397

0

현재 문제 상황이 이렇습니다.

secret_key value 가 "secret" 이 아니여도 정상적으로 로그인 되버립니다.

그래서 SecurityConfig 설정을 잘못해서 authenticationProvider 나 authenticationDetailSource 가 정상적으로 작동을 안하는지 의심되서 각각 코드에 break 를 걸고 debug 를 돌렸더니 break 가 걸려서 돌아갑니다.

그리고 진짜 진짜 신기한게 secret_key 가 null 인게 debug 모드에서 확인됩니다.그리고 secret_key == null 이 true 인게 확인됩니다. 그런데 exception 이 작동을 안하고 그냥 로그인이 되버립니다.

대체 이게 무슨일인거죠..

https://github.com/Hosung-Ahn/backend-practice/tree/main/demo-security
코드로 봐주시면 너무 감사할 것 같습니다..

답변 1

답변을 작성해보세요.

0

안호성님의 프로필

안호성

질문자

2023.04.08

해결했습니다...!

secret key를 register page 에 넣고 있었네요 하하하

근데 사실 register 에 넣어도 secret_key 가 일치하지 않는데 로그인 되는 현상이 발생했습니다.

AuthenticationManagerBuilder authenticationManagerBuilder = http.getSharedObject(AuthenticationManagerBuilder.class);
authenticationManagerBuilder.authenticationProvider(new CustomAuthenticationProvider(userDetailsService, passwordEncoder()));
authenticationManagerBuilder.parentAuthenticationManager(null);

다른 분 코드를 참고해서 이 코드를 Config 에 넣어줬더니 해결이 되던구요..

특히 3번째 줄 코드가 있어야했습니다. 이유는 잘 모르겠습니다..ㄷㄷㄷ