question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add provision to mention Authorization Header using `SwaggerResourcesProvider`

See original GitHub issue

What version of the library are you using? Is it the latest version?

Maven SpringFox 2.6.1

What kind of issue is this?

  • Question.
  • Bug
  • Feature Request

Question details

I’ve created a Gateway Proxy using Zuul. Gateway passes these requests to other microservices. I’ve aggregated swagger documents from all microservices on gateway proxy.

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

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

        return resources;
    }
}

Now this works but on Swagger UI there’s no way I can specify authorization header in format bearer: <token>.

How can I add provision to specify authorization header for all the requests?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dilipkrishcommented, Apr 10, 2018

The login form puts the token in the cookies that is later used to protect the swagger ui page

2reactions
dilipkrishcommented, Apr 9, 2018

It should use the credentials from the browser. Thats how jhipster does it. Take a look at that project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add an authorization header to your swagger-ui with ...
Just over a year ago I blogged a simple way to add an authorization header to your swagger-ui with Swashbuckle. Although that works,...
Read more >
Springfox Reference Documentation - GitHub Pages
For OpenAPI add the springfox-oas library dependency (for swagger 2.0 use ... This prefixes paths with the provided path mapping.
Read more >
HTTP authentication - MDN Web Docs - Mozilla
A client that wants to authenticate itself with the server can then do so by including an Authorization request header with the credentials....
Read more >
Custom Headers for Credentials - Salesforce Help
You can add custom headers to named credentials and external credentials. Custom headers are a way for a remote system to define parameters...
Read more >
Solved: 'Authorization' header is not allowed. Use 'API Ke...
Use 'API Key' authentication type in the Security tab to set this header. ... HTTP header", where the Header Name = Authorization and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found