zuzannast / swagger_ui_engine

Include swagger-ui as rails engine and document your API with simple JSON or YAML files.
https://zuzannast.github.io/swagger_ui_engine/
MIT License
83 stars 43 forks source link

Basic auth support #7

Closed pedelman closed 7 years ago

pedelman commented 7 years ago

It would be cool to support locking down access to the swagger doc using basic auth. This functionality is supported in other swagger ui gems as well as projects like resque web.

Here is an example implementation from another swagger gem.

https://github.com/batdevis/swagger_engine/blob/master/app/controllers/swagger_engine/application_controller.rb

Then we can configure the credentials inside an initializer as well.

# from https://github.com/batdevis/swagger_engine#basic-http-auth
SwaggerEngine.configure do |config|
  config.admin_username = ENV['ADMIN_USERNAME']
  config.admin_password = ENV['ADMIN_PASSWORD']
end

Thanks for putting this together!

zuzannast commented 7 years ago

Thanks @pedelman, I'll include this in the next version 👍