• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

스프링부트 버전 2.7이상 authenticationManagerBean 등록방법을 잘 모르겠습니다.

23.08.04 01:48 작성 조회수 1.11k

0

안녕하세요 선생님 일단 좋은 강의 감사합니다.

선생님 강의를 들으면서 2.7버전으로 진행하고 있는데

매니저 를 등록할때부터 막혔습니다.

제 나름대로 소스도 좀 제가 평소에 하던 방식으로 하고있었는데 강의 버전이랑 맞지 않으니 힘드네요 ㅠ 이 부분은 스프링부트 2.7이상에서는 어떻게 하면될까요?

 

깃허브 주소 : https://github.com/PeachCoolPiece/corespringsecurity

입니다.

답변 1

답변을 작성해보세요.

0

@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {

ProviderManager authenticationManager = (ProviderManager)authenticationConfiguration.getAuthenticationManager();

return authenticationManager;

}

이렇게 해 보시기 바랍니다.

배성환님의 프로필

배성환

질문자

2023.08.04

답변 감사합니다 선생님 그러면 setAuthenticationManager를 해줄때 new AuthenticationConfiguration() 이런식으로 해보고있는데 안되서 헤매고 있네요 ㅠㅠ..

배성환님의 프로필

배성환

질문자

2023.08.04

image선생님 하다보니깐 authenticationConfiguration을 생성자 주입으로 받고 이런식으로 했는데 실행은 되는데 이런식으로 해도 상관없을가요?

@Bean

public AjaxLoginProcessingFilter ajaxLoginProcessingFilter() throws Exception {

AjaxLoginProcessingFilter ajaxLoginProcessingFilter = new AjaxLoginProcessingFilter();

ajaxLoginProcessingFilter.setAuthenticationManager(authenticationManager());

return ajaxLoginProcessingFilter;

@Bean

public AuthenticationManager authenticationManager () throws Exception {

return authenticationConfiguration.getAuthenticationManager);

으로 하시면 됩니다

다만 설정에 따라 어떤 환경에서는 다른 결과가 나오기도 하는데 흐름에 이상이 없다면 그렇게 하시면 될 것 같습니다

배성환님의 프로필

배성환

질문자

2023.08.05

감사합니다!