Jeff
Jeff

Reputation: 1945

Spring Cloud Zuul gateway 401 basic authentication

I'm working on a Spring Cloud Zuul gateway to put in front of my spring boot application. I use basic authorization on the applications side. When I do a call to the gateway with the proper authorization header I always get 401 Unauthorized

"status": 401,
"error": "Unauthorized",
"message": "Full authentication is required to access this resource"

But when I do the request directly towards the application it works.

Upvotes: 3

Views: 5535

Answers (1)

Jeff
Jeff

Reputation: 1945

Specifying sensitive-headers property without Authorization value in Zuul routes will forward the Authorization header towards the application. By default it has hese values: Cookie,Set-Cookie,Authorization

bootstrap.yml:

zuul:
  ignoredServices: '*'
  routes:
    application:
      path: /application/**
      serviceId: application
      sensitive-headers: Cookie,Set-Cookie

More info: https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ZuulProperties.java#L118

Upvotes: 7

Related Questions