Created
October 29, 2011 19:50
-
-
Save eugenp/1324990 to your computer and use it in GitHub Desktop.
Securing a RESTful Web Service with Spring Security 3.1, part 3 - the security configuraiton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans:beans | |
xmlns="http://www.springframework.org/schema/security" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:beans="http://www.springframework.org/schema/beans" | |
xmlns:sec="http://www.springframework.org/schema/security" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/security | |
http://www.springframework.org/schema/security/spring-security-3.1.xsd | |
http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> | |
<http entry-point-ref="restAuthenticationEntryPoint"> | |
<intercept-url pattern="/api/admin/**" access="ROLE_ADMIN"/> | |
<custom-filter ref="myFilter" position="FORM_LOGIN_FILTER"/> | |
<logout /> | |
</http> | |
<beans:bean id="myFilter" | |
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"> | |
<beans:property name="authenticationManager" ref="authenticationManager"/> | |
<beans:property name="authenticationSuccessHandler" ref="mySuccessHandler"/> | |
</beans:bean> | |
<beans:bean id="mySuccessHandler" | |
class="org.rest.security.MySavedRequestAwareAuthenticationSuccessHandler"/> | |
<authentication-manager alias="authenticationManager"> | |
<authentication-provider> | |
<user-service> | |
<user name="temporary" password="temporary" authorities="ROLE_ADMIN"/> | |
<user name="user" password="user" authorities="ROLE_USER"/> | |
</user-service> | |
</authentication-provider> | |
</authentication-manager> | |
</beans:beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is used in:
http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/