From ecb8461e8c684c553a82b23c99538f254e04120d Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 31 Aug 2017 16:12:02 -0700 Subject: [PATCH] Manually format security configuration Update security configuration formatting to follow conventions recommended in the Spring Security documentation. See gh-7958 --- .../customsecurity/SecurityConfiguration.java | 1 + .../actuator/ActuatorSecurityConfiguration.java | 9 ++++++--- .../method/SampleMethodSecurityApplication.java | 16 +++++++++++----- .../web/secure/SampleWebSecureApplication.java | 12 ++++++++---- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/java/sample/actuator/customsecurity/SecurityConfiguration.java b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/java/sample/actuator/customsecurity/SecurityConfiguration.java index cf734a2818..b866c098d7 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/java/sample/actuator/customsecurity/SecurityConfiguration.java +++ b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/java/sample/actuator/customsecurity/SecurityConfiguration.java @@ -24,6 +24,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { + // @formatter:off http.authorizeRequests() .requestMatchers(this.bootSecurity.endpointIds("status", "info")).permitAll() diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java index aa33d0829d..830fb3928d 100644 --- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java +++ b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java @@ -23,9 +23,12 @@ public class ActuatorSecurityConfiguration extends WebSecurityConfigurerAdapter @Override protected void configure(HttpSecurity http) throws Exception { - http.requestMatcher( - this.springBootSecurity.endpointIds(SpringBootSecurity.ALL_ENDPOINTS)) - .authorizeRequests().antMatchers("/**").authenticated().and().httpBasic(); + // @formatter:off + http.requestMatcher(this.springBootSecurity.endpointIds(SpringBootSecurity.ALL_ENDPOINTS)).authorizeRequests() + .antMatchers("/**").authenticated() + .and() + .httpBasic(); + // @formatter:on } } diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java index a6896718bc..7738061b83 100644 --- a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java @@ -84,11 +84,17 @@ public class SampleMethodSecurityApplication implements WebMvcConfigurer { @Override protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().antMatchers("/login").permitAll().anyRequest() - .fullyAuthenticated().and().formLogin().loginPage("/login") - .failureUrl("/login?error").and().logout() - .logoutRequestMatcher(new AntPathRequestMatcher("/logout")).and() - .exceptionHandling().accessDeniedPage("/access?error"); + // @formatter:off + http.authorizeRequests() + .antMatchers("/login").permitAll() + .anyRequest().fullyAuthenticated() + .and() + .formLogin().loginPage("/login").failureUrl("/login?error") + .and() + .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")) + .and() + .exceptionHandling().accessDeniedPage("/access?error"); + // @formatter:on } } diff --git a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java index ba85cc071e..11dbf9d756 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java @@ -69,11 +69,15 @@ public class SampleWebSecureApplication implements WebMvcConfigurer { @Override protected void configure(HttpSecurity http) throws Exception { + // @formatter:off http.authorizeRequests() - .requestMatchers(this.springBootSecurity.staticResources()) - .permitAll().anyRequest().fullyAuthenticated().and().formLogin() - .loginPage("/login").failureUrl("/login?error").permitAll().and() - .logout().permitAll(); + .requestMatchers(this.springBootSecurity.staticResources()).permitAll() + .anyRequest().fullyAuthenticated() + .and() + .formLogin().loginPage("/login").failureUrl("/login?error").permitAll() + .and() + .logout().permitAll(); + // @formatter:on } @Override