-
Notifications
You must be signed in to change notification settings - Fork 827
/
spring-servlet.xml
executable file
·262 lines (218 loc) · 13 KB
/
spring-servlet.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Cloud Foundry 2012.02.03 Beta Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. This product is licensed to
you under the Apache License, Version 2.0 (the "License"). You may not use this product except in compliance with the License.
This product includes a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents
is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. -->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.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/beans http://www.springframework.org/schema/beans/spring-beans-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/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<!-- The data source has to be defined first -->
<import resource="spring-scim.xml" />
<import resource="oauth-clients.xml" />
<context:property-placeholder properties-ref="applicationProperties" />
<sec:http pattern="/resources/**" security="none" />
<sec:http pattern="/favicon.ico" security="none" />
<sec:http pattern="/index.html" security="none" />
<sec:http pattern="/login_info" security="none" />
<authentication-manager id="emptyAuthenticationManager" xmlns="http://www.springframework.org/schema/security" />
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased" xmlns="http://www.springframework.org/schema/beans">
<constructor-arg>
<list>
<bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" />
<bean class="org.springframework.security.access.vote.RoleVoter" />
<bean class="org.springframework.security.access.vote.AuthenticatedVoter" />
</list>
</constructor-arg>
</bean>
<!-- Version of the /authorize endpoint for stateless clients such as VMC -->
<http request-matcher-ref="oauthAuthorizeRequestMatcher" create-session="stateless" entry-point-ref="oauthAuthenticationEntryPoint"
authentication-manager-ref="authzAuthenticationMgr" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
<custom-filter ref="authzAuthenticationFilter" position="FORM_LOGIN_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<bean id="oauthAuthorizeRequestMatcher" class="org.cloudfoundry.identity.uaa.security.web.UaaRequestMatcher">
<constructor-arg value="/oauth/authorize" />
<property name="accept" value="application/json" />
<property name="parameters">
<map>
<entry key="response_type" value="token" />
<entry key="credentials" value="{" />
</map>
</property>
</bean>
<bean id="authzAuthenticationFilter" class="org.cloudfoundry.identity.uaa.authentication.AuthzAuthenticationFilter">
<constructor-arg ref="authzAuthenticationMgr" />
</bean>
<http pattern="/check_token" create-session="stateless" entry-point-ref="basicAuthenticationEntryPoint"
authentication-manager-ref="clientAuthenticationManager" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="ROLE_CLIENT" />
<anonymous enabled="false" />
<custom-filter ref="clientAuthenticationFilter" position="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<http pattern="/token_key" create-session="stateless" entry-point-ref="basicAuthenticationEntryPoint"
authentication-manager-ref="clientAuthenticationManager" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="ROLE_ADMIN,ROLE_CLIENT" method="POST" />
<intercept-url pattern="/**" access="ROLE_CLIENT" method="GET" />
<anonymous enabled="false" />
<custom-filter ref="clientAuthenticationFilter" position="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<http pattern="/userinfo" create-session="stateless" authentication-manager-ref="emptyAuthenticationManager"
entry-point-ref="oauthAuthenticationEntryPoint" access-decision-manager-ref="accessDecisionManager"
xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="SCOPE_OPENID" />
<custom-filter ref="openidResourceAuthenticationFilter" position="PRE_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="clientAuthenticationManager"
entry-point-ref="basicAuthenticationEntryPoint" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
<anonymous enabled="false" />
<custom-filter ref="clientAuthenticationFilter" position="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<!-- The OAuth2 protected resources are separated out into their own block so we can deal with authorization and error handling
separately. This isn't mandatory, but it makes it easier to control the behaviour. -->
<bean id="clientAuthenticationFilter" class="org.springframework.security.web.authentication.www.BasicAuthenticationFilter">
<constructor-arg ref="clientAuthenticationManager" />
<constructor-arg ref="basicAuthenticationEntryPoint" />
<property name="authenticationDetailsSource" ref="authenticationDetailsSource" />
</bean>
<bean id="basicAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
<property name="realmName" value="UAA/client" />
<property name="typeName" value="Basic" />
</bean>
<bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
<property name="realmName" value="UAA/oauth" />
</bean>
<bean id="oauthAccessDeniedHandler" class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />
<!-- We need this even though /varz is in a different servlet because the default security filter applies to all requests -->
<http pattern="/varz/**" create-session="stateless" authentication-manager-ref="emptyAuthenticationManager"
entry-point-ref="oauthAuthenticationEntryPoint" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
</http>
<http access-denied-page="/" authentication-manager-ref="authzAuthenticationMgr" xmlns="http://www.springframework.org/schema/security">
<!-- machine API access to the authorization process itself is allowed -->
<intercept-url pattern="/login**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/oauth/authorize" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/oauth/**" access="ROLE_USER" />
<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
<form-login authentication-failure-url="/login?error=true" login-page="/login" login-processing-url="/login.do"
username-parameter="username" password-parameter="password" authentication-details-source-ref="authenticationDetailsSource" />
<logout logout-success-url="/" logout-url="/logout.do" />
</http>
<authentication-manager id="clientAuthenticationManager" xmlns="http://www.springframework.org/schema/security">
<authentication-provider user-service-ref="clientDetailsUserService">
<password-encoder ref="bcryptPasswordEncoder" />
</authentication-provider>
</authentication-manager>
<bean id="bcryptPasswordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" />
<bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore" />
<bean id="clientDetailsUserService" class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService">
<constructor-arg ref="clientDetails" />
<property name="passwordEncoder" ref="bcryptPasswordEncoder" />
</bean>
<bean id="userApprovalHandler" class="org.cloudfoundry.identity.uaa.oauth.UaaUserApprovalHandler">
<property name="tokenServices" ref="tokenServices" />
<property name="autoApproveClients">
<set>
<value>vmc</value>
</set>
</property>
</bean>
<bean id="tokenServices" class="org.cloudfoundry.identity.uaa.oauth.JwtTokenServices">
<property name="supportRefreshToken" value="true" />
<property name="tokenStore" ref="tokenStore" />
<property name="key" value="${jwt.token.key:tokenkey}" />
</bean>
<oauth:authorization-server client-details-service-ref="clientDetails" token-services-ref="tokenServices"
user-approval-handler-ref="userApprovalHandler">
<oauth:authorization-code />
<oauth:implicit />
<oauth:refresh-token />
<oauth:client-credentials />
<oauth:password authentication-manager-ref="authzAuthenticationMgr" />
</oauth:authorization-server>
<oauth:web-expression-handler id="oauthWebExpressionHandler" />
<oauth:resource-server id="openidResourceAuthenticationFilter" token-services-ref="tokenServices"
resource-id="openid" entry-point-ref="oauthAuthenticationEntryPoint"/>
<context:mbean-server id="mbeanServer" />
<context:mbean-export server="mbeanServer" default-domain="spring.application" registration="replaceExisting" />
<bean class="org.springframework.jmx.export.MBeanExporter">
<property name="server" ref="mbeanServer" />
<property name="beans">
<map>
<entry key="spring.application:type=TokenStore,name=tokenStore" value-ref="tokenStore" />
</map>
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler">
<property name="methodMappings">
<map>
<entry key="spring.application:type=TokenStore,name=tokenStore" value="getAccessTokenCount,getRefreshTokenCount,getFlushInterval,setFlushInterval" />
</map>
</property>
</bean>
</property>
<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
</bean>
<mvc:resources location="/resources/" mapping="/resources/**" />
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html" />
<entry key="json" value="application/json" />
</map>
</property>
<property name="viewResolvers">
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</property>
<property name="defaultViews">
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</property>
</bean>
<!--Basic application beans. -->
<bean id="loginInfoEndpoint" class="org.cloudfoundry.identity.uaa.authentication.login.LoginInfoEndpoint" />
<bean id="userInfoEndpoint" class="org.cloudfoundry.identity.uaa.openid.UserInfoEndpoint">
<property name="userDatabase" ref="userDatabase" />
</bean>
<bean id="checkTokenEndpoint" class="org.cloudfoundry.identity.uaa.oauth.CheckTokenEndpoint">
<property name="tokenServices" ref="tokenServices" />
</bean>
<bean id="tokenAdminEndpoints" class="org.cloudfoundry.identity.uaa.oauth.TokenAdminEndpoints">
<property name="tokenServices" ref="tokenServices" />
</bean>
<bean id="accessController" class="org.cloudfoundry.identity.uaa.oauth.AccessController">
<property name="clientDetailsService" ref="clientDetails" />
<!-- Always use HTTPS if deployed on cloudfoundry -->
<property name="useSsl" value="#{applicationProperties['oauth.authorize.ssl']?:(T(java.lang.System).getenv('VCAP_APPLICATION')!=null ? true : null)}"/>
</bean>
<bean id="homeController" class="org.cloudfoundry.identity.uaa.home.HomeController" />
<bean id="userDatabase" class="org.cloudfoundry.identity.uaa.user.JdbcUaaUserDatabase">
<constructor-arg ref="jdbcTemplate" />
</bean>
<bean id="authzAuthenticationMgr" class="org.cloudfoundry.identity.uaa.authentication.manager.AuthzAuthenticationManager">
<constructor-arg ref="userDatabase" />
<property name="accountLoginPolicy">
<bean class="org.cloudfoundry.identity.uaa.authentication.manager.PeriodLockoutPolicy">
<constructor-arg ref="jdbcAuditService" />
<property name="lockoutAfterFailures" value="5" />
<property name="lockoutPeriodSeconds" value="300" />
</bean>
</property>
</bean>
</beans>