|
@@ -14,7 +14,7 @@
|
|
|
* limitations under the License.
|
|
* limitations under the License.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-package org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers;
|
|
|
|
|
|
|
+package org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
@@ -55,6 +55,9 @@ import org.springframework.security.authentication.AuthenticationProvider;
|
|
|
import org.springframework.security.authentication.TestingAuthenticationToken;
|
|
import org.springframework.security.authentication.TestingAuthenticationToken;
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
|
|
|
+import org.springframework.security.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration;
|
|
|
|
|
+import org.springframework.security.config.test.SpringTestContext;
|
|
|
|
|
+import org.springframework.security.config.test.SpringTestContextExtension;
|
|
|
import org.springframework.security.core.Authentication;
|
|
import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
|
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
|
@@ -90,12 +93,9 @@ import org.springframework.security.oauth2.server.authorization.client.JdbcRegis
|
|
|
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
|
|
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
|
|
|
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
|
|
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
|
|
|
import org.springframework.security.oauth2.server.authorization.client.TestRegisteredClients;
|
|
import org.springframework.security.oauth2.server.authorization.client.TestRegisteredClients;
|
|
|
-import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration;
|
|
|
|
|
import org.springframework.security.oauth2.server.authorization.jackson2.TestingAuthenticationTokenMixin;
|
|
import org.springframework.security.oauth2.server.authorization.jackson2.TestingAuthenticationTokenMixin;
|
|
|
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
|
|
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
|
|
|
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
|
|
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
|
|
|
-import org.springframework.security.oauth2.server.authorization.test.SpringTestContext;
|
|
|
|
|
-import org.springframework.security.oauth2.server.authorization.test.SpringTestContextExtension;
|
|
|
|
|
import org.springframework.security.oauth2.server.authorization.token.JwtEncodingContext;
|
|
import org.springframework.security.oauth2.server.authorization.token.JwtEncodingContext;
|
|
|
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer;
|
|
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer;
|
|
|
import org.springframework.security.oauth2.server.authorization.util.TestX509Certificates;
|
|
import org.springframework.security.oauth2.server.authorization.util.TestX509Certificates;
|
|
@@ -109,6 +109,7 @@ import org.springframework.security.oauth2.server.authorization.web.authenticati
|
|
|
import org.springframework.security.oauth2.server.authorization.web.authentication.OAuth2TokenExchangeAuthenticationConverter;
|
|
import org.springframework.security.oauth2.server.authorization.web.authentication.OAuth2TokenExchangeAuthenticationConverter;
|
|
|
import org.springframework.security.oauth2.server.authorization.web.authentication.PublicClientAuthenticationConverter;
|
|
import org.springframework.security.oauth2.server.authorization.web.authentication.PublicClientAuthenticationConverter;
|
|
|
import org.springframework.security.oauth2.server.authorization.web.authentication.X509ClientCertificateAuthenticationConverter;
|
|
import org.springframework.security.oauth2.server.authorization.web.authentication.X509ClientCertificateAuthenticationConverter;
|
|
|
|
|
+import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors;
|
|
|
import org.springframework.security.web.SecurityFilterChain;
|
|
import org.springframework.security.web.SecurityFilterChain;
|
|
|
import org.springframework.security.web.authentication.AuthenticationConverter;
|
|
import org.springframework.security.web.authentication.AuthenticationConverter;
|
|
|
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
|
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
|
@@ -124,7 +125,6 @@ import static org.mockito.Mockito.mock;
|
|
|
import static org.mockito.Mockito.reset;
|
|
import static org.mockito.Mockito.reset;
|
|
|
import static org.mockito.Mockito.spy;
|
|
import static org.mockito.Mockito.spy;
|
|
|
import static org.mockito.Mockito.verify;
|
|
import static org.mockito.Mockito.verify;
|
|
|
-import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.x509;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
@@ -160,7 +160,7 @@ public class OAuth2ClientCredentialsGrantTests {
|
|
|
|
|
|
|
|
private static AuthenticationFailureHandler authenticationFailureHandler;
|
|
private static AuthenticationFailureHandler authenticationFailureHandler;
|
|
|
|
|
|
|
|
- public final SpringTestContext spring = new SpringTestContext();
|
|
|
|
|
|
|
+ public final SpringTestContext spring = new SpringTestContext(this);
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MockMvc mvc;
|
|
private MockMvc mvc;
|
|
@@ -311,7 +311,8 @@ public class OAuth2ClientCredentialsGrantTests {
|
|
|
this.registeredClientRepository.save(registeredClient);
|
|
this.registeredClientRepository.save(registeredClient);
|
|
|
|
|
|
|
|
this.mvc
|
|
this.mvc
|
|
|
- .perform(post(DEFAULT_TOKEN_ENDPOINT_URI).with(x509(TestX509Certificates.DEMO_CLIENT_PKI_CERTIFICATE))
|
|
|
|
|
|
|
+ .perform(post(DEFAULT_TOKEN_ENDPOINT_URI)
|
|
|
|
|
+ .with(SecurityMockMvcRequestPostProcessors.x509(TestX509Certificates.DEMO_CLIENT_PKI_CERTIFICATE))
|
|
|
.param(OAuth2ParameterNames.CLIENT_ID, registeredClient.getClientId())
|
|
.param(OAuth2ParameterNames.CLIENT_ID, registeredClient.getClientId())
|
|
|
.param(OAuth2ParameterNames.GRANT_TYPE, AuthorizationGrantType.CLIENT_CREDENTIALS.getValue())
|
|
.param(OAuth2ParameterNames.GRANT_TYPE, AuthorizationGrantType.CLIENT_CREDENTIALS.getValue())
|
|
|
.param(OAuth2ParameterNames.SCOPE, "scope1 scope2"))
|
|
.param(OAuth2ParameterNames.SCOPE, "scope1 scope2"))
|
|
@@ -332,7 +333,8 @@ public class OAuth2ClientCredentialsGrantTests {
|
|
|
this.registeredClientRepository.save(registeredClient);
|
|
this.registeredClientRepository.save(registeredClient);
|
|
|
|
|
|
|
|
this.mvc
|
|
this.mvc
|
|
|
- .perform(post(DEFAULT_TOKEN_ENDPOINT_URI).with(x509(TestX509Certificates.DEMO_CLIENT_PKI_CERTIFICATE))
|
|
|
|
|
|
|
+ .perform(post(DEFAULT_TOKEN_ENDPOINT_URI)
|
|
|
|
|
+ .with(SecurityMockMvcRequestPostProcessors.x509(TestX509Certificates.DEMO_CLIENT_PKI_CERTIFICATE))
|
|
|
.param(OAuth2ParameterNames.GRANT_TYPE, AuthorizationGrantType.CLIENT_CREDENTIALS.getValue())
|
|
.param(OAuth2ParameterNames.GRANT_TYPE, AuthorizationGrantType.CLIENT_CREDENTIALS.getValue())
|
|
|
.param(OAuth2ParameterNames.SCOPE, "scope1 scope2")
|
|
.param(OAuth2ParameterNames.SCOPE, "scope1 scope2")
|
|
|
.header(HttpHeaders.AUTHORIZATION,
|
|
.header(HttpHeaders.AUTHORIZATION,
|