Annotation Interface EnableGlobalAuthentication
@Retention(RUNTIME)
@Target(TYPE)
@Documented
@Import(AuthenticationConfiguration.class)
@Configuration
public @interface EnableGlobalAuthentication
The
EnableGlobalAuthentication
annotation signals that the annotated class can
be used to configure a global instance of AuthenticationManagerBuilder
. For
example:
@Configuration @EnableGlobalAuthentication public class MyGlobalAuthenticationConfiguration { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) { auth.inMemoryAuthentication().withUser("user").password("password").roles("USER") .and().withUser("admin").password("password").roles("USER", "ADMIN"); } }Annotations that are annotated with
EnableGlobalAuthentication
also signal that
the annotated class can be used to configure a global instance of
AuthenticationManagerBuilder
. For example:
@Configuration @EnableWebSecurity public class MyWebSecurityConfiguration extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) { auth.inMemoryAuthentication().withUser("user").password("password").roles("USER") .and().withUser("admin").password("password").roles("USER", "ADMIN"); } // Possibly overridden methods ... }The following annotations are annotated with
EnableGlobalAuthentication
Configuring AuthenticationManagerBuilder
in a class without the
EnableGlobalAuthentication
annotation has unpredictable results.