Skip to content

Remove dependency on before_first_request #500

Closed

Description

@fluffy-critter

Flask's before_first_request function is going away. Publ currently uses it to bootstrap Authl's configuration at startup time in a user-friendly way; Authl's configuration requires that the Flask app be fully-formed (so that the secret_key property is available) but that it not yet be serving up any requests (so that authl.flask can add the _login and _logout routes).

There are three paths forward, both fraught with peril:

  1. Add a finalize_setup method to the Publ application object that runs the previous before_first_request functionality
  2. Refactor Publ to once again be a library that spawns a standalone Flask app rather than inheriting from it
  3. Have Publ roll its own Authl routes, rather than using authl.flask

Option 2 is the best long-term one, but that was the original design to Publ, and I changed it to be inheritance-based rather than compositional for some reason that I can't recall (probably something to address issues with startup order and PonyORM's global state, but who even knows anymore).

Option 1 is definitely the easiest to do, though, and could probably be done as an expedient option in advance of Flask 2.3.

Activity

  1. added
    code qualityPlaces where the code quality or readability can be improved
    performanceIssues pertaining to performance (both CPU and RAM)
    largeThis is going to take a lot longer than most things
    on Nov 24, 2022
  2. added
    securityCritical issues regarding the security of Publ and the server it runs on
    on May 2, 2023
  3. fluffy-critter commented on May 2, 2023

    @fluffy-critter
    CollaboratorAuthor

    Now that Flask 2.3 is a required update this should be done ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code qualityPlaces where the code quality or readability can be improvedlargeThis is going to take a lot longer than most thingsperformanceIssues pertaining to performance (both CPU and RAM)securityCritical issues regarding the security of Publ and the server it runs on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions