Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace g.user with current_user proxy #24

Closed
jace opened this issue May 3, 2017 · 2 comments
Closed

Replace g.user with current_user proxy #24

jace opened this issue May 3, 2017 · 2 comments

Comments

@jace
Copy link
Member

jace commented May 3, 2017

Flask-Login provides a current_user proxy that is available everywhere, including in templates.

Flask's documentation on local proxies hints at a crucial advantage: the backing function of a proxy is only called the first time the proxy is accessed.

Flask-Lastuser currently sets g.user on every request, even if the request needs no user authentication check. By switching to a proxy, the user can be authenticated only if required.

There will be no performance penalty with this switch, but:

  1. All uses of g.user across apps must be replaced, and
  2. To facilitate a transition, Flask-Lastuser must continue setting g.user in before_request until the transition is complete.
@jace
Copy link
Member Author

jace commented Nov 24, 2017

The current_user implementation has moved to hasgeek/coaster#154. This ticket can be closed as all additional detail is now covered in #29.

@jace jace closed this as completed Nov 24, 2017
@jace
Copy link
Member Author

jace commented Jan 30, 2018

Coaster's corresponding tickets (hasgeek/coaster#154 and hasgeek/coaster#155) have implemented this as a current_auth proxy. Lastuser's switch is in hasgeek/lastuser#229.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant