mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-11-17 23:21:08 +00:00
Improve LDAP snippet formatting
Issue: gh-6486
This commit is contained in:
parent
8e6bcc1c35
commit
c4b17475d9
@ -205,29 +205,28 @@ A typical configuration, using some of the beans we've discussed here, might loo
|
|||||||
----
|
----
|
||||||
<bean id="contextSource"
|
<bean id="contextSource"
|
||||||
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
|
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
|
||||||
<constructor-arg value="ldap://monkeymachine:389/dc=springframework,dc=org"/>
|
<constructor-arg value="ldap://monkeymachine:389/dc=springframework,dc=org"/>
|
||||||
<property name="userDn" value="cn=manager,dc=springframework,dc=org"/>
|
<property name="userDn" value="cn=manager,dc=springframework,dc=org"/>
|
||||||
<property name="password" value="password"/>
|
<property name="password" value="password"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="ldapAuthProvider"
|
<bean id="ldapAuthProvider"
|
||||||
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
|
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
|
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
|
||||||
<constructor-arg ref="contextSource"/>
|
<constructor-arg ref="contextSource"/>
|
||||||
<property name="userDnPatterns">
|
<property name="userDnPatterns">
|
||||||
<list><value>uid={0},ou=people</value></list>
|
<list><value>uid={0},ou=people</value></list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<bean
|
<bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
|
||||||
class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
|
|
||||||
<constructor-arg ref="contextSource"/>
|
<constructor-arg ref="contextSource"/>
|
||||||
<constructor-arg value="ou=groups"/>
|
<constructor-arg value="ou=groups"/>
|
||||||
<property name="groupRoleAttribute" value="ou"/>
|
<property name="groupRoleAttribute" value="ou"/>
|
||||||
</bean>
|
</bean>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</bean>
|
||||||
----
|
----
|
||||||
|
|
||||||
@ -243,9 +242,9 @@ To configure a user search object, which uses the filter `(uid=<user-login-name>
|
|||||||
|
|
||||||
<bean id="userSearch"
|
<bean id="userSearch"
|
||||||
class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
|
class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
|
||||||
<constructor-arg index="0" value=""/>
|
<constructor-arg index="0" value=""/>
|
||||||
<constructor-arg index="1" value="(uid={0})"/>
|
<constructor-arg index="1" value="(uid={0})"/>
|
||||||
<constructor-arg index="2" ref="contextSource" />
|
<constructor-arg index="2" ref="contextSource" />
|
||||||
</bean>
|
</bean>
|
||||||
----
|
----
|
||||||
|
|
||||||
@ -265,10 +264,10 @@ The creation of the `UserDetails` object is controlled by the provider's `UserDe
|
|||||||
----
|
----
|
||||||
public interface UserDetailsContextMapper {
|
public interface UserDetailsContextMapper {
|
||||||
|
|
||||||
UserDetails mapUserFromContext(DirContextOperations ctx, String username,
|
UserDetails mapUserFromContext(DirContextOperations ctx, String username,
|
||||||
Collection<GrantedAuthority> authorities);
|
Collection<GrantedAuthority> authorities);
|
||||||
|
|
||||||
void mapUserToContext(UserDetails user, DirContextAdapter ctx);
|
void mapUserToContext(UserDetails user, DirContextAdapter ctx);
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
@ -298,11 +297,10 @@ An example configuration would then look like this:
|
|||||||
----
|
----
|
||||||
|
|
||||||
<bean id="adAuthenticationProvider"
|
<bean id="adAuthenticationProvider"
|
||||||
class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
|
class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
|
||||||
<constructor-arg value="mydomain.com" />
|
<constructor-arg value="mydomain.com" />
|
||||||
<constructor-arg value="ldap://adserver.mydomain.com/" />
|
<constructor-arg value="ldap://adserver.mydomain.com/" />
|
||||||
</bean>
|
</bean>
|
||||||
}
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Note that there is no need to specify a separate `ContextSource` in order to define the server location - the bean is completely self-contained.
|
Note that there is no need to specify a separate `ContextSource` in order to define the server location - the bean is completely self-contained.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user