Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created February 13, 2015 17:04
Show Gist options
  • Save dwelch2344/0449c8c7dacbebc70ea1 to your computer and use it in GitHub Desktop.
Save dwelch2344/0449c8c7dacbebc70ea1 to your computer and use it in GitHub Desktop.
An example security xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
">
<security:http entry-point-ref="authenticationProcessingFilterEntryPoint" use-expressions="true" auto-config="true" >
<security:form-login login-page="/login" login-processing-url="/doLogin"
authentication-failure-url="/login"
username-parameter="user" password-parameter="password" />
<security:anonymous enabled="false"/>
<security:intercept-url pattern="/secure/**" access="hasRole('ROLE_USER')"/>
<security:custom-filter after="LOGOUT_FILTER" ref="logoutFilter" />
</security:http>
<bean id="authenticationProcessingFilterEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/login" />
</bean>
<bean id="logoutFilter"
class="org.springframework.security.web.authentication.logout.LogoutFilter">
<constructor-arg value="/" />
<constructor-arg>
<list>
<bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
</list>
</constructor-arg>
<property name="filterProcessesUrl" value="/logout" />
</bean>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment