mozilla / mozilla-django-oidc

A django OpenID Connect library
https://mozilla-django-oidc.readthedocs.io
Mozilla Public License 2.0
444 stars 166 forks source link

Don't call `get_settings` inside __init__ #495

Open phijma-leukeleu opened 1 year ago

phijma-leukeleu commented 1 year ago

Proposal

Move calls to get_settings outside of __init__ of the auth backend, the middleware and the authentication request view.

Why?

Because if you want to overwrite get_settings, to for example use some session data (and therefore the request object), it's impossible now. The request is not known inside the __init__ (of views, middleware and auth backends) yet. You have to do some hacks to get it working. (overwriting the __init__..)

(I ran into this when I tried to support multiple providers, where the chosen provider is in the session)