3

I am developing a back-end and using Flask Restplus. So far the code works great and the Swagger UI looks great too. I am considering adding Basic Auth on a particular endpoint (I am planning on using a Basic Auth Decorator from a previous Flask-Restful project).

How can I make the username and password fields visible on the swagger UI as well as actually enforce it on the UI? I was poking around the restplus documentation as well as Stack Overflow and didn't really see anything.

The UI will be visible on an intranet/LAN... I don't want this endpoint to be available to everyone in the building.

m.a.d.cat
  • 195
  • 2
  • 8
  • solved with the first example from this Github issue: https://github.com/noirbizarre/flask-restplus/issues/398 – m.a.d.cat Apr 25 '19 at 20:10

1 Answers1

4

Implement below:

authorizations = {
    'Basic Auth': {
        'type': 'basic',
        'in': 'header',
        'name': 'Authorization'
    },
}

api = Namespace('User', description='user related operations',security='Bearer Auth', authorizations=authorizations)
fcdt
  • 2,371
  • 5
  • 14
  • 26