title: Securing Flask-Admin with Flask-HTTPAUTH
body: <p>So I have looked everywhere for this but I couldn't find an answer.</p>
  <p>I have recently integrated <a href="https://flask-admin.readthedocs.io/en/latest/" rel="nofollow noreferrer">flask-admin</a> to my flask application, which is already, partly secured using <a href="https://flask-httpauth.readthedocs.io/en/latest/" rel="nofollow noreferrer">flask-httpauth</a>'s basic authentication. I am using the @auth.verify_password decorator to verify the credentials using httpauth.</p>
  <p>I tried following the examples about how to integrate flask-basicauth with flask-admin using custom Views but I couldn't find a method that asks for the user login as the <code>basic_auth.challenge()</code>.</p>
  <p>So here's the question, how could I fill this custom admin view to integrate httpauth?</p>
  <pre><code>class MyAdminIndexView(AdminIndexView):
      def is_accessible(self):
          if not auth.current_user():
              raise AuthException('Not authenticated.')
          else:
              return True
      def inaccessible_callback(self, name, **kwargs):
          # What can I put in place of this:
          return redirect(auth.challenge())
  </code></pre>
  <p>Or else, what's the alternative?</p>