From 5375c85332e5d97513af10748feddbe8dff9e0d4 Mon Sep 17 00:00:00 2001 From: Arvind Krishnakumar Date: Fri, 3 Feb 2023 00:32:45 -0600 Subject: [PATCH] fix application startup failure (505) --- .../com/okta/spring/boot/oauth/OktaOAuth2Configurer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oauth2/src/main/java/com/okta/spring/boot/oauth/OktaOAuth2Configurer.java b/oauth2/src/main/java/com/okta/spring/boot/oauth/OktaOAuth2Configurer.java index 026c55f70..be9d7be06 100644 --- a/oauth2/src/main/java/com/okta/spring/boot/oauth/OktaOAuth2Configurer.java +++ b/oauth2/src/main/java/com/okta/spring/boot/oauth/OktaOAuth2Configurer.java @@ -188,7 +188,10 @@ private void configureResourceServerForOpaqueTokenValidation(HttpSecurity http, // Spring (2.7.x+) configures JWT be default and this creates startup failure "Spring Security // only supports JWTs or Opaque Tokens, not both at the same time" when we try to configure Opaque Token mode in following line. // Therefore, we are unsetting JWT mode before attempting to configure Opaque Token mode for ROOT issuer case. - unsetJwtConfigurer(http.getConfigurer(OAuth2ResourceServerConfigurer.class)); + + if (http.getConfigurer(OAuth2ResourceServerConfigurer.class) != null) { + unsetJwtConfigurer(http.getConfigurer(OAuth2ResourceServerConfigurer.class)); + } http.oauth2ResourceServer().opaqueToken(); }