Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security requirements not working for OAS 3.0+ #7

Open
hsgreen opened this issue Apr 19, 2019 · 3 comments
Open

Security requirements not working for OAS 3.0+ #7

hsgreen opened this issue Apr 19, 2019 · 3 comments
Assignees

Comments

@hsgreen
Copy link

hsgreen commented Apr 19, 2019

The problem is that the OAS 3.0.x specification moved the securityDefinitions member of the req.swagger.swaggerObject to req.swagger.swaggerObject.components.securitySchemas but it seems like the code in swagger-security.js was not updated to reflect this.

Just curious how this is still a lingering issue, does anyone else use security in their OAS projects?

Here is the fix to go in place of swagger-security.js:138-140

var secDef;
if (req.swagger.swaggerVersion < "2.0") {
    // Swagger pre 2.0
    secDef = req.swagger.resourceListing.authorizations[name];
} else if (req.swagger.swaggerVersion < "3.0") {
    // Swagger 2.0 up to OAS 3.0
    secDef = req.swagger.swaggerObject.securityDefinitions[name];
} else {
    // OAS 3.0+
    secDef = req.swagger.swaggerObject.components.securitySchemes[name];
}
@HugoMario
Copy link
Collaborator

thanks @hsgreen, going to address this.

@HugoMario HugoMario self-assigned this Jun 29, 2019
@ystreibel
Copy link

Hello, I need this fix! Did you plan to integrated it in a hotfix release?

@hsgreen
Copy link
Author

hsgreen commented Sep 27, 2019

It still appears to be broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants