sample-spring-microservices-advanced icon indicating copy to clipboard operation
sample-spring-microservices-advanced copied to clipboard

Add authorization header to aggregated swagger

Open ghsatpute opened this issue 6 years ago • 2 comments

I have created gateway proxy using Zuul. It redirects the traffic to Service1 and Service2

public class SwaggerAggregatorController implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
        List<SwaggerResource> resources= new ArrayList<>();

        SwaggerResource custSwagger = new SwaggerResource();
        custSwagger.setName("cust");
        custSwagger.setLocation("/cust/cust-service/v2/api-docs");
        custSwagger.setSwaggerVersion("2.0");
        resources.add(custSwagger);

        return resources;
    }
}

I'm getting the swagger documents as expected.

What extra I need is, ability to pass the authorization header via swagger as Authorization: bearer: <token>. This token would be verified on Gateway and if the right token then pass the request to service without the token.

What can I do to achieve this?

ghsatpute avatar Mar 28 '18 06:03 ghsatpute

Hi @ghsatpute,

I think if the gateway already checks and validate the token, you can simply accept all request from just gateway via CORS or manually checks where the request comes from.

ramazansakin avatar Sep 27 '21 06:09 ramazansakin

@ramazansakin What I was asking is some way to add an authorization header on the Swagger UI itself. It's been three years, I'm not sure whether this is feature is available now or not.

The validation part I had already implemented.

ghsatpute-freshworks avatar Sep 27 '21 06:09 ghsatpute-freshworks

still no success?

i guess another feature is missing too!

when i call an api from micro1 through swagger, the request wont go through spring cloud gateway filter!! any idea?

anissaa avatar May 26 '23 16:05 anissaa