Spring Security + Sleuth
This commit is contained in:
parent
63897863b3
commit
c2eced0d66
16 changed files with 140 additions and 2 deletions
|
|
@ -61,6 +61,10 @@
|
|||
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-sleuth</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.clientui;
|
||||
|
||||
import brave.sampler.Sampler;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients("com.clientui")
|
||||
|
|
@ -14,4 +16,9 @@ public class ClientUiApplication {
|
|||
public static void main(String[] args) {
|
||||
SpringApplication.run(ClientUiApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Sampler defaultSampler(){
|
||||
return Sampler.ALWAYS_SAMPLE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.clientui.configuration;
|
||||
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class FeignConfig {
|
||||
|
||||
@Bean
|
||||
public BasicAuthRequestInterceptor mBasicAuthRequestInterceptor(){
|
||||
return new BasicAuthRequestInterceptor("utilisateur", "mdp");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.clientui.configuration;
|
||||
|
||||
import brave.sampler.Sampler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class SleuthConfig {
|
||||
|
||||
|
||||
public Sampler defaultSampler(){
|
||||
return Sampler.ALWAYS_SAMPLE;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ import com.clientui.beans.ProductBean;
|
|||
import com.clientui.proxies.MicroserviceCommandeProxy;
|
||||
import com.clientui.proxies.MicroservicePaiementProxy;
|
||||
import com.clientui.proxies.MicroserviceProduitsProxy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
@ -33,6 +35,8 @@ public class ClientController {
|
|||
private MicroservicePaiementProxy paiementProxy;
|
||||
|
||||
|
||||
Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/*
|
||||
* Étape (1)
|
||||
* Opération qui récupère la liste des produits et on les affichent dans la page d'accueil.
|
||||
|
|
@ -42,10 +46,14 @@ public class ClientController {
|
|||
@RequestMapping("/")
|
||||
public String accueil(Model model){
|
||||
|
||||
|
||||
log.info("Envoi requête vers microservice-produits");
|
||||
|
||||
List<ProductBean> produits = ProduitsProxy.listeDesProduits();
|
||||
|
||||
model.addAttribute("produits", produits);
|
||||
|
||||
|
||||
return "Accueil";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue