Project

General

Profile

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"/>
47
        <security:csrf disabled="true"/>
48
    </security:http>
49

    
50
    <bean id="requestContextFilter" class="org.springframework.web.filter.RequestContextFilter"/>
51

    
52
    <bean id="webexpressionHandler"
53
          class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
54

    
55
    <bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" >
56
        <constructor-arg type="java.lang.String" value="/openid_connect_login"/>
57
    </bean>
58

    
59
    <security:authentication-manager alias="authenticationManager">
60
        <security:authentication-provider ref="openIdConnectAuthenticationProvider" />
61
    </security:authentication-manager>
62

    
63
    <bean id="openIdConnectAuthenticationProvider" class="org.mitre.openid.connect.client.OIDCAuthenticationProvider">
64
        <property name="authoritiesMapper">
65
            <!--<bean class="org.mitre.openid.connect.client.NamedAdminAuthoritiesMapper">
66
                <property name="admins" ref="namedAdmins" />
67
            </bean>-->
68
            <bean class="eu.dnetlib.openaire.user.login.authorization.OpenAIREAuthoritiesMapper"/>
69
        </property>
70
    </bean>
71

    
72
    <util:set id="namedAdmins" value-type="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
73
        <!--
74
            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.
75
            Note that having an administrator role on the IdP doesn't grant administrator access on this client.
76

    
77
            These are values from the demo "openid-connect-server-webapp" project of MITREid Connect.
78
        -->
79
        <bean class="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
80
            <constructor-arg name="subject" value="subject_value" />
81
            <constructor-arg name="issuer" value="${oidc.issuer}" />
82
        </bean>
83
    </util:set>
84
    
85
    <!--<bean id="securityContextLogoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>-->
86
    <!--<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">-->
87
        <!--<property name="filterProcessesUrl" value="/logout"/>-->
88
        <!--<constructor-arg index="0" value="/"/>-->
89
        <!--<constructor-arg index="1">-->
90
            <!--<list>-->
91
                <!--<ref bean="securityContextLogoutHandler"/>-->
92
                <!--&lt;!&ndash;ref bean="myLogoutHandler"/&ndash;&gt;-->
93
            <!--</list>-->
94
        <!--</constructor-arg>-->
95
    <!--</bean>-->
96

    
97
    <!--<bean class="eu.dnetlib.openaire.user.security.FrontEndLinkURILogoutSuccessHandler" id="frontEndRedirectLogout"/>-->
98

    
99
    <!--<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">-->
100
        <!--<property name="filterProcessesUrl" value="/logout"/>-->
101
        <!--<constructor-arg index="0" value="/"/>-->
102
        <!--<constructor-arg index="1">-->
103
            <!--<list>-->
104
                <!--<ref bean="securityContextLogoutHandler"/>-->
105
                <!--&lt;!&ndash;ref bean="myLogoutHandler"/&ndash;&gt;-->
106
            <!--</list>-->
107
        <!--</constructor-arg>-->
108
    <!--</bean>-->
109

    
110
    <!--
111
        Static issuer service, returns the same issuer for every request.
112
    -->
113
    <bean class="org.mitre.openid.connect.client.service.impl.StaticSingleIssuerService" id="staticIssuerService">
114
        <property name="issuer" value="${oidc.issuer}" />
115
    </bean>
116

    
117
    <!--
118
        Dynamic server configuration, fetches the server's information using OIDC Discovery.
119
    -->
120
    <bean class="org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService" id="staticServerConfigurationService">
121
        <property name="servers">
122
            <map>
123
                <entry key="${oidc.issuer}">
124
                    <bean class="org.mitre.openid.connect.config.ServerConfiguration">
125
                        <property name="issuer" value="${oidc.issuer}" />
126
                        <property name="authorizationEndpointUri"	value="${oidc.issuer}authorize" />
127
                        <property name="tokenEndpointUri"	value="${oidc.issuer}token" />
128
                        <property name="userInfoUri" value="${oidc.issuer}userinfo" />
129
                        <property name="jwksUri" value="${oidc.issuer}jwk" />
130
                        <property name="revocationEndpointUri" value="${oidc.issuer}revoke" />
131
                    </bean>
132
                </entry>
133
            </map>
134
        </property>
135
    </bean>
136

    
137

    
138
    <!--
139
       Static Client Configuration. Configures a client statically by storing configuration on a per-issuer basis.
140

    
141
    -->
142

    
143
    <bean class="org.mitre.openid.connect.client.service.impl.StaticClientConfigurationService" id="staticClientConfigurationService">
144
        <property name="clients">
145
            <map>
146
                <entry key="${oidc.issuer}">
147
                    <bean class="org.mitre.oauth2.model.RegisteredClient">
148
                        <property name="clientId" value="${oidc.id}" />
149
                        <property name="clientSecret" value="${oidc.secret}" />
150
                        <property name="scope">
151
                            <set value-type="java.lang.String">
152
                                <value>openid</value>
153
                                <value>profile</value>
154
                                <value>email</value>
155
                                <value>eduperson_entitlement</value>
156
                                <value>offline_access</value>
157
                            </set>
158
                        </property>
159
                        <property name="tokenEndpointAuthMethod" value="SECRET_BASIC" />
160
                        <property name="redirectUris">
161
                            <set>
162
                                <value>${oidc.home}</value>
163
                            </set>
164
                        </property>
165
                    </bean>
166
                </entry>
167
            </map>
168
        </property>
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>
(4-4/4)