Refactor auth middleware to avoid code duplication.

ref: https://codeclimate.com/github/intridea/grape/Grape::Middleware::Auth::Basic