Git Product home page Git Product logo

feign-bug-demo's Introduction

Spring Cloud Netflix Feign Bug Demo

using @FeignClient in spring currently has one fatal issue, which is demonstrated with this repository.

how to run

You will need BASH, Java 8 SDK and docker, to run the test script. During the test, ports 8761 and 8080 have to be free to use.

To run the entire test, just

./test.sh

This script is:

  • starting an eureka server
  • starting producer service
  • running WebIntegrationTests from the consumer service
  • terminating the producer
  • stopping an removing the eureka container

experiment

We assume some foreign service, serving "foo" entities. You have to be authenticated to access this the foo resource and have a role "USER". If you have "ADMIN", you will see different data, as when "USER".

This behavior is implemented using plain spring boot with spring security in the "producer" service. Additionally it registers to an eureka instance, so some "consumer" service is able to fetch this.

So the consumer service should fetch data from consumer, automatically passing basic auth of "users he know". While this may not clearly makes sense for real world, something very similar is happening consuming OAuth2 secured resource servers with client credentials grant! So to get the data correctly, we define 2 clients, with individually set up basic auth credentials using feign client configuration.

Since the main application does not use @SpringBootApplication, but @EnableAutoConfiguration, and an exclude filter on @ComponentScan, the two different configuration do not declare the internal beans.

So the expected result of these 2 clients is: the UserFooClient retrieving at least a foo entity with value "user1", while the AdminFooClients result should contain a "admin1" foo.

To verify, which result is intended, the same test is done using plain old RestTemplate.

consequences

This issue leads towards we can't really use multiple feign clients in spring boot using the @FeignClient annotation, because as soon one client is using some authorization flow (basic, oauth2), this is applied to all other clients.

feign-bug-demo's People

Contributors

xetys avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.