I maintain a third party library that provides webhook callback views. I got a bug report that using Django’s LoginRequiredMiddleware (introduced in 5.1) breaks the webhooks.
Looking for some guidance on how third party packages are expected to handle LoginRequiredMiddleware:
- Yes! Go ahead and apply
login_not_requiredto any views that shouldn’t be subject to Django’s authentication (webhooks, alternative login and password reset pages, email unsubscribe links, etc.) - No! Using
login_not_requiredin third party packages could introduce unexpected security issues. Developers wanting to use LoginRequiredMiddleware should carefully think through views where it shouldn’t apply, and then use the decorator only where they’ve determined it’s appropriate. (And maybe Django should mention that in the docs.) - There’s no one good answer. Because…?
(There was some earlier discussion in Add a Setting to Exempt URLs in `LoginRequiredMiddleware` - #4 by matthiask . From that, I think the answer is “Yes.” But I’d like to be sure.)