security-context.xml 6.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
		http://www.springframework.org/schema/security
		http://www.springframework.org/schema/security/spring-security-4.0.xsd">

 	<security:http pattern="/resources/css/**" security="none" />
	<security:http pattern="/resources/js/**" security="none" />
	<security:http pattern="/resources/js_tests/**" security="none" />
	<security:http pattern="/resources/images/**" security="none" />
	<security:http pattern="/resources/other/**" security="none" />
	<security:http pattern="/javax.faces.resource/**" security="none"/>

	<security:http auto-config="false" use-expressions='true' entry-point-ref="loginUrlAuthenticationEntryPoint">
		<security:custom-filter before="SESSION_MANAGEMENT_FILTER" ref="sessionManagementFilter" /> 
		<security:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" />
		<security:custom-filter position="FORM_LOGIN_FILTER" ref="mapViewerUsernamePasswordAuthenticationFilter"/>

		<security:session-management session-authentication-strategy-ref="sas"/>
		
	 	<security:intercept-url pattern="/login**" access="permitAll"/>
	 	<security:intercept-url pattern="/index**" access="permitAll"/>
	 	<security:intercept-url pattern="/export**" access="permitAll"/>
	 	<security:intercept-url pattern="/galaxy**" access="permitAll"/>
	 	<security:intercept-url pattern="/map**" access="permitAll"/>
		<security:intercept-url pattern="/map/**" access="permitAll"/>
Piotr Gawron's avatar
Piotr Gawron committed
30
31
32
33

	 	<security:intercept-url pattern="/api**" access="permitAll"/>
		<security:intercept-url pattern="/api/**" access="permitAll"/>
		
Piotr Gawron's avatar
Piotr Gawron committed
34
		<security:intercept-url pattern="/fonts/**" access="permitAll"/>
Piotr Gawron's avatar
Piotr Gawron committed
35
		
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
		<security:intercept-url pattern="/**" access="isAuthenticated()"/> 
	 	
	 	<security:logout	logout-url="/j_spring_security_logout" logout-success-url="/login.xhtml" invalidate-session="true"/>
   	
   	<security:headers>
   		<!-- we aply custom filtering of x-frames, more info in the class: lcsb.mapviewer.bean.utils.XFrameAccessControlFilter -->
	   	<security:frame-options disabled="true"/>
   	</security:headers>
   	<security:csrf disabled="true"/>		
	</security:http>
		
	<bean id="sessionManagementFilter" class="org.springframework.security.web.session.SessionManagementFilter">
		<constructor-arg name="securityContextRepository" ref="httpSessionSecurityContextRepository" />
		<property name="invalidSessionStrategy" ref="mapViewerInvalidSessionStrategy"/>
		<property name="authenticationFailureHandler" ref="authenticationFailureHandler"/>
	</bean> 		

	<bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter">
		<constructor-arg name="sessionRegistry" ref="sessionRegistry" />
		<constructor-arg name="expiredUrl" value="/index.xhtml" />
	</bean>
	
	<bean id="mapViewerUsernamePasswordAuthenticationFilter" class="lcsb.mapviewer.security.MvUsernamePasswordAuthenticationFilter">
		<property name="sessionAuthenticationStrategy" ref="sas" />
		<property name="authenticationManager" ref="authenticationManager"/>
		<property name="authenticationFailureHandler" ref="authenticationFailureHandler"/>
		<property name="authenticationSuccessHandler" ref="authenticationSuccessHandler"/>
	</bean>

	<bean id="authenticationSuccessHandler" class="lcsb.mapviewer.security.MvAuthenticationSuccessHandler">
		<property name="defaultTargetUrl" value="/login.xhtml"/> 
	</bean>
	
	<bean id="authenticationFailureHandler" class="lcsb.mapviewer.security.MvAuthenticationFailureHandler">
		<constructor-arg value="/login.xhtml"></constructor-arg>
	</bean>
	
	<bean id="userDetailsService" class="lcsb.mapviewer.security.MvSecurityServiceImpl">
		<property name="userService" ref="UserService" />
	</bean>

	<bean id="sas" class="org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy">
  	<constructor-arg>
    	<list>
      	<bean class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy">
        	<constructor-arg ref="sessionRegistry"/>
          <property name="maximumSessions" value="-1" />
          <property name="exceptionIfMaximumExceeded" value="true" />
        </bean>
       	<bean class="org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy">
        </bean>
        <bean class="org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy">
        	<constructor-arg ref="sessionRegistry"/>
        </bean>
      </list>
    </constructor-arg>
	</bean>	

	<bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />	
		
	<bean id="jsfRedirectStrategy" class="lcsb.mapviewer.security.MvJsfRedirectStrategy" />
			
	<bean id="mapViewerInvalidSessionStrategy" class="lcsb.mapviewer.security.MvInvalidSessionStrategy" >
<!--		<constructor-arg name="invalidSessionUrl" value="viewExpired.xhtml"/> -->
		<constructor-arg value="index.xhtml"/>
<!--		<constructor-arg name="invalidSessionUrl" value="index.xhtml"/> -->
	</bean>	
	
	<bean id="httpSessionSecurityContextRepository" class="org.springframework.security.web.context.HttpSessionSecurityContextRepository"/>
	
	<bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
		<property name="userDetailsService" ref="userDetailsService" />
		<property name="passwordEncoder" ref="PasswordEncoder" />
	</bean>
		
	<security:authentication-manager alias="authenticationManager">
		<security:authentication-provider ref="authenticationProvider" />
	</security:authentication-manager>
		
	<bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<!--		<property name="loginFormUrl" value="/login.xhtml"/> -->
		<constructor-arg value="/login.xhtml"/>
	</bean>
</beans>