2009-11-18 3 views
0

내 시스템에 2 개의 서브 시스템이 있습니다. 각 서브 시스템에는 다른 사용자 세트가 있습니다. 각 사용자에게는이 사용자가 속한 시스템을 알기 위해 사용할 수있는 "SystemName"이라는 추가 필드가 있습니다.사용자 정의 인증

로그인 양식 (각 하위 시스템에 대해 1 개의 양식)에서 양식의 유형 (SystemName 값 포함)을 지정하는 숨김 필드를 추가했습니다.

if (user.systemName == params.systemName) { 
    proceed with regular login 
} else { 
    throw standard login error 
} 

내가 내 사용자 지정 DaoAuthenticationProvider는 해당 수표를 퍼팅 시도하지만 "params.systemName"에 액세스 할 수 없습니다 :

일반적으로, 검사는 오히려 간단하다.

Acegi가이 확인으로 내 사용자를 인증하도록하려면이 코드를 어디에 넣어야합니까? 사전에

감사합니다.

답변

1

이것은 내가 Java에서 그랬습니다. 인증 필터

import javax.servlet.http.HttpServletRequest; 
import org.acegisecurity.ui.WebAuthenticationDetails; 

public class SystemNameWebAuthenticationDetails extends WebAuthenticationDetails { 

    public SystemNameWebAuthenticationDetails() { 
     super(); 
    } 

    public SystemNameWebAuthenticationDetails(HttpServletRequest request) { 
     super(request); 
     this.systemName = request.getParameter("systemName"); 
    } 

    public String getSystemName() { 
     return systemName; 
    } 

    private String systemName; 
} 

설정을 :

<bean id="authenticationProcessingFilter" 
     class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"> 
     ... 
     <property name="authenticationDetailsSource"> 
     <bean class="org.acegisecurity.ui.AuthenticationDetailsSourceImpl"> 
      <property name="clazz" value="SystemNameWebAuthenticationDetails"/> 
     </bean> 
     </property> 
</bean> 

나중에 당신이 인증 개체에 대한 세부 사항을 요청하는 인증 과정에서 해당 속성에 액세스 할 수 있습니다 WebAuthenticationDetails을 확장합니다. 또는 이렇게 :

SecurityContextHolder.getContext().getAuthentication().getDetails() 
관련 문제