applicationContext-acegi-security-cas.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  3. <!--
  4. - Application context containing authentication, channel
  5. - security and web URI beans.
  6. -
  7. - Only used by "cas" artifact.
  8. -
  9. - $Id: applicationContext-acegi-security.xml 1409 2006-04-26 23:36:03Z benalex $
  10. -->
  11. <beans>
  12. <!-- ======================== FILTER CHAIN ======================= -->
  13. <bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
  14. <property name="filterInvocationDefinitionSource">
  15. <value>
  16. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  17. PATTERN_TYPE_APACHE_ANT
  18. /**=channelProcessingFilter,httpSessionContextIntegrationFilter,logoutFilter,casProcessingFilter,basicProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
  19. </value>
  20. </property>
  21. </bean>
  22. <!-- ======================== AUTHENTICATION ======================= -->
  23. <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
  24. <property name="providers">
  25. <list>
  26. <ref local="casAuthenticationProvider"/>
  27. </list>
  28. </property>
  29. </bean>
  30. <bean id="jdbcDaoImpl" class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
  31. <property name="dataSource" ref="dataSource"/>
  32. </bean>
  33. <bean id="basicProcessingFilter" class="org.springframework.security.ui.basicauth.BasicProcessingFilter">
  34. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  35. <property name="authenticationEntryPoint"><ref local="basicProcessingFilterEntryPoint"/></property>
  36. </bean>
  37. <bean id="basicProcessingFilterEntryPoint" class="org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint">
  38. <property name="realmName"><value>Contacts Realm</value></property>
  39. </bean>
  40. <bean id="httpSessionContextIntegrationFilter" class="org.springframework.security.context.HttpSessionContextIntegrationFilter"/>
  41. <bean id="casAuthenticationProvider" class="org.springframework.security.providers.cas.CasAuthenticationProvider">
  42. <property name="casAuthoritiesPopulator"><ref local="casAuthoritiesPopulator"/></property>
  43. <property name="casProxyDecider"><ref local="casProxyDecider"/></property>
  44. <property name="ticketValidator"><ref local="casProxyTicketValidator"/></property>
  45. <property name="statelessTicketCache"><ref local="statelessTicketCache"/></property>
  46. <property name="key"><value>my_password_for_this_auth_provider_only</value></property>
  47. </bean>
  48. <bean id="casProxyTicketValidator" class="org.springframework.security.providers.cas.ticketvalidator.CasProxyTicketValidator">
  49. <property name="casValidate" value="https://localhost:8443/cas/proxyValidate"/>
  50. <property name="proxyCallbackUrl" value="https://localhost:8443/contacts-cas/casProxy/receptor"/>
  51. <property name="serviceProperties"><ref local="serviceProperties"/></property>
  52. <!-- <property name="trustStore"><value>/some/path/to/your/lib/security/cacerts</value></property> -->
  53. </bean>
  54. <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
  55. <bean id="ticketCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  56. <property name="cacheManager"><ref local="cacheManager"/></property>
  57. <property name="cacheName" value="ticketCache"/>
  58. </bean>
  59. <bean id="statelessTicketCache" class="org.springframework.security.providers.cas.cache.EhCacheBasedTicketCache">
  60. <property name="cache"><ref local="ticketCacheBackend"/></property>
  61. </bean>
  62. <bean id="casAuthoritiesPopulator" class="org.springframework.security.providers.cas.populator.DaoCasAuthoritiesPopulator">
  63. <property name="userDetailsService"><ref local="jdbcDaoImpl"/></property>
  64. </bean>
  65. <bean id="casProxyDecider" class="org.springframework.security.providers.cas.proxy.RejectProxyTickets"/>
  66. <bean id="serviceProperties" class="org.springframework.security.ui.cas.ServiceProperties">
  67. <property name="service" value="https://localhost:8443/contacts-cas/j_spring_cas_security_check"/>
  68. <property name="sendRenew" value="false"/>
  69. </bean>
  70. <!-- note logout has little impact, due to CAS reauthentication functionality (it will cause a refresh of the authentication though) -->
  71. <bean id="logoutFilter" class="org.springframework.security.ui.logout.LogoutFilter">
  72. <constructor-arg value="/index.jsp"/> <!-- URL redirected to after logout -->
  73. <constructor-arg>
  74. <list>
  75. <bean class="org.springframework.security.ui.logout.SecurityContextLogoutHandler"/>
  76. </list>
  77. </constructor-arg>
  78. </bean>
  79. <!-- ===================== HTTP CHANNEL REQUIREMENTS ==================== -->
  80. <!-- Enabled by default for CAS, as a CAS deployment uses HTTPS -->
  81. <bean id="channelProcessingFilter" class="org.springframework.security.securechannel.ChannelProcessingFilter">
  82. <property name="channelDecisionManager"><ref local="channelDecisionManager"/></property>
  83. <property name="filterInvocationDefinitionSource">
  84. <value>
  85. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  86. \A/secure/.*\Z=REQUIRES_SECURE_CHANNEL
  87. \A/j_spring_cas_security_check.*\Z=REQUIRES_SECURE_CHANNEL
  88. \A.*\Z=REQUIRES_INSECURE_CHANNEL
  89. </value>
  90. </property>
  91. </bean>
  92. <bean id="channelDecisionManager" class="org.springframework.security.securechannel.ChannelDecisionManagerImpl">
  93. <property name="channelProcessors">
  94. <list>
  95. <ref local="secureChannelProcessor"/>
  96. <ref local="insecureChannelProcessor"/>
  97. </list>
  98. </property>
  99. </bean>
  100. <bean id="secureChannelProcessor" class="org.springframework.security.securechannel.SecureChannelProcessor"/>
  101. <bean id="insecureChannelProcessor" class="org.springframework.security.securechannel.InsecureChannelProcessor"/>
  102. <!-- ===================== HTTP REQUEST SECURITY ==================== -->
  103. <bean id="exceptionTranslationFilter" class="org.springframework.security.ui.ExceptionTranslationFilter">
  104. <property name="authenticationEntryPoint"><ref local="casProcessingFilterEntryPoint"/></property>
  105. </bean>
  106. <bean id="casProcessingFilter" class="org.springframework.security.ui.cas.CasProcessingFilter">
  107. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  108. <property name="authenticationFailureUrl"><value>/casfailed.jsp</value></property>
  109. <property name="defaultTargetUrl"><value>/</value></property>
  110. <property name="filterProcessesUrl"><value>/j_spring_cas_security_check</value></property>
  111. </bean>
  112. <bean id="casProcessingFilterEntryPoint" class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
  113. <property name="loginUrl"><value>https://localhost:8443/cas/login</value></property>
  114. <property name="serviceProperties"><ref local="serviceProperties"/></property>
  115. </bean>
  116. <bean id="httpRequestAccessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
  117. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  118. <property name="decisionVoters">
  119. <list>
  120. <ref bean="roleVoter"/>
  121. </list>
  122. </property>
  123. </bean>
  124. <!-- Note the order that entries are placed against the objectDefinitionSource is critical.
  125. The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
  126. Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
  127. <bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
  128. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  129. <property name="accessDecisionManager"><ref local="httpRequestAccessDecisionManager"/></property>
  130. <property name="objectDefinitionSource">
  131. <value>
  132. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  133. \A/secure/super.*\Z=ROLE_WE_DONT_HAVE
  134. \A/secure/.*\Z=ROLE_SUPERVISOR,ROLE_TELLER
  135. </value>
  136. </property>
  137. </bean>
  138. <!-- BASIC Regular Expression Syntax (for beginners):
  139. \A means the start of the string (ie the beginning of the URL)
  140. \Z means the end of the string (ie the end of the URL)
  141. . means any single character
  142. * means null or any number of repetitions of the last expression (so .* means zero or more characters)
  143. Some examples:
  144. Expression: \A/my/directory/.*\Z
  145. Would match: /my/directory/
  146. /my/directory/hello.html
  147. Expression: \A/.*\Z
  148. Would match: /hello.html
  149. /
  150. Expression: \A/.*/secret.html\Z
  151. Would match: /some/directory/secret.html
  152. /another/secret.html
  153. Not match: /anothersecret.html (missing required /)
  154. -->
  155. </beans>