solicitação de micro-serviço inter responde com o status Proibido no aplicativo Spring Cloud

Estou investigando a arquitetura de microsserviços. Eu escolhi a estrutura da nuvem da primavera.

Meu aplicativo shema é assim:

Também tenho o servidor de descoberta eureka, mas decidi pular a imagem para simplificá-la.

O código fonte completo do exemplo que você pode encontrar no githib:https://github.com/gredwhite/spring-cloud

Explicação do problema:

olá serviço mundial:

@GetMapping("/helloWorld")
@HystrixCommand(fallbackMethod = "reliable")
public String hello() {
    return this.restTemplate.getForObject("http://hello-service/hello?name=World", String.class);
}

Olá serviço:

@GetMapping("/hello")
public String hello(@RequestParam("name") String name) throws UnknownHostException, InterruptedException {           
     return "Hello " + name + "!";
 }

Quando eu comecei ohello service e tente acessarlocalhost:8082/h/hello?name=Vasya (/h - caminho do contexto) - a solicitação ocorre com sucesso e vejoHello Vasya mensagem na resposta.Eu preciso dizer que a autenticação está desabilitada para esse serviço.

hello world service temindex.html página e quando tento acessá-lo - o fluxo de autenticação acontece com êxito e, eventualmente, este aplicativo efetua login com êxito. Então eu tento executar o método/hello dehello world service e vejo resposta:

{"timestamp":"2018-05-17T08:53:04.623+0000","status":403,"error":"Forbidden","message":"Forbidden","path":"/hw/helloWorld"}
Configuração Oauth2:

olá serviço mundial

@SpringBootApplication
@EnableEurekaClient
@RibbonClient(name = "say-hello")
@EnableAutoConfiguration
@EnableOAuth2Sso
public class HelloWorldStarter {

    public static void main(String[] args) {
        SpringApplication.run(HelloWorldStarter.class, args);
    }


    @RestController
    @EnableDiscoveryClient
    @EnableCircuitBreaker
    public static class HelloWorldController {
        @Autowired
        private RestTemplate restTemplate;
        @Autowired
        private DiscoveryClient discoveryClient;

        @GetMapping("/helloWorld")
        @HystrixCommand(fallbackMethod = "reliable")
        public String hello() {           
            return this.restTemplate.getForObject("http://hello-service/hello?name=World", String.class);
        }

        public String reliable() {
            return "Could not get response from service";
        }
    }

    @org.springframework.context.annotation.Configuration
    public static class Configuration {
        @Bean
        @LoadBalanced
        RestTemplate restTemplate() {
            return new RestTemplate();
        }
    }
}

application.yml:

spring:
  application:
    name: hello-world-service
server:
  port: 8081
  servlet:
    context-path: /hw
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka
  instance:
    preferIpAddress: true

security:
  oauth2:
    client:
      client-id: acme
      client-secret: acmesecret
      access-token-uri: http://localhost:8080/oauth/token
      user-authorization-uri: http://localhost:8080/oauth/authorize
    resource:
      user-info-uri: http://localhost:8080/me

logging:
  level:
    org.springframework.security: DEBUG
    org.springframework.web: DEBUG
QuestõesComo posso resolver este problema?Após a correção do ponto anterior, quero saber como executar uma solicitação autorizada para esse serviço. Em outras palavras, desejo ativar a autorização do oauth 2 no serviço hello e ter a possibilidade de fazer uma solicitação dohello world service

questionAnswers(1)

yourAnswerToTheQuestion