Skip to content

Commit df3080b

Browse files
committed
Merge branch '6.5.x'
2 parents a5c38bd + 518ae27 commit df3080b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurer.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher;
6767
import org.springframework.security.web.util.matcher.RequestMatcher;
6868
import org.springframework.util.Assert;
69+
import org.springframework.util.ClassUtils;
6970
import org.springframework.web.accept.ContentNegotiationStrategy;
7071
import org.springframework.web.accept.HeaderContentNegotiationStrategy;
7172

@@ -149,13 +150,19 @@
149150
public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<H>>
150151
extends AbstractHttpConfigurer<OAuth2ResourceServerConfigurer<H>, H> {
151152

153+
private static final boolean dPoPAuthenticationAvailable;
154+
155+
static {
156+
ClassLoader classLoader = OAuth2ResourceServerConfigurer.class.getClassLoader();
157+
dPoPAuthenticationAvailable = ClassUtils
158+
.isPresent("org.springframework.security.oauth2.jwt.DPoPProofJwtDecoderFactory", classLoader);
159+
}
160+
152161
private static final RequestHeaderRequestMatcher X_REQUESTED_WITH = new RequestHeaderRequestMatcher(
153162
"X-Requested-With", "XMLHttpRequest");
154163

155164
private final ApplicationContext context;
156165

157-
private final DPoPAuthenticationConfigurer<H> dPoPAuthenticationConfigurer = new DPoPAuthenticationConfigurer<>();
158-
159166
private AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver;
160167

161168
private AuthenticationConverter authenticationConverter;
@@ -269,7 +276,10 @@ public void configure(H http) {
269276
filter.setSecurityContextHolderStrategy(getSecurityContextHolderStrategy());
270277
filter = postProcess(filter);
271278
http.addFilter(filter);
272-
this.dPoPAuthenticationConfigurer.configure(http);
279+
if (dPoPAuthenticationAvailable) {
280+
DPoPAuthenticationConfigurer<H> dPoPAuthenticationConfigurer = new DPoPAuthenticationConfigurer<>();
281+
dPoPAuthenticationConfigurer.configure(http);
282+
}
273283
}
274284

275285
private void validateConfiguration() {

0 commit comments

Comments
 (0)