1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
|
3
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
4
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
xmlns:context="http://www.springframework.org/schema/context"
|
6
|
xmlns:security="http://www.springframework.org/schema/security"
|
7
|
xmlns:util="http://www.springframework.org/schema/util"
|
8
|
xsi:schemaLocation="
|
9
|
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
|
10
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
11
|
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
|
12
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
13
|
default-autowire="byType">
|
14
|
|
15
|
|
16
|
<security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>
|
17
|
|
18
|
<!--
|
19
|
-
|
20
|
- The authentication filter
|
21
|
-
|
22
|
-->
|
23
|
<bean id="openIdConnectAuthenticationFilter" class="org.mitre.openid.connect.client.OIDCAuthenticationFilter">
|
24
|
<property name="authenticationManager" ref="authenticationManager" />
|
25
|
<property name="issuerService" ref="staticIssuerService" />
|
26
|
<property name="serverConfigurationService" ref="staticServerConfigurationService" />
|
27
|
<property name="clientConfigurationService" ref="staticClientConfigurationService" />
|
28
|
<property name="authRequestOptionsService" ref="staticAuthRequestOptionsService" />
|
29
|
<property name="authRequestUrlBuilder" ref="plainAuthRequestUrlBuilder" />
|
30
|
<property name="authenticationSuccessHandler" ref="frontEndRedirect"/>
|
31
|
|
32
|
</bean>
|
33
|
|
34
|
<!-- The login handler -->
|
35
|
<bean class="eu.dnetlib.openaire.user.login.handler.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect">
|
36
|
<property name="frontEndURI" value="${webbapp.front}"/>
|
37
|
<property name="frontPath" value="${webbapp.front.path}"/>
|
38
|
<property name="frontDomain" value="${webbapp.front.domain:#{null}}"/>
|
39
|
</bean>
|
40
|
|
41
|
|
42
|
<security:http auto-config="false" use-expressions="true"
|
43
|
disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint"
|
44
|
pattern="/**">
|
45
|
<security:custom-filter before="PRE_AUTH_FILTER" ref="openIdConnectAuthenticationFilter" />
|
46
|
<security:logout logout-url="/openid_logout" invalidate-session="true" delete-cookies="SESSION"
|
47
|
logout-success-url="${oidc.logout}${webbapp.front}"/>
|
48
|
<security:intercept-url pattern="/personalToken" access="hasAuthority('REGISTERED_USER')"/>
|
49
|
<security:intercept-url pattern="/serviceToken" access="hasAuthority('REGISTERED_USER')"/>
|
50
|
<security:intercept-url pattern="/registerService" access="hasAuthority('REGISTERED_USER')"/>
|
51
|
<security:intercept-url pattern="/editService" access="hasAuthority('REGISTERED_USER')"/>
|
52
|
<security:intercept-url pattern="/registeredServices" access="hasAuthority('REGISTERED_USER')"/>
|
53
|
<security:intercept-url pattern="/editRegisteredService" access="hasAuthority('REGISTERED_USER')"/>
|
54
|
<security:csrf disabled="true"/>
|
55
|
</security:http>
|
56
|
|
57
|
<bean id="requestContextFilter" class="org.springframework.web.filter.RequestContextFilter"/>
|
58
|
|
59
|
<bean id="webexpressionHandler"
|
60
|
class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
|
61
|
|
62
|
<bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" >
|
63
|
<constructor-arg type="java.lang.String" value="/openid_connect_login"/>
|
64
|
</bean>
|
65
|
|
66
|
<security:authentication-manager alias="authenticationManager">
|
67
|
<security:authentication-provider ref="openIdConnectAuthenticationProvider" />
|
68
|
</security:authentication-manager>
|
69
|
|
70
|
<bean id="openIdConnectAuthenticationProvider" class="org.mitre.openid.connect.client.OIDCAuthenticationProvider">
|
71
|
<property name="authoritiesMapper">
|
72
|
<bean class="eu.dnetlib.openaire.user.login.authorization.OpenAIREAuthoritiesMapper"/>
|
73
|
</property>
|
74
|
</bean>
|
75
|
|
76
|
<util:set id="namedAdmins" value-type="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
|
77
|
<!--
|
78
|
This is an example of how to set up a user as an administrator: they'll be given ROLE_ADMIN in addition to ROLE_USER.
|
79
|
Note that having an administrator role on the IdP doesn't grant administrator access on this client.
|
80
|
|
81
|
These are values from the demo "openid-connect-server-webapp" project of MITREid Connect.
|
82
|
-->
|
83
|
<bean class="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
|
84
|
<constructor-arg name="subject" value="subject_value" />
|
85
|
<constructor-arg name="issuer" value="${oidc.issuer}" />
|
86
|
</bean>
|
87
|
</util:set>
|
88
|
|
89
|
<!--<bean id="securityContextLogoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>-->
|
90
|
<!--<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">-->
|
91
|
<!--<property name="filterProcessesUrl" value="/logout"/>-->
|
92
|
<!--<constructor-arg index="0" value="/"/>-->
|
93
|
<!--<constructor-arg index="1">-->
|
94
|
<!--<list>-->
|
95
|
<!--<ref bean="securityContextLogoutHandler"/>-->
|
96
|
<!--<!–ref bean="myLogoutHandler"/–>-->
|
97
|
<!--</list>-->
|
98
|
<!--</constructor-arg>-->
|
99
|
<!--</bean>-->
|
100
|
|
101
|
<!--<bean class="eu.dnetlib.openaire.user.security.FrontEndLinkURILogoutSuccessHandler" id="frontEndRedirectLogout"/>-->
|
102
|
|
103
|
<!--<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">-->
|
104
|
<!--<property name="filterProcessesUrl" value="/logout"/>-->
|
105
|
<!--<constructor-arg index="0" value="/"/>-->
|
106
|
<!--<constructor-arg index="1">-->
|
107
|
<!--<list>-->
|
108
|
<!--<ref bean="securityContextLogoutHandler"/>-->
|
109
|
<!--<!–ref bean="myLogoutHandler"/–>-->
|
110
|
<!--</list>-->
|
111
|
<!--</constructor-arg>-->
|
112
|
<!--</bean>-->
|
113
|
|
114
|
<!--
|
115
|
Static issuer service, returns the same issuer for every request.
|
116
|
-->
|
117
|
<bean class="org.mitre.openid.connect.client.service.impl.StaticSingleIssuerService" id="staticIssuerService">
|
118
|
<property name="issuer" value="${oidc.issuer}" />
|
119
|
</bean>
|
120
|
|
121
|
<!--
|
122
|
Dynamic server configuration, fetches the server's information using OIDC Discovery.
|
123
|
-->
|
124
|
<bean class="org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService" id="staticServerConfigurationService">
|
125
|
<property name="servers">
|
126
|
<map>
|
127
|
<entry key="${oidc.issuer}">
|
128
|
<bean class="org.mitre.openid.connect.config.ServerConfiguration">
|
129
|
<property name="issuer" value="${oidc.issuer}" />
|
130
|
<property name="authorizationEndpointUri" value="${oidc.issuer}authorize" />
|
131
|
<property name="tokenEndpointUri" value="${oidc.issuer}token" />
|
132
|
<property name="userInfoUri" value="${oidc.issuer}userinfo" />
|
133
|
<property name="jwksUri" value="${oidc.issuer}jwk" />
|
134
|
<property name="revocationEndpointUri" value="${oidc.issuer}revoke" />
|
135
|
</bean>
|
136
|
</entry>
|
137
|
</map>
|
138
|
</property>
|
139
|
</bean>
|
140
|
|
141
|
|
142
|
<!--
|
143
|
Static Client Configuration. Configures a client statically by storing configuration on a per-issuer basis.
|
144
|
|
145
|
-->
|
146
|
|
147
|
<bean class="org.mitre.openid.connect.client.service.impl.StaticClientConfigurationService" id="staticClientConfigurationService">
|
148
|
<property name="clients">
|
149
|
<map>
|
150
|
<entry key="${oidc.issuer}">
|
151
|
<bean class="org.mitre.oauth2.model.RegisteredClient">
|
152
|
<property name="clientId" value="${oidc.id}" />
|
153
|
<property name="clientSecret" value="${oidc.secret}" />
|
154
|
<property name="scope" value="#{scopeReader.scopes}"/> <!-- now read from properties file via scopeReader -->
|
155
|
<property name="tokenEndpointAuthMethod" value="SECRET_BASIC" />
|
156
|
<property name="redirectUris">
|
157
|
<set>
|
158
|
<value>${oidc.home}</value>
|
159
|
</set>
|
160
|
</property>
|
161
|
</bean>
|
162
|
</entry>
|
163
|
</map>
|
164
|
</property>
|
165
|
</bean>
|
166
|
|
167
|
<bean class="eu.dnetlib.openaire.user.login.utils.ScopeReader" id="scopeReader">
|
168
|
<constructor-arg value="${scopes}"/>
|
169
|
</bean>
|
170
|
|
171
|
<!--
|
172
|
-
|
173
|
- Auth request options service: returns the optional components of the request
|
174
|
-
|
175
|
-->
|
176
|
<bean class="org.mitre.openid.connect.client.service.impl.StaticAuthRequestOptionsService" id="staticAuthRequestOptionsService">
|
177
|
<property name="options">
|
178
|
<map>
|
179
|
<!-- Entries in this map are sent as key-value parameters to the auth request -->
|
180
|
<!--
|
181
|
<entry key="display" value="page" />
|
182
|
<entry key="max_age" value="30" />
|
183
|
<entry key="prompt" value="none" />
|
184
|
-->
|
185
|
</map>
|
186
|
</property>
|
187
|
</bean>
|
188
|
|
189
|
<!--
|
190
|
Plain authorization request builder, puts all options as query parameters on the GET request
|
191
|
-->
|
192
|
<bean class="org.mitre.openid.connect.client.service.impl.PlainAuthRequestUrlBuilder" id="plainAuthRequestUrlBuilder" />
|
193
|
|
194
|
<context:component-scan base-package="eu.dnetlib.openaire.user.login.registry.beans" />
|
195
|
<context:annotation-config></context:annotation-config>
|
196
|
|
197
|
</beans>
|