0

So I have looked everywhere for this but I couldn't find an answer.

I have recently integrated flask-admin to my flask application, which is already, partly secured using flask-httpauth's basic authentication. I am using the @auth.verify_password decorator to verify the credentials using httpauth.

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 basic_auth.challenge().

So here's the question, how could I fill this custom admin view to integrate httpauth?

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())

Or else, what's the alternative?

  • if you need implement security/auth function in your already apps i suggest using [flask-security-too](https://flask-security-too.readthedocs.io/en/stable/). You can secure every end point based on auth variety like [http auth, token, session](https://flask-security-too.readthedocs.io/en/stable/api.html#protecting-views) using decorator @auth_required("basic", "session", "token"). And more granularly, every endpoint can restricted [based on user roles](https://flask-security-too.readthedocs.io/en/stable/api.html#flask_security.roles_required). hopefully answer – Hiroaki Genpati Apr 16 '21 at 13:53
  • i found more simply solution check this out https://github.com/flask-admin/flask-admin/issues/1049 – Hiroaki Genpati Apr 16 '21 at 15:15
  • @HiroakiGenpati I am not using neither flask-login nor flask-security, but I think that's going to be the only solution. – Kais Ben Daamech Apr 19 '21 at 13:00

0 Answers0