I have build a swagger doc, generated the swagger client (python-flask with python2 support).
I've built my code up, tested, happy with what I've got. Now I want to secure my API endpoints using https and Basic Auth.
This is v2 of the Open Api Specification (OAS) so I'm setting up as follows (described https://swagger.io/docs/specification/2-0/authentication/basic-authentication/)
swagger: "2.0"
securityDefinitions:
basicAuth:
type: "basic"
Whether I specify that my endpoint have individual security settings or whether I specify this at the root level in the YAML for all endpoints, it makes no difference.
security:
- basicAuth: []
I take my YAML, export to JSON, then run the following to rebuild the swagger_server code:
java -jar swagger-codegen-cli-2.3.1.jar generate -l python-flask -
DsupportPython2=true -i swagger.json -a "Authorization: Basic
Base64encodedstring"
What I'm expecting is for the controller or model code to validate that a basic auth header has been passed that matches the authrization specified in the generation code but I see no references anywhere. Not sure if I've just read this wrong or if there's an issue with the way I'm doing it or some of the options I'm using?
-a/--authargument is the authorization header used to access the Swagger JSON/YAML file. It's not the auth for the generated server/client. - Helen