mirror of
https://github.com/discourse/discourse.git
synced 2025-02-11 05:44:59 +00:00
Previously, we would build the stack of omniauth authenticators once on boot. That meant that all strategies had to be included, even if they were disabled. We then used the `before_request_phase` to ensure disabled strategies could not be used. This works well, but it means that omniauth is often doing unnecessary work running logic in disabled strategies. This commit refactors things so that we build the stack of strategies on each request. That means we only need to include the enabled strategies in the stack - disabled strategies are totally ignored. Building the stack on-demand like this does add some overhead to auth requests, but on the majority of sites that will be significantly outweighed by the fact we're now skipping logic for disabled authenticators. As well as the slight performance improvement, this new approach means that: - Broken (i.e. exception-raising) strategies cannot cause issues on a site if they're disabled - `other_phase` of disabled strategies will never appear in the backtrace of other authentication errors