applicationContext-security.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <b:beans xmlns:b="http://www.springframework.org/schema/beans"
  3. xmlns="http://www.springframework.org/schema/security"
  4. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:context="http://www.springframework.org/schema/context"
  7. xmlns:util="http://www.springframework.org/schema/util"
  8. xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
  9. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  10. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
  11. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  12. <http entry-point-ref="casEntryPoint" use-expressions="true">
  13. <intercept-url pattern="/" access="permitAll"/>
  14. <intercept-url pattern="/index.jsp" access="permitAll"/>
  15. <intercept-url pattern="/cas-logout.jsp" access="permitAll"/>
  16. <intercept-url pattern="/casfailed.jsp" access="permitAll"/>
  17. <intercept-url pattern="/secure/extreme/**"
  18. access="hasRole('ROLE_SUPERVISOR')" />
  19. <intercept-url pattern="/secure/**" access="hasRole('ROLE_USER')" />
  20. <intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
  21. <custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER"/>
  22. <custom-filter ref="singleLogoutFilter" before="CAS_FILTER"/>
  23. <custom-filter ref="casFilter" position="CAS_FILTER" />
  24. <logout logout-success-url="/cas-logout.jsp"/>
  25. </http>
  26. <authentication-manager alias="authManager">
  27. <authentication-provider ref="casAuthProvider" />
  28. </authentication-manager>
  29. <user-service id="userService">
  30. <user name="rod" password="rod" authorities="ROLE_SUPERVISOR,ROLE_USER" />
  31. <user name="dianne" password="dianne" authorities="ROLE_USER" />
  32. <user name="scott" password="scott" authorities="ROLE_USER" />
  33. </user-service>
  34. <!-- This filter handles a Single Logout Request from the CAS Server -->
  35. <b:bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/>
  36. <!-- This filter redirects to the CAS Server to signal Single Logout should be performed -->
  37. <b:bean id="requestSingleLogoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"
  38. p:filterProcessesUrl="/j_spring_cas_security_logout">
  39. <b:constructor-arg value="https://${cas.server.host}/cas/logout"/>
  40. <b:constructor-arg>
  41. <b:bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
  42. </b:constructor-arg>
  43. </b:bean>
  44. <b:bean id="serviceProperties"
  45. class="org.springframework.security.cas.ServiceProperties"
  46. p:service="https://${cas.service.host}/cas-sample/j_spring_cas_security_check"
  47. p:authenticateAllArtifacts="true"/>
  48. <b:bean id="casEntryPoint"
  49. class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"
  50. p:serviceProperties-ref="serviceProperties" p:loginUrl="https://${cas.server.host}/cas/login" />
  51. <b:bean id="casFilter"
  52. class="org.springframework.security.cas.web.CasAuthenticationFilter"
  53. p:authenticationManager-ref="authManager"
  54. p:serviceProperties-ref="serviceProperties"
  55. p:proxyGrantingTicketStorage-ref="pgtStorage"
  56. p:proxyReceptorUrl="/j_spring_cas_security_proxyreceptor">
  57. <b:property name="authenticationDetailsSource">
  58. <b:bean class="org.springframework.security.cas.web.authentication.ServiceAuthenticationDetailsSource"/>
  59. </b:property>
  60. <b:property name="authenticationFailureHandler">
  61. <b:bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"
  62. p:defaultFailureUrl="/casfailed.jsp"/>
  63. </b:property>
  64. </b:bean>
  65. <!--
  66. NOTE: In a real application you should not use an in memory implementation. You will also want
  67. to ensure to clean up expired tickets by calling ProxyGrantingTicketStorage.cleanup()
  68. -->
  69. <b:bean id="pgtStorage" class="org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl"/>
  70. <b:bean id="casAuthProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"
  71. p:serviceProperties-ref="serviceProperties"
  72. p:key="casAuthProviderKey">
  73. <b:property name="authenticationUserDetailsService">
  74. <b:bean
  75. class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
  76. <b:constructor-arg ref="userService" />
  77. </b:bean>
  78. </b:property>
  79. <b:property name="ticketValidator">
  80. <b:bean
  81. class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"
  82. p:acceptAnyProxy="true"
  83. p:proxyCallbackUrl="https://${cas.service.host}/cas-sample/j_spring_cas_security_proxyreceptor"
  84. p:proxyGrantingTicketStorage-ref="pgtStorage">
  85. <b:constructor-arg value="https://${cas.server.host}/cas" />
  86. </b:bean>
  87. </b:property>
  88. <b:property name="statelessTicketCache">
  89. <b:bean class="org.springframework.security.cas.authentication.EhCacheBasedTicketCache">
  90. <b:property name="cache">
  91. <b:bean class="net.sf.ehcache.Cache"
  92. init-method="initialise"
  93. destroy-method="dispose">
  94. <b:constructor-arg value="casTickets"/>
  95. <b:constructor-arg value="50"/>
  96. <b:constructor-arg value="true"/>
  97. <b:constructor-arg value="false"/>
  98. <b:constructor-arg value="3600"/>
  99. <b:constructor-arg value="900"/>
  100. </b:bean>
  101. </b:property>
  102. </b:bean>
  103. </b:property>
  104. </b:bean>
  105. <!-- Configuration for the environment can be overriden by system properties -->
  106. <context:property-placeholder system-properties-mode="OVERRIDE" properties-ref="environment"/>
  107. <util:properties id="environment">
  108. <b:prop key="cas.service.host">localhost:8443</b:prop>
  109. <b:prop key="cas.server.host">localhost:9443</b:prop>
  110. </util:properties>
  111. </b:beans>