1

標準的な方法ではなく、次のように認証を実行するようにSpringSecurityLDAPプラグインを構成する方法があるかどうか疑問に思っていました。

If one is able to connect and login to the LDAP server then 
the user is authenticated. 

Read the authorization from this user's account on LDAP 
(this is probably the default behavior)

したがって、基本的にマスターアカウントを構成する代わりに、ユーザーから渡されたユーザー/パスを使用して実際にログインを実行します(成功した場合、ユーザーは他のデータをフェッチできます)。

前もって感謝します!

4

1 に答える 1

0

あなたがまだこれを探していることを願っています。BindAuthenticator は、正しい方向への良い一歩のように思えます。ただし、セキュリティ コンテキスト ソースを使用しないように機関ポピュレータを変更する必要があります。デフォルトのポピュレーターは、適切な管理者アカウントで接続プールを使用していると思います。

以下は、BindAuthenticator とカスタム AuthoritiesPopulator を使用したセットアップのサンプルです。

        <bean id="authPopulator" class="org.springframework.security.ldap.populator.CustomLdapAuthoritiesPopulator">
      <constructor-arg ref="securityContextSource"/>
      <constructor-arg value="ou=Roles,o=data"/>
      <property name="groupRoleAttribute" value="resourceGroupType"/>
      <property name="groupSearchFilter" value="member={0}" />
    </bean>

<bean id="ldap-authentication-provider"
        class="org.springframework.security.providers.ldap.LdapAuthenticationProvider" >
  <constructor-arg>
    <bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
      <constructor-arg ref="securityContextSource"/>
      <property name="userDnPatterns">
        <list><value>cn={0},ou=users,o=system</value>
          <value>cn={0},ou=users,o=xyz</value>
          <value>cn={0},ou=users,ou=external,o=xyz</value>
    </list>
      </property>
      <property name="userSearch" ref="userSearch">
      </property>
    </bean>
  </constructor-arg>
  <constructor-arg ref="authPopulator"/>
  <s:custom-authentication-provider />
</bean>

ここに私のコンテキストソース定義があります:

     <bean id="securityContextSource"
        class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
  <constructor-arg value="ldap://192.168.254.254:389"/>
  <property name="userDn" value="cn=admin,ou=users,o=xyz"/>
  <property name="password" value="password"/>
</bean>

ユーザー名またはパスワードなしでコンテキスト ソースをテストすることにしましたが、部分的に機能しているように見えます。これが私のログ出力です。

 [java] - Authentication success: org.springframework.security.providers.UsernamePasswordAuthenticationToken@79107ad5: Principal: org.springframework.security.userdetails.ldap.LdapUserDetailsImpl@3d1a70a7: Username: internalUser; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@0: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: a2a3a505521919d529e75c6d14081f6b; Granted Authorities: ROLE_USER
     [java] - Updated SecurityContextHolder to contain the following Authentication: 'org.springframework.security.providers.UsernamePasswordAuthenticationToken@79107ad5: Principal: org.springframework.security.userdetails.ldap.LdapUserDetailsImpl@3d1a70a7: Username: internalUser; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@0: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: a2a3a505521919d529e75c6d14081f6b; Granted Authorities: ROLE_USER'

エラーは発生しませんが、すべてのロールが入力されるわけではありません。これは eDirectory のアクセス許可の問題であるか、独自の権限ポピュレータを作成する必要がある場合があります。ポピュレータには、ユーザー dirContext が渡されます。

于 2010-11-03T14:10:10.933 に答える