Skip to content

Commit e087fc9

Browse files
BAEL-315 - reformatting config classes
1 parent be45787 commit e087fc9

4 files changed

Lines changed: 46 additions & 50 deletions

File tree

‎spring-cloud/spring-cloud-bootstrap/config/src/main/java/com/baeldung/spring/cloud/bootstrap/config/SecurityConfig.java‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
1818

1919
@Override
2020
protected void configure(HttpSecurity http) throws Exception {
21-
http
22-
.authorizeRequests()
23-
.anyRequest().hasRole("SYSTEM")
24-
.and()
25-
.httpBasic()
26-
.and()
27-
.csrf()
28-
.disable();
21+
http.authorizeRequests()
22+
.anyRequest().hasRole("SYSTEM")
23+
.and()
24+
.httpBasic()
25+
.and()
26+
.csrf()
27+
.disable();
2928
}
3029
}

‎spring-cloud/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/SecurityConfig.java‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,20 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
2222

2323
@Override
2424
protected void configure(HttpSecurity http) throws Exception {
25-
http
26-
.sessionManagement()
27-
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
28-
.and()
29-
.requestMatchers()
30-
.antMatchers("/eureka/**")
31-
.and()
32-
.authorizeRequests()
33-
.antMatchers("/eureka/**").hasRole("SYSTEM")
34-
.anyRequest().denyAll()
35-
.and()
36-
.httpBasic()
37-
.and()
38-
.csrf()
39-
.disable();
25+
http.sessionManagement()
26+
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
27+
.and()
28+
.requestMatchers()
29+
.antMatchers("/eureka/**")
30+
.and()
31+
.authorizeRequests()
32+
.antMatchers("/eureka/**").hasRole("SYSTEM")
33+
.anyRequest().denyAll()
34+
.and()
35+
.httpBasic()
36+
.and()
37+
.csrf()
38+
.disable();
4039
}
4140

4241
@Configuration

‎spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/SecurityConfig.java‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
1414
@Autowired
1515
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
1616
auth.inMemoryAuthentication()
17-
.withUser("user").password("password").roles("USER")
18-
.and()
19-
.withUser("admin").password("admin").roles("ADMIN");
17+
.withUser("user").password("password").roles("USER")
18+
.and()
19+
.withUser("admin").password("admin").roles("ADMIN");
2020
}
2121

2222
@Override
2323
protected void configure(HttpSecurity http) throws Exception {
24-
http
25-
.authorizeRequests()
26-
.antMatchers("/resource/hello/cloud").permitAll()
27-
.antMatchers("/eureka/**").hasRole("ADMIN")
28-
.anyRequest().authenticated()
29-
.and()
30-
.formLogin()
31-
.and()
32-
.logout().permitAll()
33-
.logoutSuccessUrl("/resource/hello/cloud").permitAll()
34-
.and()
35-
.csrf()
36-
.disable();
24+
http.authorizeRequests()
25+
.antMatchers("/resource/hello/cloud").permitAll()
26+
.antMatchers("/eureka/**").hasRole("ADMIN")
27+
.anyRequest().authenticated()
28+
.and()
29+
.formLogin()
30+
.and()
31+
.logout().permitAll()
32+
.logoutSuccessUrl("/resource/hello/cloud").permitAll()
33+
.and()
34+
.csrf()
35+
.disable();
3736
}
3837
}

‎spring-cloud/spring-cloud-bootstrap/resource/src/main/java/com/baeldung/spring/cloud/bootstrap/resource/SecurityConfig.java‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ public void configureGlobal1(AuthenticationManagerBuilder auth) throws Exception
1919

2020
@Override
2121
protected void configure(HttpSecurity http) throws Exception {
22-
http
23-
.httpBasic()
24-
.disable()
25-
.authorizeRequests()
26-
.antMatchers("/hello/cloud").permitAll()
27-
.antMatchers("/hello/user").hasAnyRole("USER", "ADMIN")
28-
.antMatchers("/hello/admin").hasRole("ADMIN")
29-
.anyRequest().authenticated()
30-
.and()
31-
.csrf()
32-
.disable();
22+
http.httpBasic()
23+
.disable()
24+
.authorizeRequests()
25+
.antMatchers("/hello/cloud").permitAll()
26+
.antMatchers("/hello/user").hasAnyRole("USER", "ADMIN")
27+
.antMatchers("/hello/admin").hasRole("ADMIN")
28+
.anyRequest().authenticated()
29+
.and()
30+
.csrf()
31+
.disable();
3332
}
3433
}

0 commit comments

Comments
 (0)