Skip to content

Commit 5a03056

Browse files
committed
Order highest precedence for OAuth2AuthorizationServerSecurity
Closes gh-103
1 parent 72ec263 commit 5a03056

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configuration/OAuth2AuthorizationServerSecurity.java

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.security.config.annotation.web.configuration;
1717

18+
import org.springframework.core.Ordered;
19+
import org.springframework.core.annotation.Order;
1820
import org.springframework.http.HttpMethod;
1921
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
2022
import org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer;
@@ -31,6 +33,7 @@
3133
* @author Joe Grandja
3234
* @since 0.0.1
3335
*/
36+
@Order(Ordered.HIGHEST_PRECEDENCE)
3437
public class OAuth2AuthorizationServerSecurity extends WebSecurityConfigurerAdapter {
3538

3639
// @formatter:off
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2020 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.annotation.web.configuration;
17+
18+
import org.junit.Test;
19+
import org.springframework.core.Ordered;
20+
import org.springframework.core.annotation.OrderUtils;
21+
22+
import static org.assertj.core.api.Assertions.assertThat;
23+
24+
/**
25+
* Tests for {@link OAuth2AuthorizationServerSecurity}.
26+
*
27+
* @author Joe Grandja
28+
*/
29+
public class OAuth2AuthorizationServerSecurityTests {
30+
31+
@Test
32+
public void assertOrderHighestPrecedence() {
33+
Integer authorizationServerSecurityOrder = OrderUtils.getOrder(OAuth2AuthorizationServerSecurity.class);
34+
Integer defaultSecurityOrder = OrderUtils.getOrder(WebSecurityConfigurerAdapter.class);
35+
assertThat(authorizationServerSecurityOrder).isNotEqualTo(defaultSecurityOrder);
36+
assertThat(authorizationServerSecurityOrder).isEqualTo(Ordered.HIGHEST_PRECEDENCE);
37+
}
38+
39+
}

0 commit comments

Comments
 (0)