Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2016 13:46
What would you like to do?
Spring Secuirty file to configure url-patterns, login, logout and error page. Configure handler for successful and unsuccessful login. Authentication manager and provider.
<beans:beans xmlns=""
xmlns:beans="" xmlns:xsi=""
<http auto-config="true">
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/admin**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
<form-login login-page="/login"
authentication-failure-handler-ref="customAuthenticationFailureHandler" />
<access-denied-handler error-page="/accessDenied" />
<logout logout-url="/logout" logout-success-url="/login?logout" />
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="userService"/>
Copy link

Refer Spring Security 4 with Hibernate for complete example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment