Skip to content

Instantly share code, notes, and snippets.

Created March 5, 2013 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5094420 to your computer and use it in GitHub Desktop.
Save anonymous/5094420 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd">
<context:property-placeholder location="classpath:resource-provider-local.properties"/>
<sec:authentication-manager alias="authenticationManager"/>
<!-- See docs for EL-based access control http://static.springsource.org/spring-security/site/docs/3.0.x/reference/el-access.html -->
<sec:http entry-point-ref="oauthAuthenticationEntryPoint"
create-session="ifRequired"
use-expressions="true">
<sec:intercept-url pattern="/api/**"
access="hasRole('ROLE_CLIENT') and #oauth2.hasScope('read')"
requires-channel="any"/>
<sec:custom-filter ref="resourceServerFilter_SimpleAPI_All" position="PRE_AUTH_FILTER" />
<sec:access-denied-handler ref="oauthAccessDeniedHandler" />
<sec:expression-handler ref="oauthWebExpressionHandler" />
</sec:http>
<!-- security error handling concerns specific to OAuth2 resources -->
<bean id="oauthAccessDeniedHandler" class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />
<oauth:web-expression-handler id="oauthWebExpressionHandler" />
<!--
Client authentication with HTTP Basic scheme. This is the recommended way by specification.
-->
<bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint" />
<!--//// OAuth 2.0 configuration ////-->
<!-- Loads an instance of OAuth2AuthenticationProcessingFilter. The following attributes can be applied to the resource-server element:
- token-services-ref: The reference to the bean that defines the token services.
- resource-id: The id for the resource (optional, but required by our implementation of authorization server. it will be validated by the auth server!)
-->
<oauth:resource-server id="resourceServerFilter_SimpleAPI_All" token-services-ref="tokenServices" resource-id="${resource.id}"/>
<bean id="tokenServices" class="cz.cvut.oauth.provider.RemoteTokenServiceImpl"
p:tokensDAO-ref="remoteTokensOauth2RestTemplateDAO"/>
<bean id="remoteTokensOauth2RestTemplateDAO" class="cz.cvut.oauth.provider.dao.RemoteTokensOauth2RestTemplateDAO"
p:restTemplate-ref="oauthRestTemplateCheckTokenEndpoint"
p:checkTokentEndpoint="${check.token.endpoint}"/>
<import resource="oauth2-client.xml"/>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment