Changing config to user properties to set up security
This commit is contained in:
parent
876710fa22
commit
66b618d99d
|
@ -9,7 +9,7 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||||
@EnableConfigServer
|
@EnableConfigServer
|
||||||
@EnableEurekaClient
|
@EnableEurekaClient
|
||||||
public class ConfigApplication {
|
public class ConfigApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ConfigApplication.class, args);
|
SpringApplication.run(ConfigApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.baeldung.spring.cloud.bootstrap.config;
|
package com.baeldung.spring.cloud.bootstrap.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
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.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
@ -11,20 +9,8 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Autowired
|
@Override
|
||||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
auth.inMemoryAuthentication().withUser("configUser").password("configPassword").roles("SYSTEM");
|
http.authorizeRequests().anyRequest().hasRole("SYSTEM").and().httpBasic().and().csrf().disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
http
|
|
||||||
.authorizeRequests()
|
|
||||||
.anyRequest().hasRole("SYSTEM")
|
|
||||||
.and()
|
|
||||||
.httpBasic()
|
|
||||||
.and()
|
|
||||||
.csrf()
|
|
||||||
.disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,7 @@ spring.cloud.config.server.git.uri=file:///${user.home}/application-config
|
||||||
|
|
||||||
eureka.client.region = default
|
eureka.client.region = default
|
||||||
eureka.client.registryFetchIntervalSeconds = 5
|
eureka.client.registryFetchIntervalSeconds = 5
|
||||||
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword@localhost:8082/eureka/
|
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword@localhost:8082/eureka/
|
||||||
|
security.user.name=configUser
|
||||||
|
security.user.password=configPassword
|
||||||
|
security.user.role=SYSTEM
|
Loading…
Reference in New Issue