Add noformat blocks around auth config

Find `auth` config using a regex search of `^\s*auths*$` and protect
them against formatting.

Issue gh-8945
This commit is contained in:
Phillip Webb 2020-07-23 12:58:41 -07:00 committed by Rob Winch
parent 103d822e46
commit 63b5998fad
46 changed files with 158 additions and 64 deletions

View File

@ -74,14 +74,14 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class DefaultLdapConfig extends BaseLdapProviderConfig { static class DefaultLdapConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
.userDnPatterns("uid={0},ou=people"); .userDnPatterns("uid={0},ou=people");
// @formatter:on
} }
// @formatter:on
} }
@Test @Test
@ -94,15 +94,15 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class GroupRolesConfig extends BaseLdapProviderConfig { static class GroupRolesConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
.userDnPatterns("uid={0},ou=people") .userDnPatterns("uid={0},ou=people")
.groupRoleAttribute("group"); .groupRoleAttribute("group");
// @formatter:on
} }
// @formatter:on
} }
@Test @Test
@ -115,15 +115,15 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class GroupSearchConfig extends BaseLdapProviderConfig { static class GroupSearchConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
.userDnPatterns("uid={0},ou=people") .userDnPatterns("uid={0},ou=people")
.groupSearchFilter("ou=groupName"); .groupSearchFilter("ou=groupName");
// @formatter:on
} }
// @formatter:on
} }
@Test @Test
@ -137,16 +137,16 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig { static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
.userDnPatterns("uid={0},ou=people") .userDnPatterns("uid={0},ou=people")
.groupSearchFilter("ou=groupName") .groupSearchFilter("ou=groupName")
.groupSearchSubtree(true); .groupSearchSubtree(true);
// @formatter:on
} }
// @formatter:on
} }
@Test @Test
@ -159,15 +159,15 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class RolePrefixConfig extends BaseLdapProviderConfig { static class RolePrefixConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
.userDnPatterns("uid={0},ou=people") .userDnPatterns("uid={0},ou=people")
.rolePrefix("role_"); .rolePrefix("role_");
// @formatter:on
} }
// @formatter:on
} }
@Test @Test
@ -180,16 +180,16 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class BindAuthenticationConfig extends BaseLdapServerConfig { static class BindAuthenticationConfig extends BaseLdapServerConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})") .groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people"); .userDnPatterns("uid={0},ou=people");
// @formatter:on
} }
// @formatter:on
} }
// SEC-2472 // SEC-2472
@ -203,8 +203,8 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class PasswordEncoderConfig extends BaseLdapServerConfig { static class PasswordEncoderConfig extends BaseLdapServerConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.contextSource(contextSource()) .contextSource(contextSource())
@ -212,8 +212,8 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})") .groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people"); .userDnPatterns("uid={0},ou=people");
// @formatter:on
} }
// @formatter:on
} }
private LdapAuthenticationProvider ldapProvider() { private LdapAuthenticationProvider ldapProvider() {

View File

@ -83,8 +83,8 @@ public class LdapAuthenticationProviderConfigurerTests {
@EnableWebSecurity @EnableWebSecurity
static class MultiLdapAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter { static class MultiLdapAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
@ -95,14 +95,14 @@ public class LdapAuthenticationProviderConfigurerTests {
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})") .groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people"); .userDnPatterns("uid={0},ou=people");
// @formatter:on
} }
// @formatter:on
} }
@EnableWebSecurity @EnableWebSecurity
static class MultiLdapWithCustomRolePrefixAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter { static class MultiLdapWithCustomRolePrefixAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
@ -115,14 +115,15 @@ public class LdapAuthenticationProviderConfigurerTests {
.groupSearchFilter("(member={0})") .groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people") .userDnPatterns("uid={0},ou=people")
.rolePrefix("RUOLO_"); .rolePrefix("RUOLO_");
// @formatter:on
} }
// @formatter:on
} }
@EnableWebSecurity @EnableWebSecurity
static class LdapWithRandomPortConfig extends WebSecurityConfigurerAdapter { static class LdapWithRandomPortConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
@ -130,20 +131,21 @@ public class LdapAuthenticationProviderConfigurerTests {
.userDnPatterns("uid={0},ou=people") .userDnPatterns("uid={0},ou=people")
.contextSource() .contextSource()
.port(0); .port(0);
// @formatter:on
} }
} }
@EnableWebSecurity @EnableWebSecurity
static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig { static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})") .groupSearchFilter("(member={0})")
.groupSearchSubtree(true) .groupSearchSubtree(true)
.userDnPatterns("uid={0},ou=people"); .userDnPatterns("uid={0},ou=people");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -29,21 +29,21 @@ import org.springframework.security.ldap.userdetails.PersonContextMapper;
public class NamespaceLdapAuthenticationProviderTestsConfigs { public class NamespaceLdapAuthenticationProviderTestsConfigs {
@EnableWebSecurity @EnableWebSecurity
static class LdapAuthenticationProviderConfig extends WebSecurityConfigurerAdapter { static class LdapAuthenticationProviderConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
.userDnPatterns("uid={0},ou=people"); // ldap-server@user-dn-pattern .userDnPatterns("uid={0},ou=people"); // ldap-server@user-dn-pattern
// @formatter:on
} }
// @formatter:on
} }
@EnableWebSecurity @EnableWebSecurity
static class CustomLdapAuthenticationProviderConfig extends static class CustomLdapAuthenticationProviderConfig extends
WebSecurityConfigurerAdapter { WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupRoleAttribute("cn") // ldap-authentication-provider@group-role-attribute .groupRoleAttribute("cn") // ldap-authentication-provider@group-role-attribute
@ -63,28 +63,28 @@ public class NamespaceLdapAuthenticationProviderTestsConfigs {
.root("dc=springframework,dc=org") // ldap-server@root .root("dc=springframework,dc=org") // ldap-server@root
// .url("ldap://localhost:33389/dc-springframework,dc=org") this overrides root and port and is used for external // .url("ldap://localhost:33389/dc-springframework,dc=org") this overrides root and port and is used for external
; ;
// @formatter:on
} }
// @formatter:on
} }
@EnableWebSecurity @EnableWebSecurity
static class CustomAuthoritiesPopulatorConfig extends WebSecurityConfigurerAdapter { static class CustomAuthoritiesPopulatorConfig extends WebSecurityConfigurerAdapter {
static LdapAuthoritiesPopulator LAP; static LdapAuthoritiesPopulator LAP;
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.userSearchFilter("(uid={0})") .userSearchFilter("(uid={0})")
.ldapAuthoritiesPopulator(LAP); .ldapAuthoritiesPopulator(LAP);
// @formatter:on
} }
// @formatter:on
} }
@EnableWebSecurity @EnableWebSecurity
static class PasswordCompareLdapConfig extends WebSecurityConfigurerAdapter { static class PasswordCompareLdapConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.ldapAuthentication() .ldapAuthentication()
.groupSearchBase("ou=groups") .groupSearchBase("ou=groups")
@ -92,7 +92,7 @@ public class NamespaceLdapAuthenticationProviderTestsConfigs {
.passwordCompare() .passwordCompare()
.passwordEncoder(new BCryptPasswordEncoder()) // ldap-authentication-provider/password-compare/password-encoder@ref .passwordEncoder(new BCryptPasswordEncoder()) // ldap-authentication-provider/password-compare/password-encoder@ref
.passwordAttribute("userPassword"); // ldap-authentication-provider/password-compare@password-attribute .passwordAttribute("userPassword"); // ldap-authentication-provider/password-compare@password-attribute
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -113,9 +113,11 @@ public class AuthenticationManagerBuilderTests {
static class PasswordEncoderGlobalConfig extends WebSecurityConfigurerAdapter { static class PasswordEncoderGlobalConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
@Bean @Bean
@ -139,9 +141,11 @@ public class AuthenticationManagerBuilderTests {
@EnableWebSecurity @EnableWebSecurity
static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter { static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
@Bean @Bean

View File

@ -28,9 +28,11 @@ import org.springframework.security.config.annotation.authentication.builders.Au
public class BaseAuthenticationConfig { public class BaseAuthenticationConfig {
@Autowired @Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
} }

View File

@ -55,9 +55,11 @@ public class NamespaceAuthenticationManagerTests {
static class EraseCredentialsTrueDefaultConfig extends WebSecurityConfigurerAdapter { static class EraseCredentialsTrueDefaultConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }
@ -77,10 +79,12 @@ public class NamespaceAuthenticationManagerTests {
static class EraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter { static class EraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.eraseCredentials(false) .eraseCredentials(false)
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }
@ -97,10 +101,12 @@ public class NamespaceAuthenticationManagerTests {
static class GlobalEraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter { static class GlobalEraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.eraseCredentials(false) .eraseCredentials(false)
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }
} }

View File

@ -56,8 +56,10 @@ public class NamespaceAuthenticationProviderTests {
@EnableWebSecurity @EnableWebSecurity
static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter { static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) { protected void configure(AuthenticationManagerBuilder auth) {
// @formatter:off
auth auth
.authenticationProvider(authenticationProvider()); .authenticationProvider(authenticationProvider());
// @formatter:on
} }
@Bean @Bean
@ -80,8 +82,10 @@ public class NamespaceAuthenticationProviderTests {
@EnableWebSecurity @EnableWebSecurity
static class UserServiceRefConfig extends WebSecurityConfigurerAdapter { static class UserServiceRefConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.userDetailsService(userDetailsService()); .userDetailsService(userDetailsService());
// @formatter:on
} }
@Bean @Bean

View File

@ -63,11 +63,13 @@ public class NamespaceJdbcUserServiceTests {
private DataSource dataSource; private DataSource dataSource;
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.jdbcAuthentication() .jdbcAuthentication()
.withDefaultSchema() .withDefaultSchema()
.withUser(PasswordEncodedUser.user()) .withUser(PasswordEncodedUser.user())
.dataSource(this.dataSource); // jdbc-user-service@data-source-ref .dataSource(this.dataSource); // jdbc-user-service@data-source-ref
// @formatter:on
} }
} }
@ -94,6 +96,7 @@ public class NamespaceJdbcUserServiceTests {
private DataSource dataSource; private DataSource dataSource;
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.jdbcAuthentication() .jdbcAuthentication()
// jdbc-user-service@dataSource // jdbc-user-service@dataSource
@ -108,6 +111,7 @@ public class NamespaceJdbcUserServiceTests {
.groupAuthoritiesByUsername(JdbcUserDetailsManager.DEF_GROUP_AUTHORITIES_BY_USERNAME_QUERY) .groupAuthoritiesByUsername(JdbcUserDetailsManager.DEF_GROUP_AUTHORITIES_BY_USERNAME_QUERY)
// jdbc-user-service@role-prefix // jdbc-user-service@role-prefix
.rolePrefix("ROLE_"); .rolePrefix("ROLE_");
// @formatter:on
} }

View File

@ -61,10 +61,12 @@ public class NamespacePasswordEncoderTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password(encoder.encode("password")).roles("USER").and() .withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder); .passwordEncoder(encoder);
// @formatter:on
} }
} }
@ -82,12 +84,14 @@ public class NamespacePasswordEncoderTests {
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// @formatter:off
auth auth
.jdbcAuthentication() .jdbcAuthentication()
.withDefaultSchema() .withDefaultSchema()
.dataSource(dataSource()) .dataSource(dataSource())
.withUser("user").password(encoder.encode("password")).roles("USER").and() .withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder); .passwordEncoder(encoder);
// @formatter:on
} }
@Bean @Bean
@ -116,9 +120,11 @@ public class NamespacePasswordEncoderTests {
.roles("USER") .roles("USER")
.build(); .build();
InMemoryUserDetailsManager uds = new InMemoryUserDetailsManager(user); InMemoryUserDetailsManager uds = new InMemoryUserDetailsManager(user);
// @formatter:off
auth auth
.userDetailsService(uds) .userDetailsService(uds)
.passwordEncoder(encoder); .passwordEncoder(encoder);
// @formatter:on
} }
@Bean @Bean

