diff --git a/src/main/webapp/WEB-INF/arsnova-servlet.xml b/src/main/webapp/WEB-INF/arsnova-servlet.xml index 3a90da7eade502162b301f4b0d1a5186b8652297..cee82e47414033b84e985bfe1f5f9ca94a2680b8 100644 --- a/src/main/webapp/WEB-INF/arsnova-servlet.xml +++ b/src/main/webapp/WEB-INF/arsnova-servlet.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" xmlns:security="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc" + xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.4.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd @@ -11,29 +13,14 @@ <context:component-scan base-package="de.thm.arsnova" /> <context:annotation-config /> - <mvc:resources mapping="/**.html" location="/" /> - <mvc:resources mapping="/**.png" location="/" /> - <mvc:resources mapping="/**.manifest" location="/" /> - <mvc:resources mapping="/**.json" location="/" /> - <mvc:resources mapping="/**.xml" location="/" /> - <mvc:resources mapping="/dojo/**" location="/dojo/" /> - <mvc:resources mapping="/dijit/**" location="/dijit/" /> - <mvc:resources mapping="/dojox/**" location="/dojox/" /> - <mvc:resources mapping="/app/**" location="/app/" /> - <mvc:resources mapping="/views/**" location="/views/" /> - <mvc:resources mapping="/lib/**" location="/lib/" /> - <mvc:resources mapping="/resources/**" location="/resources/" /> - <mvc:resources mapping="/screenshots/**" location="/screenshots/" /> - <mvc:resources mapping="/templates/**" location="/templates/" /> - + <mvc:resources mapping="/**" location="/" /> + <mvc:annotation-driven /> <bean id="viewResolver" - class="org.springframework.web.servlet.view.InternalResourceViewResolver"> - <property name="viewClass" - value="org.springframework.web.servlet.view.JstlView" /> - <property name="prefix" value="/WEB-INF/views/" /> - <property name="suffix" value=".jsp" /> - </bean> + class="org.springframework.web.servlet.view.InternalResourceViewResolver" + p:viewClass="org.springframework.web.servlet.view.JstlView" + p:prefix="/WEB-INF/views/" + p:suffix=".jsp" /> </beans> diff --git a/src/main/webapp/WEB-INF/spring/spring-main.xml b/src/main/webapp/WEB-INF/spring/spring-main.xml index 9b191bf95abc8fea87d60f7f5a1a1d700dad83bf..2c8fa638b68c365ae8fa5c95aa019f5ddc023a68 100644 --- a/src/main/webapp/WEB-INF/spring/spring-main.xml +++ b/src/main/webapp/WEB-INF/spring/spring-main.xml @@ -1,9 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + <bean id="propertyPlaceholderConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" + p:ignoreUnresolvablePlaceholders="false"> + <property name="locations" > + <list> + <value>config.properties.example</value> + <value>config.properties</value> + </list> + </property> + </bean> + + <import resource="spring-security.xml" /> + <context:component-scan base-package="de.thm.arsnova" /> <context:annotation-config /> diff --git a/src/main/webapp/WEB-INF/spring/spring-security.xml b/src/main/webapp/WEB-INF/spring/spring-security.xml index e1e54d7d04d4af95b2bef572cecce925400cbd55..ce404288bed1ed3facd354ce58518378b8636671 100644 --- a/src/main/webapp/WEB-INF/spring/spring-security.xml +++ b/src/main/webapp/WEB-INF/spring/spring-security.xml @@ -1,7 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security" - xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sec="http://www.springframework.org/schema/security" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd @@ -10,55 +12,47 @@ <context:component-scan base-package="de.thm.arsnova" /> <context:annotation-config /> - <bean - class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> - <property name="ignoreUnresolvablePlaceholders" value="false" /> - <property name="locations"> - <value>config.properties</value> - </property> - </bean> - - <sec:http entry-point-ref="casEntryPoint" - disable-url-rewriting="true"> + <sec:http entry-point-ref="casEntryPoint" disable-url-rewriting="true"> <sec:intercept-url pattern="/j_spring_security_check" access="IS_AUTHENTICATED_ANONYMOUSLY" /> <sec:intercept-url pattern="/doCasLogin" access="ROLE_USER" /> - <sec:custom-filter ref="casFilter" position="CAS_FILTER" /> + <sec:custom-filter ref="casAuthenticationFilter" position="CAS_FILTER" /> <sec:openid-login user-service-ref="openidUserDetailsService" default-target-url="${security.openid-target-url}" /> + <sec:logout invalidate-session="true" logout-url="/logout" logout-success-url="/j_spring_cas_security_logout"/> + <sec:custom-filter ref="singleSignOutFilter" before="CAS_FILTER"/> + <sec:anonymous enabled="false" /> </sec:http> + + <sec:authentication-manager alias="casAuthenticationManager"> + <sec:authentication-provider ref="casAuthenticationProvider" /> + </sec:authentication-manager> - <bean id="casFilter" - class="org.springframework.security.cas.web.CasAuthenticationFilter"> - <property name="authenticationManager" ref="casAuthManager" /> - </bean> + <bean id="casAuthenticationFilter" + class="org.springframework.security.cas.web.CasAuthenticationFilter" + p:authenticationManager-ref="casAuthenticationManager" /> <bean id="casEntryPoint" - class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"> - <property name="loginUrl" value="https://cas.thm.de/cas/login" /> - <property name="serviceProperties" ref="serviceProperties" /> - </bean> + class="org.springframework.security.cas.web.CasAuthenticationEntryPoint" + p:loginUrl="${security.cas-server-url}/login" + p:serviceProperties-ref="casServiceProperties" /> + + <bean id="casServiceProperties" + class="org.springframework.security.cas.ServiceProperties" + p:service="${security.cas-check-url}" + p:sendRenew="false" /> - <sec:authentication-manager alias="casAuthManager"> - <sec:authentication-provider ref="casAuthProvider" /> - </sec:authentication-manager> + <bean id="casAuthenticationProvider" + class="org.springframework.security.cas.authentication.CasAuthenticationProvider" + p:key="casAuthProviderKey" + p:serviceProperties-ref="casServiceProperties" + p:authenticationUserDetailsService-ref="casUserDetailsService" + p:ticketValidator-ref="casTicketValidator" /> - <!-- TODO: Replace local URL with real world url / parameter? --> - <bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"> - <property name="service" value="${security.cas-check-url}" /> - <property name="sendRenew" value="false" /> + <bean id="casUserDetailsService" class="de.thm.arsnova.CasUserDetailsService" /> + <bean id="casTicketValidator" class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"> + <constructor-arg value="${security.cas-server-url}" /> </bean> - <bean id="casAuthProvider" - class="org.springframework.security.cas.authentication.CasAuthenticationProvider" - p:serviceProperties-ref="serviceProperties" p:key="casAuthProviderKey"> - <property name="authenticationUserDetailsService"> - <bean class="de.thm.arsnova.CasUserDetailsService" /> - </property> - <property name="ticketValidator"> - <bean class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"> - <constructor-arg value="${security.cas-service-url}" /> - </bean> - </property> - </bean> + <bean id="singleSignOutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter" /> </beans> diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index e051aa8ec135bec3e5aa671abbbf01d3fa6b6f8f..8efaa0b9d77f94ce57705ce6df73b958b7b8afa9 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -7,19 +7,12 @@ <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring/spring-main.xml - /WEB-INF/spring/spring-security.xml </param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> - <listener> - <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> - </listener> - <listener> - <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> - </listener> <servlet> <servlet-name>arsnova</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> @@ -38,7 +31,7 @@ <servlet-name>api</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping> - <filter> + <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> @@ -46,9 +39,31 @@ <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> + <filter> + <filter-name>characterEncodingFilter</filter-name> + <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> + <init-param> + <param-name>encoding</param-name> + <param-value>UTF-8</param-value> + </init-param> + </filter> + <filter-mapping> + <filter-name>characterEncodingFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> + <listener> + <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> + </listener> + <listener> + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> + </listener> + <listener> + <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> + </listener> + <mime-mapping> <extension>manifest</extension> <mime-type>text/cache-manifest</mime-type> diff --git a/src/main/webapp/config.properties.example b/src/main/webapp/config.properties.example index 280d47dae5a9fa5b895a069ecb65afdf5597dce7..858a7a1c94036f9cf899199a089514abeb6e725d 100644 --- a/src/main/webapp/config.properties.example +++ b/src/main/webapp/config.properties.example @@ -1,6 +1,6 @@ security.openid-target-url=http://localhost:8080/arsnova-war/doOpenIdLogin security.cas-check-url=http://localhost:8080/arsnova-war/j_spring_cas_security_check -security.cas-service-url=https://cas.thm.de/cas +security.cas-server-url=https://cas.thm.de/cas couchdb.host=localhost couchdb.port=5984