apigee-127 / swagger-tools

A Node.js and browser module that provides tooling around Swagger.
MIT License
701 stars 373 forks source link

handling middleware on on multiple optional security options #591

Open iamakimmer opened 5 years ago

iamakimmer commented 5 years ago

I have configured my swagger to optionally taken in a api key or jwt key:

security:

and my middleware to


  app.use(middleware.swaggerSecurity({
    JWTPublicKeyHeader: function(req, def, scopes, callback) {
           //logic 
    }, 
    APIKeyHeader: function(req, def, scopes, callback) {
         //logic 
    }
  }));

If i have a request and I'm only sending a JWTPublicKeyHeader, it still goes through the APIKeyHeader middleware in which no keys exist and will fail. How do I ignore this middleware from being called as I'm only sending 1 key?

8enmann commented 5 years ago

I have the same problem