1

Working on a Flask application which will have separate classes of routes to be authenticated against: user routes and host routes(think Airbnb'esque where users and hosts differ substantially).

Creating a single verify_password callback and login_required combo is extremely straightforward, however that isn't sufficient, since some routes will need host authentication and others routes will necessitate user authentication. Essentially I will need to have one verify_password/login_required for user and one for host, but I can't seem to figure out how that would be done since it appears that the callback is global in respect to auth's scope.

Brent Hronik
  • 2,357
  • 1
  • 27
  • 43

1 Answers1

6

The way I intended that to be handled is by creating two HTTPAuth objects. Each gets its own verify_password callback, and then you can decorate each route with the decorator that is appropriate.

Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152
  • Oh, wow, yes after you say that, it is immediately obvious... for some reason I thought the auth object was a Singleton. – Brent Hronik Jul 09 '15 at 18:57