Manually format security configuration

Update security configuration formatting to follow conventions
recommended in the Spring Security documentation.

See gh-7958
This commit is contained in:
Phillip Webb 2017-08-31 16:12:02 -07:00
parent 8f79ca9e65
commit ecb8461e8c
4 changed files with 26 additions and 12 deletions

View File

@ -24,6 +24,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http.authorizeRequests() http.authorizeRequests()
.requestMatchers(this.bootSecurity.endpointIds("status", "info")).permitAll() .requestMatchers(this.bootSecurity.endpointIds("status", "info")).permitAll()

View File

@ -23,9 +23,12 @@ public class ActuatorSecurityConfiguration extends WebSecurityConfigurerAdapter
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher( // @formatter:off
this.springBootSecurity.endpointIds(SpringBootSecurity.ALL_ENDPOINTS)) http.requestMatcher(this.springBootSecurity.endpointIds(SpringBootSecurity.ALL_ENDPOINTS)).authorizeRequests()
.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic(); .antMatchers("/**").authenticated()
.and()
.httpBasic();
// @formatter:on
} }
} }

View File

@ -84,11 +84,17 @@ public class SampleMethodSecurityApplication implements WebMvcConfigurer {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/login").permitAll().anyRequest() // @formatter:off
.fullyAuthenticated().and().formLogin().loginPage("/login") http.authorizeRequests()
.failureUrl("/login?error").and().logout() .antMatchers("/login").permitAll()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).and() .anyRequest().fullyAuthenticated()
.and()
.formLogin().loginPage("/login").failureUrl("/login?error")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.and()
.exceptionHandling().accessDeniedPage("/access?error"); .exceptionHandling().accessDeniedPage("/access?error");
// @formatter:on
} }
} }

View File

@ -69,11 +69,15 @@ public class SampleWebSecureApplication implements WebMvcConfigurer {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http.authorizeRequests() http.authorizeRequests()
.requestMatchers(this.springBootSecurity.staticResources()) .requestMatchers(this.springBootSecurity.staticResources()).permitAll()
.permitAll().anyRequest().fullyAuthenticated().and().formLogin() .anyRequest().fullyAuthenticated()
.loginPage("/login").failureUrl("/login?error").permitAll().and() .and()
.formLogin().loginPage("/login").failureUrl("/login?error").permitAll()
.and()
.logout().permitAll(); .logout().permitAll();
// @formatter:on
} }
@Override @Override