Skip to content

Remove Configuration meta-annotation from Enable* annotations #11653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
import org.springframework.security.authentication.AuthenticationManager;
Expand Down Expand Up @@ -155,6 +156,7 @@ static int getPort() throws IOException {
return port;
}

@Configuration
@EnableWebSecurity
static class DefaultLdapConfig extends BaseLdapProviderConfig {

Expand All @@ -170,6 +172,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class GroupRolesConfig extends BaseLdapProviderConfig {

Expand Down Expand Up @@ -202,6 +205,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig {

Expand All @@ -219,6 +223,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class RolePrefixConfig extends BaseLdapProviderConfig {

Expand All @@ -235,6 +240,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class BindAuthenticationConfig extends BaseLdapServerConfig {

Expand All @@ -252,6 +258,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class PasswordEncoderConfig extends BaseLdapServerConfig {

Expand All @@ -270,6 +277,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
abstract static class BaseLdapServerConfig extends BaseLdapProviderConfig {

Expand All @@ -283,6 +291,7 @@ ApacheDSContainer ldapServer() throws Exception {

}

@Configuration
@EnableWebSecurity
@EnableGlobalAuthentication
@Import(ObjectPostProcessorConfiguration.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.ldap.LdapAuthenticationProviderBuilderSecurityBuilderTests.BaseLdapProviderConfig;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand Down Expand Up @@ -114,6 +115,7 @@ public void authenticationManagerWhenSearchSubtreeThenNestedGroupFound() throws
this.mockMvc.perform(request).andExpect(expectedUser);
}

@Configuration
@EnableWebSecurity
static class MultiLdapAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {

Expand All @@ -135,6 +137,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class MultiLdapWithCustomRolePrefixAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {

Expand All @@ -158,6 +161,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class LdapWithRandomPortConfig extends WebSecurityConfigurerAdapter {

Expand All @@ -176,6 +180,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.security.config.annotation.authentication.ldap;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
Expand All @@ -29,6 +30,7 @@
*/
public class NamespaceLdapAuthenticationProviderTestsConfigs {

@Configuration
@EnableWebSecurity
static class LdapAuthenticationProviderConfig extends WebSecurityConfigurerAdapter {

Expand All @@ -44,6 +46,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class CustomLdapAuthenticationProviderConfig extends WebSecurityConfigurerAdapter {

Expand Down Expand Up @@ -73,6 +76,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class CustomAuthoritiesPopulatorConfig extends WebSecurityConfigurerAdapter {

Expand All @@ -90,6 +94,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {

}

@Configuration
@EnableWebSecurity
static class PasswordCompareLdapConfig extends WebSecurityConfigurerAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.beans.factory.UnsatisfiedDependencyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void contextSourceFactoryBeanWhenManagerDnAndNoPasswordThenException() {
.withMessageContaining("managerPassword is required if managerDn is supplied");
}

@Configuration
@EnableWebSecurity
static class FromEmbeddedLdapServerConfig {

Expand All @@ -98,6 +100,7 @@ AuthenticationManager authenticationManager(LdapContextSource contextSource) {

}

@Configuration
@EnableWebSecurity
static class PortZeroConfig {

Expand All @@ -118,6 +121,7 @@ AuthenticationManager authenticationManager(LdapContextSource contextSource) {

}

@Configuration
@EnableWebSecurity
static class CustomLdifAndRootConfig {

Expand All @@ -139,6 +143,7 @@ AuthenticationManager authenticationManager(LdapContextSource contextSource) {

}

@Configuration
@EnableWebSecurity
static class CustomManagerDnConfig {

Expand All @@ -161,6 +166,7 @@ AuthenticationManager authenticationManager(LdapContextSource contextSource) {

}

@Configuration
@EnableWebSecurity
static class CustomManagerDnNoPasswordConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
Expand Down Expand Up @@ -131,6 +132,7 @@ public void authenticationManagerFactoryWhenCustomUserSearchThenUsed() throws Ex
.andExpect(authenticated().withUsername("bob"));
}

@Configuration
@EnableWebSecurity
static class FromContextSourceConfig extends BaseLdapServerConfig {

Expand All @@ -143,6 +145,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
static class CustomAuthoritiesMapperConfig extends BaseLdapServerConfig {

Expand All @@ -158,6 +161,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
static class CustomAuthoritiesPopulatorConfig extends BaseLdapServerConfig {

Expand All @@ -173,6 +177,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
static class CustomUserDetailsContextMapperConfig extends BaseLdapServerConfig {

Expand All @@ -188,6 +193,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
static class CustomUserDnPatternsConfig extends BaseLdapServerConfig {

Expand All @@ -200,6 +206,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
static class CustomUserSearchConfig extends BaseLdapServerConfig {

Expand All @@ -213,6 +220,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
abstract static class BaseLdapServerConfig implements DisposableBean {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand Down Expand Up @@ -59,6 +60,7 @@ public void authenticationManagerFactoryWhenCustomPasswordAttributeThenUsed() th
this.mockMvc.perform(formLogin().user("bob").password("bob")).andExpect(authenticated().withUsername("bob"));
}

@Configuration
@EnableWebSecurity
static class CustomPasswordEncoderConfig extends BaseLdapServerConfig {

Expand All @@ -72,6 +74,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
static class CustomPasswordAttributeConfig extends BaseLdapServerConfig {

Expand All @@ -86,6 +89,7 @@ AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSou

}

@Configuration
@EnableWebSecurity
abstract static class BaseLdapServerConfig implements DisposableBean {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
Expand Down Expand Up @@ -106,7 +105,6 @@
@Target(ElementType.TYPE)
@Documented
@Import(AuthenticationConfiguration.class)
@Configuration
public @interface EnableGlobalAuthentication {

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.lang.annotation.Target;

import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;
import org.springframework.security.access.annotation.Secured;
Expand All @@ -49,7 +48,6 @@
@Documented
@Import({ GlobalMethodSecuritySelector.class })
@EnableGlobalAuthentication
@Configuration
public @interface EnableGlobalMethodSecurity {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.lang.annotation.Target;

import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
Expand All @@ -41,7 +40,6 @@
@Target(ElementType.TYPE)
@Documented
@Import(MethodSecuritySelector.class)
@Configuration
public @interface EnableMethodSecurity {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.lang.annotation.Target;

import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;

Expand All @@ -36,7 +35,6 @@
@Target(ElementType.TYPE)
@Documented
@Import(ReactiveMethodSecuritySelector.class)
@Configuration
public @interface EnableReactiveMethodSecurity {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.annotation.authentication.configuration.EnableGlobalAuthentication;
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
Expand Down Expand Up @@ -86,7 +85,6 @@
@Import({ WebSecurityConfiguration.class, SpringWebMvcImportSelector.class, OAuth2ImportSelector.class,
HttpSecurityConfiguration.class })
@EnableGlobalAuthentication
@Configuration
public @interface EnableWebSecurity {

/**
Expand Down
Loading