BAEL-315 Clean up some code formatting on the security configurations
This commit is contained in:
parent
2777df61a9
commit
c7551758d8
@ -13,10 +13,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
|
||||
auth.inMemoryAuthentication()
|
||||
.withUser("configUser")
|
||||
.password("configPassword")
|
||||
.roles("SYSTEM");
|
||||
auth.inMemoryAuthentication().withUser("configUser").password("configPassword").roles("SYSTEM");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,6 +24,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.and()
|
||||
.httpBasic()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
.csrf()
|
||||
.disable();
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
|
||||
auth.inMemoryAuthentication()
|
||||
.withUser("discUser")
|
||||
.password("discPassword")
|
||||
.roles("SYSTEM");
|
||||
auth.inMemoryAuthentication().withUser("discUser").password("discPassword").roles("SYSTEM");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,7 +35,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.and()
|
||||
.httpBasic()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
.csrf()
|
||||
.disable();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ -59,10 +57,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.authorizeRequests()
|
||||
.antMatchers(HttpMethod.GET, "/").hasRole("ADMIN")
|
||||
.antMatchers("/info","/health").authenticated()
|
||||
.antMatchers("/eureka/js/**", "/eureka/css/**", "/eureka/images/**", "/eureka/fonts/**").authenticated()
|
||||
.anyRequest().denyAll()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
.csrf()
|
||||
.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/resource/hello/cloud").permitAll()
|
||||
.antMatchers("/static/eureka/**").hasRole("ADMIN")
|
||||
.antMatchers("/eureka/**").hasRole("ADMIN")
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
@ -33,6 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.logout().permitAll()
|
||||
.logoutSuccessUrl("/resource/hello/cloud").permitAll()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
.csrf()
|
||||
.disable();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.baeldung.spring.cloud.bootstrap.resource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
@EnableWebSecurity
|
||||
@Configuration
|
||||
@ -27,14 +25,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.authorizeRequests()
|
||||
.antMatchers("/hello/cloud").permitAll()
|
||||
.antMatchers("/hello/user").hasAnyRole("USER", "ADMIN")
|
||||
.antMatchers("/hello/admin").hasAnyRole("ADMIN")
|
||||
.antMatchers("/hello/admin").hasRole("ADMIN")
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder encoder() {
|
||||
return new BCryptPasswordEncoder(11);
|
||||
.csrf()
|
||||
.disable();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user