View File

@ -49,15 +49,15 @@ public class PasswordEncoderConfigurerTests {
@EnableWebSecurity @EnableWebSecurity
static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter { static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = passwordEncoder(); BCryptPasswordEncoder encoder = passwordEncoder();
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password(encoder.encode("password")).roles("USER").and() .withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder); .passwordEncoder(encoder);
// @formatter:on
} }
// @formatter:on
@Override @Override
protected void configure(HttpSecurity http) { protected void configure(HttpSecurity http) {
@ -80,15 +80,15 @@ public class PasswordEncoderConfigurerTests {
@EnableWebSecurity @EnableWebSecurity
static class PasswordEncoderNoAuthManagerLoadsConfig extends static class PasswordEncoderNoAuthManagerLoadsConfig extends
WebSecurityConfigurerAdapter { WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = passwordEncoder(); BCryptPasswordEncoder encoder = passwordEncoder();
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password(encoder.encode("password")).roles("USER").and() .withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder); .passwordEncoder(encoder);
// @formatter:on
} }
// @formatter:on
@Bean @Bean
public BCryptPasswordEncoder passwordEncoder() { public BCryptPasswordEncoder passwordEncoder() {

View File

@ -241,9 +241,11 @@ public class AuthenticationConfigurationTests {
static class ConfiguresInMemoryConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter { static class ConfiguresInMemoryConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
public void init(AuthenticationManagerBuilder auth) throws Exception { public void init(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }

View File

@ -134,8 +134,10 @@ public class GlobalMethodSecurityConfigurationTests {
public static class InMemoryAuthWithGlobalMethodSecurityConfig extends GlobalMethodSecurityConfiguration { public static class InMemoryAuthWithGlobalMethodSecurityConfig extends GlobalMethodSecurityConfiguration {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:on
} }
@Bean @Bean

View File

@ -74,10 +74,12 @@ public class SampleEnableGlobalMethodSecurityTests {
@Autowired @Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
} }
@ -109,10 +111,12 @@ public class SampleEnableGlobalMethodSecurityTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
} }

View File

@ -135,9 +135,11 @@ public class SampleWebSecurityConfigurerAdapterTests {
public static class HelloWorldWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { public static class HelloWorldWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }
@ -233,10 +235,12 @@ public class SampleWebSecurityConfigurerAdapterTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()) .withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin()); .withUser(PasswordEncodedUser.admin());
// @formatter:on
} }
} }
@ -346,10 +350,12 @@ public class SampleWebSecurityConfigurerAdapterTests {
public static class SampleMultiHttpSecurityConfig { public static class SampleMultiHttpSecurityConfig {
@Autowired @Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()) .withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin()); .withUser(PasswordEncodedUser.admin());
// @formatter:on
} }
@Configuration @Configuration

