1. ref 'AuthenticationProvider'를 구현하는 스프링 빈에 대한 참조를 정의 2. user-service-ref 표준 bean 요소 또는 사용자 지정 사용자 서비스 요소를 사용하여 생성할 수 있는 UserDetailsService를 구현하는 빈에 대한 참조
Unless used with arefattribute, this element is shorthand for configuring aDaoAuthenticationProvider.DaoAuthenticationProviderloads user information from aUserDetailsServiceand compares the username/password combination with the values supplied at login. TheUserDetailsServiceinstance can be defined either by using an available namespace element (jdbc-user-serviceor by using theuser-service-refattribute to point to a bean defined elsewhere in the application context). You can find examples of these variations in thenamespace introduction.
refDefines a reference to a Spring bean that implements `AuthenticationProvider `.
If you have written your ownAuthenticationProviderimplementation (or want to configure one of Spring Security’s own implementations as a traditional bean for some reason, then you can use the following syntax to add it to the internal `ProviderManager’s list:
user-service-refA reference to a bean that implements UserDetailsService that may be created using the standard bean element or the custom user-service element.
1. access-decision-manager-ref 메서드 보안은 웹 보안과 동일한 AccessDecisionManager 구성을 사용하지만 이 속성을 사용하여 재정의할 수 있다. 기본적으로 AffirmativeBased 구현은 RoleVoter 및 AuthentifiedVoter와 함께 사용한다.
2. intercept-url
특정한 URL에 접근할 때 인터셉터를 이용해서 접근을 제한하는 설정을 하는 경우
pattern : url의 패턴
access : 권한 체크
* pattern과 access는 반드시 intercept-ulr에서 지정해야하는 필수속성이다.
질문 . 사용자 권한을 authorities에 담는 것 까지는 알겠음.. (ADMIN, USER..이런거) 근데 이걸 담아 둔다고 해서.. intercept-url에서 그냥 쓰면되는건가?
위의 코드에서.. access-decision-manager-ref="myAccessDecisionMajagerBean" 이 부분..을 더 알아봐야 할 것 같다.
https://doing7.tistory.com/15
인증과 권한에 대한 처리는 AuthenticationManager ->AuthenticationProvider->UserDetailsService의 과정을 거치게 된다.
getAuthorities()는 해당 사용자의 권한을 GrantedAuthority나 GrantedAuthority의 자식 클래스를 제네릭으로 갖는 컬렉션을 반환하는 메소드입니다. 제 코드에서는 SimpleGrantedAuthority라는 메소드를 사용하여 myGrant를 생성하여 리스트에 담은것을 반환하도록 하였습니다.
Context에서 변경할 수 있지만 기본적으로 Spring Security의 권한은 "ROLE_"로 시작하므로, 사용자가 갖는 최종 권한은 ADMIN, USER가 아닌 ROLE_ADMIN, ROLE_USER가 됩니다. (ADMIN과 USER는 제가 DB에 저장하는 권한인 grant_name입니다.)