• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

ResourceSeverConfig를 작성하면 LoginForm을 사용할 수 없게되는건가요?

20.09.04 12:11 작성 조회수 331

0

ResourceServerConfig를 삭제하고 SecurityConfig에서 http를 설정하면 loginForm이 나오더라구요.

ResourceServerConfig를 작성하면 기존의 loginForm이 나오지 않고 이렇게 나오는게 맞는건지 궁금해서 질문드렸습니다. 

ResourceServerConfigurerAdapter가 WebSecurityConfigurerAdapter를 덮어씌우는 건가요?

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<oauth>
<error_description>Full authentication is required to access this resource</error_description>
<error>unauthorized</error>
</oauth>

답변 1

답변을 작성해보세요.

0

네 맞습니다. 리소스 서버 설정이 웹 시큐리티 설정 보다 우선순위가 높아서 그런건데요. ResourceServerConfiguration 코드를 보시면 Ordered라는 인터페이스 구현하고 값을 3으로 설정한걸 보실 수 있습니다. 그리고 기본 스프링 웹 시큐리티는 100이구요. WebSecurityConfigurationAdapter 코드에 보시면 @Order(100)을 보실 수 있습니다. 숫자가 낮을 수록 높은 우선 순위를 가지고 있으니 리소스 서버 설정이 먼저 적용이 된겁니다.

웹 시큐리티 설정을 더 높게 설정하고 싶다면 SecurityConfig 클래스에 @Order(SecurityProperties.IGNORED_ORDER) 이런 애노테이션을 붙이면 해당 설정이 제일 우선 순위가 높아지기 때문에 로그인 페이지를 볼 수 있을 겁니다.