|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2002-2020 the original author or authors.
|
|
|
+ * Copyright 2002-2021 the original author or authors.
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
* you may not use this file except in compliance with the License.
|
|
@@ -131,6 +131,11 @@ public class OAuth2LoginTests {
|
|
|
private static ClientRegistration google = CommonOAuth2Provider.GOOGLE.getBuilder("google").clientId("client")
|
|
|
.clientSecret("secret").build();
|
|
|
|
|
|
+ // @formatter:off
|
|
|
+ private static ClientRegistration clientCredentials = TestClientRegistrations.clientCredentials()
|
|
|
+ .build();
|
|
|
+ // @formatter:on
|
|
|
+
|
|
|
@Autowired
|
|
|
public void setApplicationContext(ApplicationContext context) {
|
|
|
if (context.getBeanNamesForType(WebHandler.class).length > 0) {
|
|
@@ -176,6 +181,22 @@ public class OAuth2LoginTests {
|
|
|
assertThat(driver.getCurrentUrl()).startsWith("https://github.com/login/oauth/authorize");
|
|
|
}
|
|
|
|
|
|
+ // gh-9457
|
|
|
+ @Test
|
|
|
+ public void defaultLoginPageWithAuthorizationCodeAndClientCredentialsClientRegistrationThenRedirect() {
|
|
|
+ this.spring.register(OAuth2LoginWithAuthorizationCodeAndClientCredentialsClientRegistration.class).autowire();
|
|
|
+ // @formatter:off
|
|
|
+ WebTestClient webTestClient = WebTestClientBuilder
|
|
|
+ .bindToWebFilters(new GitHubWebFilter(), this.springSecurity)
|
|
|
+ .build();
|
|
|
+ WebDriver driver = WebTestClientHtmlUnitDriverBuilder
|
|
|
+ .webTestClientSetup(webTestClient)
|
|
|
+ .build();
|
|
|
+ // @formatter:on
|
|
|
+ driver.get("http://localhost/");
|
|
|
+ assertThat(driver.getCurrentUrl()).startsWith("https://github.com/login/oauth/authorize");
|
|
|
+ }
|
|
|
+
|
|
|
// gh-8118
|
|
|
@Test
|
|
|
public void defaultLoginPageWithSingleClientRegistrationAndXhrRequestThenDoesNotRedirectForAuthorization() {
|
|
@@ -543,6 +564,16 @@ public class OAuth2LoginTests {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @EnableWebFluxSecurity
|
|
|
+ static class OAuth2LoginWithAuthorizationCodeAndClientCredentialsClientRegistration {
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ InMemoryReactiveClientRegistrationRepository clientRegistrationRepository() {
|
|
|
+ return new InMemoryReactiveClientRegistrationRepository(github, clientCredentials);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@EnableWebFlux
|
|
|
static class OAuth2AuthorizeWithMockObjectsConfig {
|
|
|
|