View File

@ -146,9 +146,11 @@ public class WebSecurityConfigurerAdapterPowermockTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
@Override @Override

View File

@ -96,9 +96,11 @@ public class WebSecurityConfigurerAdapterTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
@Override @Override
@ -125,9 +127,11 @@ public class WebSecurityConfigurerAdapterTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
@Override @Override
@ -152,9 +156,11 @@ public class WebSecurityConfigurerAdapterTests {
static class InMemoryConfigureProtectedConfig extends WebSecurityConfigurerAdapter { static class InMemoryConfigureProtectedConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
@Override @Override
@ -180,9 +186,11 @@ public class WebSecurityConfigurerAdapterTests {
static class InMemoryConfigureGlobalConfig extends WebSecurityConfigurerAdapter { static class InMemoryConfigureGlobalConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
@Override @Override
@ -283,9 +291,11 @@ public class WebSecurityConfigurerAdapterTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }

View File

@ -75,9 +75,11 @@ public class HttpConfigurationTests {
} }
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }

View File

@ -479,9 +479,11 @@ public class NamespaceHttpTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
} }

View File

@ -79,8 +79,10 @@ public class AuthenticationPrincipalArgumentResolverTests {
static class Config { static class Config {
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:off
} }
@Bean @Bean

View File

@ -64,9 +64,11 @@ public class EnableWebSecurityTests {
static class SecurityConfig extends WebSecurityConfigurerAdapter { static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
@Bean @Bean

View File

@ -90,8 +90,10 @@ public class HttpSecurityAntMatchersTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:on
} }
} }
@ -123,8 +125,10 @@ public class HttpSecurityAntMatchersTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:on
} }
} }

