piomin/sample-spring-microservices-advanced

Add authorization header to aggregated swagger

Closed this issue · 3 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?

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
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.

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?