2011-01-25 2 views
4

스프링 LDAP reference docs을 통해 읽었으며 LDAP 서버에 대한 사용자 인증이 자동화되었는지 여부를 알 수 없습니다.스프링 LDAP 인증 (Automatic or Not?)

"자동화 된"이란 사용자가 ContextSource에 userDn과 암호를 제공하면 bean 인스턴스화시 자동으로 발생한다는 의미입니다. 말하자면, 프로그래머는 LdapTemplate.authenticate(...)으로 전화 할 필요가 없습니다. "뒤에서"발생합니다.

그래서 봄 LDAP 인증이 자동 인 경우

  1. 을 알고 싶습니다
  2. 나는이 문제를

감사를 변경 설정할 수 있습니다 필드,
KTM

가있는 경우

편집 : 나는이 질문을한다. 내가 작성한 코드의 맥락에서 다음 ContextSource은 사용자가 사용할 수있는 bean 파일의 컨텍스트 소스 중 하나입니다. 런타임시 userDn 및 암호를 구성하는 데 사용됩니다 (보안상의 이유로). LDAP 응용 프로그램이 실제로 런타임에 인증에서 수집하는 userDn/password를 사용할 것인지 여부를 알고 싶습니다. (인증이 내 코드를 구성하는 사용자 DN/암호 필드를 무시합니까? 내 코드의 실행을 앞에 있습니까?)

public class RuntimeContext extends LdapContextSource { 

    public RuntimeContext() { 
     super(); 
     if (!resolveAuthInfo()) { 
      System.out.println("Failed to resolve auth info. Exiting..."); 
      System.exit(1); 
     } 
    } 

    public boolean resolveAuthInfo() 
    { 
     String myUserDn, myPassword; 
     try { 
      BufferedReader br = new BufferedReader(
        new InputStreamReader(System.in)); 
      System.out.print("userDn: "); 
      myUserDn = br.readLine(); 
      System.out.print("password: "); 
      myPassword = br.readLine(); 
     } catch (IOException e) { 
      return false; 
     } 
     super.setUserDn(myUserDn); 
     super.setPassword(myPassword); 
     return true; 
    } 
} 
+0

추가 소스 코드 – ktm5124

+0

나는 그것이 작동한다고 믿는다 ... 나는 다음과 같은 테스트를 시도했다. bean 파일에서 url 속성을 제거하고 대신 위의 resolveAuthInfo 메소드에서 url (setUrl 호출로)을 설정했다. 앱이 여전히 작동하고 쿼리가 성공적으로 수행됩니다. 물론 setUrl 호출 없이는 작동하지 않습니다. 그래서 위의 코드는 뭔가를하고 있습니다. – ktm5124

답변

1

내가 LDAP 응용 프로그램이 실제로 사용자 DN을 사용할지 여부를 알고 싶어/비밀 번호를 내가 런타임에 인증에서 수집합니다.

http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html

그것은 당신이 런타임에 수집 한 사용자 DN 및 암호를 사용합니다. 당신이 당신의 콩을 구성하는 방법을 바탕으로, LDAP 인증은 봄에 두 경로 중 하나를 사용합니다 :

이 인증 자가 호출

  • 암호 비교 (BindAuthenticator 사용)

    1. 바인드 인증 (PasswordComparisonAuthenticator 사용)

      <authentication-manager alias="authenticationManager"> 
          <authentication-provider user-service-ref="usernamePasswordUserDetailsService"> 
           <password-encoder ref="passwordEncoder"> 
            <salt-source ref="saltSource"/> 
           </password-encoder> 
          </authentication-provider> 
          <authentication-provider ref="ldapAuthenticationProvider"/> 
      </authentication-manager> 
      
      의 인증 자로 구성 할 수있는 LdapAuthenticationProvider 컨텍스트 내에서

      <http auto-config="true"> 
          <form-login login-page="/auth/login" 
             login-processing-url="/auth/j_security_check"/> 
          <logout invalidate-session="true" logout-url="/auth/logout"/> 
      </http> 
      

      토큰은 사용자 이름과 암호를 사용하여 만든 다음 UsernamePasswordAuthenticationFilter는 (은/인증/로그인 페이지를 통해)를 호출

      .

      public class LdapAuthenticationProvider implements AuthenticationProvider, MessageSourceAware { 
      
          ... 
      
          public boolean supports(Class<?> authentication) { 
           return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication)); 
          } 
      } 
      

      를 그리고 인증을 수행 할 수는 LdapContextSource에 저장된 정보를 사용하여 다음 LdapAuthenticationProvider은 토큰 유형에 응답합니다.