처리 프로세스

Security 라이브러리는 크게 아래와 같은 구성으로 정의된다.

Security 구성-Security Process.drawio (1).png

스프링 시큐리티 설정

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한다.