applicationContext-security.xml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:s="http://www.springframework.org/schema/security"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  5. http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">
  6. <s:http>
  7. <s:intercept-url pattern="/secure/extreme/**" access="ROLE_SUPERVISOR"/>
  8. <s:intercept-url pattern="/secure/**" access="IS_AUTHENTICATED_REMEMBERED" />
  9. <s:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
  10. <s:form-login />
  11. <s:anonymous />
  12. <s:logout />
  13. </s:http>
  14. <!-- Simple namespace-based configuration -->
  15. <s:ldap-server ldif="classpath:users.ldif" />
  16. <s:ldap-authentication-provider
  17. group-search-filter="member={0}"
  18. group-search-base="ou=groups"
  19. user-search-base="ou=people"
  20. user-search-filter="uid={0}"
  21. />
  22. <!-- Traditional Bean version of the same configuration -->
  23. <!-- This bean points at the embedded directory server created by the ldap-server element above -->
  24. <bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
  25. <constructor-arg value="ldap://localhost:389/dc=springframework,dc=org"/>
  26. </bean>
  27. <bean id="secondLdapProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
  28. <s:custom-authentication-provider />
  29. <constructor-arg>
  30. <bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
  31. <constructor-arg ref="contextSource" />
  32. <property name="userSearch">
  33. <bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
  34. <constructor-arg index="0" value="ou=people"/>
  35. <constructor-arg index="1" value="(uid={0})"/>
  36. <constructor-arg index="2" ref="contextSource" />
  37. </bean>
  38. </property>
  39. </bean>
  40. </constructor-arg>
  41. <constructor-arg>
  42. <bean class="org.springframework.security.ldap.populator.DefaultLdapAuthoritiesPopulator">
  43. <constructor-arg ref="contextSource" />
  44. <constructor-arg value="ou=groups" />
  45. <property name="groupSearchFilter" value="member={0}"/>
  46. <property name="groupRoleAttribute" value="ou" />
  47. <property name="rolePrefix" value="ROLE_"/>
  48. <property name="searchSubtree" value="true"/>
  49. <property name="convertToUpperCase" value="true"/>
  50. </bean>
  51. </constructor-arg>
  52. </bean>
  53. </beans>