1
0
mirror of synced 2026-05-22 21:33:16 +00:00

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
@@ -74,14 +74,14 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class DefaultLdapConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
.userDnPatterns("uid={0},ou=people");
// @formatter:on
}
// @formatter:on
}
@Test
@@ -94,15 +94,15 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class GroupRolesConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
.userDnPatterns("uid={0},ou=people")
.groupRoleAttribute("group");
// @formatter:on
}
// @formatter:on
}
@Test
@@ -115,15 +115,15 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class GroupSearchConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
.userDnPatterns("uid={0},ou=people")
.groupSearchFilter("ou=groupName");
// @formatter:on
}
// @formatter:on
}
@Test
@@ -137,16 +137,16 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
.userDnPatterns("uid={0},ou=people")
.groupSearchFilter("ou=groupName")
.groupSearchSubtree(true);
// @formatter:on
}
// @formatter:on
}
@Test
@@ -159,15 +159,15 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class RolePrefixConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
.userDnPatterns("uid={0},ou=people")
.rolePrefix("role_");
// @formatter:on
}
// @formatter:on
}
@Test
@@ -180,16 +180,16 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class BindAuthenticationConfig extends BaseLdapServerConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
.groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people");
// @formatter:on
}
// @formatter:on
}
// SEC-2472
@@ -203,8 +203,8 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
@EnableWebSecurity
static class PasswordEncoderConfig extends BaseLdapServerConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.contextSource(contextSource())
@@ -212,8 +212,8 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
.groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people");
// @formatter:on
}
// @formatter:on
}
private LdapAuthenticationProvider ldapProvider() {
@@ -83,8 +83,8 @@ public class LdapAuthenticationProviderConfigurerTests {
@EnableWebSecurity
static class MultiLdapAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupSearchBase("ou=groups")
@@ -95,14 +95,14 @@ public class LdapAuthenticationProviderConfigurerTests {
.groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people");
// @formatter:on
}
// @formatter:on
}
@EnableWebSecurity
static class MultiLdapWithCustomRolePrefixAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupSearchBase("ou=groups")
@@ -115,14 +115,15 @@ public class LdapAuthenticationProviderConfigurerTests {
.groupSearchFilter("(member={0})")
.userDnPatterns("uid={0},ou=people")
.rolePrefix("RUOLO_");
// @formatter:on
}
// @formatter:on
}
@EnableWebSecurity
static class LdapWithRandomPortConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupSearchBase("ou=groups")
@@ -130,20 +131,21 @@ public class LdapAuthenticationProviderConfigurerTests {
.userDnPatterns("uid={0},ou=people")
.contextSource()
.port(0);
// @formatter:on
}
}
@EnableWebSecurity
static class GroupSubtreeSearchConfig extends BaseLdapProviderConfig {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})")
.groupSearchSubtree(true)
.userDnPatterns("uid={0},ou=people");
// @formatter:on
}
// @formatter:on
}
}
@@ -29,21 +29,21 @@ import org.springframework.security.ldap.userdetails.PersonContextMapper;
public class NamespaceLdapAuthenticationProviderTestsConfigs {
@EnableWebSecurity
static class LdapAuthenticationProviderConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupSearchBase("ou=groups")
.userDnPatterns("uid={0},ou=people"); // ldap-server@user-dn-pattern
// @formatter:on
}
// @formatter:on
}
@EnableWebSecurity
static class CustomLdapAuthenticationProviderConfig extends
WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupRoleAttribute("cn") // ldap-authentication-provider@group-role-attribute
@@ -63,28 +63,28 @@ public class NamespaceLdapAuthenticationProviderTestsConfigs {
.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
;
// @formatter:on
}
// @formatter:on
}
@EnableWebSecurity
static class CustomAuthoritiesPopulatorConfig extends WebSecurityConfigurerAdapter {
static LdapAuthoritiesPopulator LAP;
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.userSearchFilter("(uid={0})")
.ldapAuthoritiesPopulator(LAP);
// @formatter:on
}
// @formatter:on
}
@EnableWebSecurity
static class PasswordCompareLdapConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.ldapAuthentication()
.groupSearchBase("ou=groups")
@@ -92,7 +92,7 @@ public class NamespaceLdapAuthenticationProviderTestsConfigs {
.passwordCompare()
.passwordEncoder(new BCryptPasswordEncoder()) // ldap-authentication-provider/password-compare/password-encoder@ref
.passwordAttribute("userPassword"); // ldap-authentication-provider/password-compare@password-attribute
// @formatter:on
}
// @formatter:on
}
}
@@ -113,9 +113,11 @@ public class AuthenticationManagerBuilderTests {
static class PasswordEncoderGlobalConfig extends WebSecurityConfigurerAdapter {
@Autowired
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
@Bean
@@ -139,9 +141,11 @@ public class AuthenticationManagerBuilderTests {
@EnableWebSecurity
static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
@Bean
@@ -28,9 +28,11 @@ import org.springframework.security.config.annotation.authentication.builders.Au
public class BaseAuthenticationConfig {
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
}
@@ -55,9 +55,11 @@ public class NamespaceAuthenticationManagerTests {
static class EraseCredentialsTrueDefaultConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -77,10 +79,12 @@ public class NamespaceAuthenticationManagerTests {
static class EraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.eraseCredentials(false)
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -97,10 +101,12 @@ public class NamespaceAuthenticationManagerTests {
static class GlobalEraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.eraseCredentials(false)
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
}
@@ -56,8 +56,10 @@ public class NamespaceAuthenticationProviderTests {
@EnableWebSecurity
static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) {
// @formatter:off
auth
.authenticationProvider(authenticationProvider());
// @formatter:on
}
@Bean
@@ -80,8 +82,10 @@ public class NamespaceAuthenticationProviderTests {
@EnableWebSecurity
static class UserServiceRefConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.userDetailsService(userDetailsService());
// @formatter:on
}
@Bean
@@ -63,11 +63,13 @@ public class NamespaceJdbcUserServiceTests {
private DataSource dataSource;
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.jdbcAuthentication()
.withDefaultSchema()
.withUser(PasswordEncodedUser.user())
.dataSource(this.dataSource); // jdbc-user-service@data-source-ref
// @formatter:on
}
}
@@ -94,6 +96,7 @@ public class NamespaceJdbcUserServiceTests {
private DataSource dataSource;
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.jdbcAuthentication()
// jdbc-user-service@dataSource
@@ -108,6 +111,7 @@ public class NamespaceJdbcUserServiceTests {
.groupAuthoritiesByUsername(JdbcUserDetailsManager.DEF_GROUP_AUTHORITIES_BY_USERNAME_QUERY)
// jdbc-user-service@role-prefix
.rolePrefix("ROLE_");
// @formatter:on
}
@@ -61,10 +61,12 @@ public class NamespacePasswordEncoderTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder);
// @formatter:on
}
}
@@ -82,12 +84,14 @@ public class NamespacePasswordEncoderTests {
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// @formatter:off
auth
.jdbcAuthentication()
.withDefaultSchema()
.dataSource(dataSource())
.withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder);
// @formatter:on
}
@Bean
@@ -116,9 +120,11 @@ public class NamespacePasswordEncoderTests {
.roles("USER")
.build();
InMemoryUserDetailsManager uds = new InMemoryUserDetailsManager(user);
// @formatter:off
auth
.userDetailsService(uds)
.passwordEncoder(encoder);
// @formatter:on
}
@Bean
@@ -49,15 +49,15 @@ public class PasswordEncoderConfigurerTests {
@EnableWebSecurity
static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = passwordEncoder();
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder);
// @formatter:on
}
// @formatter:on
@Override
protected void configure(HttpSecurity http) {
@@ -80,15 +80,15 @@ public class PasswordEncoderConfigurerTests {
@EnableWebSecurity
static class PasswordEncoderNoAuthManagerLoadsConfig extends
WebSecurityConfigurerAdapter {
// @formatter:off
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = passwordEncoder();
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password(encoder.encode("password")).roles("USER").and()
.passwordEncoder(encoder);
// @formatter:on
}
// @formatter:on
@Bean
public BCryptPasswordEncoder passwordEncoder() {
@@ -241,9 +241,11 @@ public class AuthenticationConfigurationTests {
static class ConfiguresInMemoryConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
public void init(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -134,8 +134,10 @@ public class GlobalMethodSecurityConfigurationTests {
public static class InMemoryAuthWithGlobalMethodSecurityConfig extends GlobalMethodSecurityConfiguration {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
}
@Bean
@@ -74,10 +74,12 @@ public class SampleEnableGlobalMethodSecurityTests {
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
}
@@ -109,10 +111,12 @@ public class SampleEnableGlobalMethodSecurityTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
}
@@ -135,9 +135,11 @@ public class SampleWebSecurityConfigurerAdapterTests {
public static class HelloWorldWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -233,10 +235,12 @@ public class SampleWebSecurityConfigurerAdapterTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin());
// @formatter:on
}
}
@@ -346,10 +350,12 @@ public class SampleWebSecurityConfigurerAdapterTests {
public static class SampleMultiHttpSecurityConfig {
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin());
// @formatter:on
}
@Configuration
@@ -146,9 +146,11 @@ public class WebSecurityConfigurerAdapterPowermockTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
@Override
@@ -96,9 +96,11 @@ public class WebSecurityConfigurerAdapterTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
@Override
@@ -125,9 +127,11 @@ public class WebSecurityConfigurerAdapterTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
@Override
@@ -152,9 +156,11 @@ public class WebSecurityConfigurerAdapterTests {
static class InMemoryConfigureProtectedConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
@Override
@@ -180,9 +186,11 @@ public class WebSecurityConfigurerAdapterTests {
static class InMemoryConfigureGlobalConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
@Override
@@ -283,9 +291,11 @@ public class WebSecurityConfigurerAdapterTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -75,9 +75,11 @@ public class HttpConfigurationTests {
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -479,9 +479,11 @@ public class NamespaceHttpTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
}
@@ -79,8 +79,10 @@ public class AuthenticationPrincipalArgumentResolverTests {
static class Config {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:off
}
@Bean
@@ -64,9 +64,11 @@ public class EnableWebSecurityTests {
static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
@Bean
@@ -90,8 +90,10 @@ public class HttpSecurityAntMatchersTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
}
}
@@ -123,8 +125,10 @@ public class HttpSecurityAntMatchersTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
}
}
@@ -95,8 +95,10 @@ public class HttpSecurityLogoutTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
}
}
@@ -77,9 +77,11 @@ public class NamespaceHttpExpressionHandlerTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
}
@Override
@@ -147,10 +147,12 @@ public class NamespaceHttpInterceptUrlTests {
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
}
@@ -79,10 +79,12 @@ public class NamespaceHttpPortMappingsTests {
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
}
}
@@ -78,10 +78,12 @@ public class NamespaceHttpRequestCacheTests {
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin());
// @formatter:on
}
@Bean
@@ -114,10 +116,12 @@ public class NamespaceHttpRequestCacheTests {
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user())
.withUser(PasswordEncodedUser.admin());
// @formatter:on
}
}
@@ -81,9 +81,11 @@ public class NamespaceHttpX509Tests {
public static class X509Config extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
}
@Override
@@ -114,9 +116,11 @@ public class NamespaceHttpX509Tests {
static class AuthenticationDetailsSourceRefConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
}
@Override
@@ -152,9 +156,11 @@ public class NamespaceHttpX509Tests {
public static class SubjectPrincipalRegexConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
}
@Override
@@ -183,9 +189,11 @@ public class NamespaceHttpX509Tests {
public static class CustomPrincipalExtractorConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("rod@example.com").password("password").roles("USER", "ADMIN");
// @formatter:on
}
@Override
@@ -222,9 +230,11 @@ public class NamespaceHttpX509Tests {
public static class UserDetailsServiceRefConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("rod").password("password").roles("USER", "ADMIN");
// @formatter:on
}
@Override
@@ -441,8 +441,10 @@ public class NamespaceRememberMeTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.userDetailsService(USERDETAILS_SERVICE);
// @formatter:on
}
}
@@ -113,14 +113,14 @@ public class SessionManagementConfigurerServlet31Tests {
// @formatter:on
}
// @formatter:off
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
// @formatter:on
}
private void loadConfig(Class<?>... classes) {
@@ -71,13 +71,13 @@ public class SessionManagementConfigurerSessionAuthenticationStrategyTests {
// @formatter:on
}
// @formatter:off
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser(PasswordEncodedUser.user());
// @formatter:on
}
// @formatter:on
}
}
@@ -78,8 +78,10 @@ public class SessionManagementConfigurerTransientAuthenticationTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) {
// @formatter:off
auth
.authenticationProvider(new TransientAuthenticationProvider());
// @formatter:on
}
}
@@ -158,9 +158,11 @@ public class GrantedAuthorityDefaultsJcTests {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
@Override
@@ -48,13 +48,13 @@ public class WithMockUserParentTests extends WithMockUserParent {
@EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackageClasses = HelloMessageService.class)
static class Config {
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -77,13 +77,13 @@ public class WithMockUserTests {
@EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackageClasses = HelloMessageService.class)
static class Config {
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -77,13 +77,13 @@ public class WithUserDetailsTests {
@EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackageClasses = HelloMessageService.class)
static class Config {
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.userDetailsService(myUserDetailsService());
// @formatter:on
}
// @formatter:on
@Bean
public UserDetailsService myUserDetailsService() {
@@ -82,13 +82,13 @@ public class SecurityMockMvcRequestPostProcessorsAuthenticationStatelessTests {
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
}
// @formatter:on
@RestController
static class Controller {
@@ -82,13 +82,13 @@ public class SecurityMockMvcRequestPostProcessorsTestSecurityContextStatelessTes
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
}
// @formatter:on
@RestController
static class Controller {
@@ -75,13 +75,13 @@ public class CsrfShowcaseTests {
protected void configure(HttpSecurity http) {
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -83,14 +83,14 @@ public class CustomCsrfShowcaseTests {
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
@Bean
public CsrfTokenRepository repo() {
@@ -70,13 +70,13 @@ public class DefaultCsrfShowcaseTests {
protected void configure(HttpSecurity http) {
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -97,13 +97,13 @@ public class DefaultfSecurityRequestsTests {
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -115,14 +115,14 @@ public class SecurityRequestsTests {
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
@Override
@Bean
@@ -99,13 +99,13 @@ public class WithUserAuthenticationTests {
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -99,13 +99,13 @@ public class WithUserClassLevelAuthenticationTests {
// @formatter:on
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
// @formatter:on
}
// @formatter:on
}
}
@@ -97,14 +97,14 @@ public class WithUserDetailsAuthenticationTests {
return super.userDetailsServiceBean();
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
// @formatter:on
}
}
@@ -97,14 +97,14 @@ public class WithUserDetailsClassLevelAuthenticationTests {
return super.userDetailsServiceBean();
}
// @formatter:off
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
// @formatter:on
}
// @formatter:on
}
}