Merge pull request #8303 from kwoyke/BAEL-19790

BAEL-19790 Update Spring Cloud Configuration article
This commit is contained in:
Josh Cummings 2019-12-07 11:15:03 -07:00 committed by GitHub
commit f95933e870
5 changed files with 30 additions and 12 deletions

View File

@ -4,9 +4,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication @SpringBootApplication
@ -22,7 +21,7 @@ public class ConfigClient {
SpringApplication.run(ConfigClient.class, args); SpringApplication.run(ConfigClient.class, args);
} }
@RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) @GetMapping(value = "/whoami/{username}", produces = MediaType.TEXT_PLAIN_VALUE)
public String whoami(@PathVariable("username") String username) { public String whoami(@PathVariable("username") String username) {
return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password); return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password);
} }

View File

@ -9,10 +9,10 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<parent> <parent>
<artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-boot-1</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-1</relativePath> <relativePath>../../parent-boot-2</relativePath>
</parent> </parent>
<modules> <modules>
@ -33,7 +33,8 @@
</dependencyManagement> </dependencyManagement>
<properties> <properties>
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version> <spring-cloud-dependencies.version>Hoxton.RELEASE</spring-cloud-dependencies.version>
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
</properties> </properties>
</project> </project>

View File

@ -0,0 +1,18 @@
package com.baeldung.spring.cloud.config.server;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.csrf()
.ignoringAntMatchers("/encrypt/**")
.ignoringAntMatchers("/decrypt/**");
super.configure(http);
}
}

View File

@ -1,9 +1,5 @@
server.port=8888 server.port=8888
spring.cloud.config.server.git.uri= spring.cloud.config.server.git.uri=
spring.cloud.config.server.git.clone-on-start=true spring.cloud.config.server.git.clone-on-start=true
security.user.name=root spring.security.user.name=root
security.user.password=s3cr3t spring.security.user.password=s3cr3t
encrypt.key-store.location=classpath:/config-server.jks
encrypt.key-store.password=my-s70r3-s3cr3t
encrypt.key-store.alias=config-server-key
encrypt.key-store.secret=my-k34-s3cr3t

View File

@ -0,0 +1,4 @@
encrypt.keyStore.location=classpath:/config-server.jks
encrypt.keyStore.password=my-s70r3-s3cr3t
encrypt.keyStore.alias=config-server-key
encrypt.keyStore.secret=my-k34-s3cr3t