dhiraj singh
dhiraj singh

Reputation: 101

zuul API Gateway Filter

I am facing problem when i trying to access another REST API(registered in ZUUL route) from zuul pre-filter, the call is becoming recursive i.e its running my pre-filter code again and again. My Usecase is as follows-

  1. In Zuul PreFilter run() method, I am validating the token passed in the header.

  2. After validating the token, I am calling one rest service(User Location Service) to fetch the user details. My User Location Service is itself registered in ZUUL as below:

    user-location-service:
      path: /userLocationService/**
      url: http://localhost:9002
    

The problem is that the JWT token validation code is running again and again, Can you please suggest some solution where I can apply the call Userlocation service so that the PreFilter code would not run again and again?

Upvotes: 2

Views: 1197

Answers (2)

wthamira
wthamira

Reputation: 2250

you need to allow sensitiveHeaders.

     zuul:
        routes:
            resource:
                path: /resource/**
                url: http://localhost:8002/
                sensitiveHeaders: Cookie,Set-Cookie

Upvotes: 1

Rafael Manzoni
Rafael Manzoni

Reputation: 617

Your User Location Service is registred in Zuul. So, all the times your filter is going to be executed when you got caugth in an infinite loop.

There are two approaches here:

  • Do not pass again to the gateway and call direct User Location Service
  • OR, Create a filter rule in your ZUll Authentication Filter to not consider the User Location Service. You can use the URL Path Context to exclude this route to be executed

Upvotes: 2

Related Questions