Skip to content

Commit 40c0a45

Browse files
committed
Define oauth2-login xsd elements
Issue gh-4557
1 parent a3e09fa commit 40c0a45

File tree

13 files changed

+4262
-12
lines changed

13 files changed

+4262
-12
lines changed

config/src/main/java/org/springframework/security/config/Elements.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,4 +72,7 @@ public abstract class Elements {
7272

7373
public static final String WEBSOCKET_MESSAGE_BROKER = "websocket-message-broker";
7474
public static final String INTERCEPT_MESSAGE = "intercept-message";
75+
76+
public static final String OAUTH2_LOGIN = "oauth2-login";
77+
public static final String CLIENT_REGISTRATIONS = "client-registrations";
7578
}

config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2013 the original author or authors.
2+
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@
4141
import org.springframework.security.config.method.GlobalMethodSecurityBeanDefinitionParser;
4242
import org.springframework.security.config.method.InterceptMethodsBeanDefinitionDecorator;
4343
import org.springframework.security.config.method.MethodSecurityMetadataSourceBeanDefinitionParser;
44+
import org.springframework.security.config.oauth2.client.ClientRegistrationsBeanDefinitionParser;
4445
import org.springframework.security.config.websocket.WebSocketMessageBrokerSecurityBeanDefinitionParser;
4546
import org.springframework.security.core.SpringSecurityCoreVersion;
4647
import org.springframework.util.ClassUtils;
@@ -86,7 +87,7 @@ public BeanDefinition parse(Element element, ParserContext pc) {
8687
if (!namespaceMatchesVersion(element)) {
8788
pc.getReaderContext()
8889
.fatal("You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd schema "
89-
+ "with Spring Security 5.2. Please update your schema declarations to the 5.2 schema.",
90+
+ "with Spring Security 5.3. Please update your schema declarations to the 5.3 schema.",
9091
element);
9192
}
9293
String name = pc.getDelegate().getLocalName(element);
@@ -192,6 +193,7 @@ private void loadParsers() {
192193
new FilterInvocationSecurityMetadataSourceParser());
193194
parsers.put(Elements.FILTER_CHAIN, new FilterChainBeanDefinitionParser());
194195
filterChainMapBDD = new FilterChainMapBeanDefinitionDecorator();
196+
parsers.put(Elements.CLIENT_REGISTRATIONS, new ClientRegistrationsBeanDefinitionParser());
195197
}
196198

197199
if (ClassUtils.isPresent(MESSAGE_CLASSNAME, getClass().getClassLoader())) {
@@ -221,7 +223,7 @@ private boolean namespaceMatchesVersion(Element element) {
221223
private boolean matchesVersionInternal(Element element) {
222224
String schemaLocation = element.getAttributeNS(
223225
"http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
224-
return schemaLocation.matches("(?m).*spring-security-5\\.2.*.xsd.*")
226+
return schemaLocation.matches("(?m).*spring-security-5\\.3.*.xsd.*")
225227
|| schemaLocation.matches("(?m).*spring-security.xsd.*")
226228
|| !schemaLocation.matches("(?m).*spring-security.*");
227229
}

config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -158,6 +158,7 @@ final class AuthenticationConfigBuilder {
158158
createRememberMeFilter(authenticationManager);
159159
createBasicFilter(authenticationManager);
160160
createFormLoginFilter(sessionStrategy, authenticationManager);
161+
createOAuth2LoginFilter(sessionStrategy, authenticationManager);
161162
createOpenIDLoginFilter(sessionStrategy, authenticationManager);
162163
createX509Filter(authenticationManager);
163164
createJeeFilter(authenticationManager);
@@ -235,6 +236,15 @@ void createFormLoginFilter(BeanReference sessionStrategy, BeanReference authMana
235236
}
236237
}
237238

239+
void createOAuth2LoginFilter(BeanReference sessionStrategy, BeanReference authManager) {
240+
Element oauth2LoginElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.OAUTH2_LOGIN);
241+
if (oauth2LoginElt != null || this.autoConfig) {
242+
OAuth2LoginBeanDefinitionParser parser = new OAuth2LoginBeanDefinitionParser();
243+
parser.parse(oauth2LoginElt, this.pc);
244+
// TODO Implement
245+
}
246+
}
247+
238248
void createOpenIDLoginFilter(BeanReference sessionStrategy, BeanReference authManager) {
239249
Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt,
240250
Elements.OPENID_LOGIN);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.security.config.http;
17+
18+
import org.springframework.beans.factory.config.BeanDefinition;
19+
import org.springframework.beans.factory.xml.BeanDefinitionParser;
20+
import org.springframework.beans.factory.xml.ParserContext;
21+
import org.w3c.dom.Element;
22+
23+
/**
24+
* @author
25+
*/
26+
final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
27+
28+
@Override
29+
public BeanDefinition parse(Element element, ParserContext parserContext) {
30+
// TODO Implement
31+
return null;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.security.config.oauth2.client;
17+
18+
import org.springframework.beans.factory.config.BeanDefinition;
19+
import org.springframework.beans.factory.xml.BeanDefinitionParser;
20+
import org.springframework.beans.factory.xml.ParserContext;
21+
import org.w3c.dom.Element;
22+
23+
/**
24+
* @author
25+
*/
26+
public final class ClientRegistrationsBeanDefinitionParser implements BeanDefinitionParser {
27+
28+
@Override
29+
public BeanDefinition parse(Element element, ParserContext parserContext) {
30+
// TODO Implement
31+
return null;
32+
}
33+
}

config/src/main/resources/META-INF/spring.schemas

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.2.xsd
1+
http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.3.xsd
2+
http\://www.springframework.org/schema/security/spring-security-5.3.xsd=org/springframework/security/config/spring-security-5.3.xsd
23
http\://www.springframework.org/schema/security/spring-security-5.2.xsd=org/springframework/security/config/spring-security-5.2.xsd
34
http\://www.springframework.org/schema/security/spring-security-5.1.xsd=org/springframework/security/config/spring-security-5.1.xsd
45
http\://www.springframework.org/schema/security/spring-security-5.0.xsd=org/springframework/security/config/spring-security-5.0.xsd
@@ -13,7 +14,8 @@ http\://www.springframework.org/schema/security/spring-security-2.0.xsd=org/spri
1314
http\://www.springframework.org/schema/security/spring-security-2.0.1.xsd=org/springframework/security/config/spring-security-2.0.1.xsd
1415
http\://www.springframework.org/schema/security/spring-security-2.0.2.xsd=org/springframework/security/config/spring-security-2.0.2.xsd
1516
http\://www.springframework.org/schema/security/spring-security-2.0.4.xsd=org/springframework/security/config/spring-security-2.0.4.xsd
16-
https\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.2.xsd
17+
https\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.3.xsd
18+
https\://www.springframework.org/schema/security/spring-security-5.3.xsd=org/springframework/security/config/spring-security-5.3.xsd
1719
https\://www.springframework.org/schema/security/spring-security-5.2.xsd=org/springframework/security/config/spring-security-5.2.xsd
1820
https\://www.springframework.org/schema/security/spring-security-5.1.xsd=org/springframework/security/config/spring-security-5.1.xsd
1921
https\://www.springframework.org/schema/security/spring-security-5.0.xsd=org/springframework/security/config/spring-security-5.0.xsd

0 commit comments

Comments
 (0)