Stop configuring a default user with SAML 2.0 Login

See gh-29263
pull/29975/head
Guirong Hu 3 years ago committed by Stephane Nicoll
parent b7de02d908
commit ab49acc782

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -61,7 +61,8 @@ import org.springframework.util.StringUtils;
AuthenticationManagerResolver.class }, AuthenticationManagerResolver.class },
type = { "org.springframework.security.oauth2.jwt.JwtDecoder", type = { "org.springframework.security.oauth2.jwt.JwtDecoder",
"org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector", "org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector",
"org.springframework.security.oauth2.client.registration.ClientRegistrationRepository" }) "org.springframework.security.oauth2.client.registration.ClientRegistrationRepository",
"org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository" })
public class UserDetailsServiceAutoConfiguration { public class UserDetailsServiceAutoConfiguration {
private static final String NOOP_PASSWORD_PREFIX = "{noop}"; private static final String NOOP_PASSWORD_PREFIX = "{noop}";

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,6 +46,7 @@ import org.springframework.security.oauth2.client.registration.ClientRegistratio
import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector; import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector;
import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -156,6 +157,12 @@ class UserDetailsServiceAutoConfigurationTests {
.run(((context) -> assertThat(context).doesNotHaveBean(InMemoryUserDetailsManager.class))); .run(((context) -> assertThat(context).doesNotHaveBean(InMemoryUserDetailsManager.class)));
} }
@Test
void userDetailsServiceWhenRelyingPartyRegistrationRepositoryBeanPresent() {
this.contextRunner.withUserConfiguration(TestConfigWithRelyingPartyRegistrationRepository.class)
.run(((context) -> assertThat(context).doesNotHaveBean(InMemoryUserDetailsManager.class)));
}
@Test @Test
void generatedPasswordShouldNotBePrintedIfAuthenticationManagerBuilderIsUsed(CapturedOutput output) { void generatedPasswordShouldNotBePrintedIfAuthenticationManagerBuilderIsUsed(CapturedOutput output) {
this.contextRunner.withUserConfiguration(TestConfigWithAuthenticationManagerBuilder.class) this.contextRunner.withUserConfiguration(TestConfigWithAuthenticationManagerBuilder.class)
@ -234,6 +241,17 @@ class UserDetailsServiceAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
@Import(TestSecurityConfiguration.class)
static class TestConfigWithRelyingPartyRegistrationRepository {
@Bean
RelyingPartyRegistrationRepository relyingPartyRegistrationRepository() {
return mock(RelyingPartyRegistrationRepository.class);
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@Import(TestSecurityConfiguration.class) @Import(TestSecurityConfiguration.class)
static class TestConfigWithJwtDecoder { static class TestConfigWithJwtDecoder {

Loading…
Cancel
Save