View File

@ -95,8 +95,10 @@ public class HttpSecurityLogoutTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:on
} }
} }

View File

@ -77,9 +77,11 @@ public class NamespaceHttpExpressionHandlerTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN"); .withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
@Override @Override

View File

@ -147,10 +147,12 @@ public class NamespaceHttpInterceptUrlTests {
} }
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
} }

View File

@ -79,10 +79,12 @@ public class NamespaceHttpPortMappingsTests {
} }
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
} }
} }

View File

@ -78,10 +78,12 @@ public class NamespaceHttpRequestCacheTests {
} }
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()) .withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin()); .withUser(PasswordEncodedUser.admin());
// @formatter:on
} }
@Bean @Bean
@ -114,10 +116,12 @@ public class NamespaceHttpRequestCacheTests {
} }
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()) .withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin()); .withUser(PasswordEncodedUser.admin());
// @formatter:on
} }
} }

View File

@ -81,9 +81,11 @@ public class NamespaceHttpX509Tests {
public static class X509Config extends WebSecurityConfigurerAdapter { public static class X509Config extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN"); .withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
@Override @Override
@ -114,9 +116,11 @@ public class NamespaceHttpX509Tests {
static class AuthenticationDetailsSourceRefConfig extends WebSecurityConfigurerAdapter { static class AuthenticationDetailsSourceRefConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN"); .withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
@Override @Override
@ -152,9 +156,11 @@ public class NamespaceHttpX509Tests {
public static class SubjectPrincipalRegexConfig extends WebSecurityConfigurerAdapter { public static class SubjectPrincipalRegexConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN"); .withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
@Override @Override
@ -183,9 +189,11 @@ public class NamespaceHttpX509Tests {
public static class CustomPrincipalExtractorConfig extends WebSecurityConfigurerAdapter { public static class CustomPrincipalExtractorConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("rod@example.com").password("password").roles("USER", "ADMIN"); .withUser("rod@example.com").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
@Override @Override
@ -222,9 +230,11 @@ public class NamespaceHttpX509Tests {
public static class UserDetailsServiceRefConfig extends WebSecurityConfigurerAdapter { public static class UserDetailsServiceRefConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN"); .withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
@Override @Override

View File

@ -441,8 +441,10 @@ public class NamespaceRememberMeTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.userDetailsService(USERDETAILS_SERVICE); .userDetailsService(USERDETAILS_SERVICE);
// @formatter:on
} }
} }

View File

@ -113,14 +113,14 @@ public class SessionManagementConfigurerServlet31Tests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
// @formatter:on
} }
private void loadConfig(Class<?>... classes) { private void loadConfig(Class<?>... classes) {

View File

@ -71,13 +71,13 @@ public class SessionManagementConfigurerSessionAuthenticationStrategyTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser(PasswordEncodedUser.user()); .withUser(PasswordEncodedUser.user());
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -78,8 +78,10 @@ public class SessionManagementConfigurerTransientAuthenticationTests {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) { protected void configure(AuthenticationManagerBuilder auth) {
// @formatter:off
auth auth
.authenticationProvider(new TransientAuthenticationProvider()); .authenticationProvider(new TransientAuthenticationProvider());
// @formatter:on
} }
} }

View File

@ -158,9 +158,11 @@ public class GrantedAuthorityDefaultsJcTests {
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
@Override @Override

View File

@ -48,13 +48,13 @@ public class WithMockUserParentTests extends WithMockUserParent {
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackageClasses = HelloMessageService.class) @ComponentScan(basePackageClasses = HelloMessageService.class)
static class Config { static class Config {
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -77,13 +77,13 @@ public class WithMockUserTests {
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackageClasses = HelloMessageService.class) @ComponentScan(basePackageClasses = HelloMessageService.class)
static class Config { static class Config {
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -77,13 +77,13 @@ public class WithUserDetailsTests {
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackageClasses = HelloMessageService.class) @ComponentScan(basePackageClasses = HelloMessageService.class)
static class Config { static class Config {
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.userDetailsService(myUserDetailsService()); .userDetailsService(myUserDetailsService());
// @formatter:on
} }
// @formatter:on
@Bean @Bean
public UserDetailsService myUserDetailsService() { public UserDetailsService myUserDetailsService() {

View File

@ -82,13 +82,13 @@ public class SecurityMockMvcRequestPostProcessorsAuthenticationStatelessTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:on
} }
// @formatter:on
@RestController @RestController
static class Controller { static class Controller {

View File

@ -82,13 +82,13 @@ public class SecurityMockMvcRequestPostProcessorsTestSecurityContextStatelessTes
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication(); .inMemoryAuthentication();
// @formatter:on
} }
// @formatter:on
@RestController @RestController
static class Controller { static class Controller {

View File

@ -75,13 +75,13 @@ public class CsrfShowcaseTests {
protected void configure(HttpSecurity http) { protected void configure(HttpSecurity http) {
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -83,14 +83,14 @@ public class CustomCsrfShowcaseTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
@Bean @Bean
public CsrfTokenRepository repo() { public CsrfTokenRepository repo() {

View File

@ -70,13 +70,13 @@ public class DefaultCsrfShowcaseTests {
protected void configure(HttpSecurity http) { protected void configure(HttpSecurity http) {
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -97,13 +97,13 @@ public class DefaultfSecurityRequestsTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -115,14 +115,14 @@ public class SecurityRequestsTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
@Override @Override
@Bean @Bean

View File

@ -99,13 +99,13 @@ public class WithUserAuthenticationTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -99,13 +99,13 @@ public class WithUserClassLevelAuthenticationTests {
// @formatter:on // @formatter:on
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER"); .withUser("user").password("password").roles("USER");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -97,14 +97,14 @@ public class WithUserDetailsAuthenticationTests {
return super.userDetailsServiceBean(); return super.userDetailsServiceBean();
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
// @formatter:on
} }
} }

View File

@ -97,14 +97,14 @@ public class WithUserDetailsClassLevelAuthenticationTests {
return super.userDetailsServiceBean(); return super.userDetailsServiceBean();
} }
// @formatter:off
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
} }
// @formatter:on
} }
} }