Security 라이브러리는 크게 아래와 같은 구성으로 정의된다.
Manager
: Request 또는 인증 정보 등으로 Processor를 결정하고 인증 처리, 재인증 처리 및 권한 확인, 인증 해제 처리를 수행한다.Processor
: Configurer의 설정 정보 기반으로 인증 각 업무의 프로세스를 순차적으로 수행한다.Configuerer
: Processor가 요구하는 각 업무별 인터페이스 구현체를 설정한다.VxWebSecurityConfigure
클래스는 WebSecurityConfigurerAdapter
를 상속받아 configure
method에서 기본 설정을 하도록 개발되어 있다.
VxWebSecurityConfigure
를 구현하면 기본 설정 전(preconfigure
)과 후(postConfigure
)에 별도 설정을 적용할 수 있다.
@Bean
@ConditionalOnMissingBean
VxWebSecurityConfigure securityConfigure() {
return new VxWebSecurityConfigure() {
@Override
public void preConfigure(HttpSecurity http) throws Exception {
}
@Override
public void postConfigure(HttpSecurity http) throws Exception {
}
};
}
인증 관련 커스텀 설정을 위해서는 VxAuthenticationProcessor
Bean을 별도로 등록 해 주어야 한다. 아래는 기본 Processor 등록 코드이다. Processor의 생성자에서는 VxAuthenticationConfigurer
인스턴스를 인자 값으로 받으므로 VxAuthenticationConfigurer
인스턴스를 별도로 생성해야 한다.
@Configuration
public class AuthenticationConfiguration {
@Bean
VxAuthenticationProcessor<UsernamePasswordUserRequestToken, VxAuthentication> authenticationProcessor() {
return new VxDefaultAuthenticationProcessor<UsernamePasswordUserRequestToken, VxAuthentication>(
new VxAuthenticationConfigurer<UsernamePasswordUserRequestToken, VxAuthentication>() {}, VxAuthentication.class);
}
}
VxAuthenticationRequestToken
, VxAuthentication
은 Generic Type과 Processor 생성자의 마지막 파라미터 Class<? extends VxAuthentication>
를 바꿔주고
나머지는 VxAuthenticationConfigurer
구현체에서 설정하려는 함수를 Override한다.