Acegi Security에서 Siteminder를 지원하기 위해 설정해야 하는 첫 번째 단계는
앞서 논의했던 HTTP 헤더를 검사할 인증 메커니즘을 정의하는 것이다.
인증 메커니즘은 차후에 SiteminderAuthenticationProvider로 전송될
UsernamePasswordAuthenticationToken을 생성하는 책임을 가질 것이다.
예제를 살펴보기로 하자:
<bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.SiteminderAuthenticationProcessingFilter"> <property name="authenticationManager"><ref bean="authenticationManager"/></property> <property name="authenticationFailureUrl"><value>/login.jsp?login_error=1</value></property> <property name="defaultTargetUrl"><value>/security.do?method=getMainMenu</value></property> <property name="filterProcessesUrl"><value>/j_acegi_security_check</value></property> <property name="siteminderUsernameHeaderKey"><value>SM_USER</value></property> <property name="formUsernameParameterKey"><value>j_username</value></property> </bean>
위 예제에서는 빈에 AuthenticationManager가 제공되며,
이렇게 하는 것은 일반적으로 인증 메커니즘에서 AuthenticationManager를
필요로 하기 때문이다. 예제에는 몇 개의 URL도 지정되어 있는데, URL의 값은
스스로 설명이 가능하다. Acegi Security가 검사해야 하는 HTTP 헤더가 지정되어 있다는
것이 중요하다. 여러분이 추가적으로 폼 기반의 인증을 지원하고자
한다면(예를 들어 Siteminder가 설치되어 있지 않은 개발환경일 경우),
폼의 사용자명 파라미터도 지정하도록 하며, 제품으로 출시할 때에는
그렇지 하지 않도록 한다!
주의할 점은 여러분이 Siteminder 인증 메커니즘을 사용하기 위해서는
ProviderManager에 SiteminderAuthenticationProvider를
설정할 필요가 있다는 것이다. 보통 AuthenticationProvider는
비밀번호 프로퍼티가 UserDetailsSource에서 받는 것과 일치할 것으로 예상하지만,
이 경우에는 인증이 이미 Siteminder에 의해 처리되므로 비밀번호 프로퍼티가 그에 상응하지 않을 수도
있다. 이렇게 되는 것이 보안상 약점으로 들릴 수도 있긴 하나 여러분의 애플리케이션이
요청을 받기 훨씬 전에 사용자가 Siteminder를 이용하여 인증해야 한다는 것을 떠올려야 하며,
따라서 여러분이 직접 정의한 UserDetailsService의 목적은 단순히
Authentication 객체(예를 적절한 GrantedAuthority[]를 가진)를
완성하는 데 있다.
고급 팁 및 경구(word to the wise): 여러분의 개발환경(일반적으로 Siteminder가 설치되어 있지 않은)에 추가적으로 폼 기반의 인증도 지원하고자 한다면 폼의 username 파라미터도 지정한다. 출시하는 애플리케이션에는 그렇게 하지 않도록 한다!