Skip to content

🐛 add middleware to handle social auth provider unavailability gracefully#13523

Merged
Maffooch merged 18 commits intoDefectDojo:bugfixfrom
manuel-sommer:fix_auth_provider_500
Oct 30, 2025
Merged

🐛 add middleware to handle social auth provider unavailability gracefully#13523
Maffooch merged 18 commits intoDefectDojo:bugfixfrom
manuel-sommer:fix_auth_provider_500

Conversation

@manuel-sommer
Copy link
Copy Markdown
Contributor

@manuel-sommer manuel-sommer commented Oct 24, 2025

grafik

-->
grafik

grafik grafik

@github-actions github-actions Bot added the settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR label Oct 24, 2025
@dryrunsecurity
Copy link
Copy Markdown

dryrunsecurity Bot commented Oct 24, 2025

DryRun Security

🔴 Risk threshold exceeded.

This pull request modifies a sensitive file (dojo/middleware.py) multiple times; the scanner flags these as sensitive codepath edits and recommends configuring allowed paths/authors in .dryrunsecurity.yaml. Review and approve or restrict these changes per your sensitivity policy.

🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/middleware.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.

We've notified @mtesauro.


All finding details can be found in the DryRun Security Dashboard.

@manuel-sommer manuel-sommer changed the title 🎉 add middleware to handle social auth provider unavailability gracefully 🐛 add middleware to handle social auth provider unavailability gracefully Oct 24, 2025
@valentijnscholten
Copy link
Copy Markdown
Member

valentijnscholten commented Oct 24, 2025

Is there not a better/cleaner way to do this, for example by subclassing the social auth middleware?
It feels like a lot of extra code and configuration to handle a case which is probably not even that common.
I think name, path_prefix, check_path are not needed. The rest can be loaded straight from settings?
I also wonder if the standard login is always available as fallback.

@manuel-sommer
Copy link
Copy Markdown
Contributor Author

Is there not a better/cleaner way to do this, for example by subclassing the social auth middleware? It feels like a lot of extra code and configuration to handle a case which is probably not even that common. I think name, path_prefix, check_path are not needed. The rest can be loaded straight from settings? I also wonder if the standard login is always available as fallback.

I adapted the code. Also, the standard login is always available as fallback.

@valentijnscholten
Copy link
Copy Markdown
Member

Thanks for the efforts @manuel-sommer , but did you consider other approaches? I am not yet convinced this middleware solution is the best way to implement this. When I look at the Django Social Auth app I see some pointers around customizing the middleware and exception handling:

Could you take a look and/or convince us that the proposed solution in this PR is the best fit?

@manuel-sommer
Copy link
Copy Markdown
Contributor Author

Thanks for the efforts @manuel-sommer , but did you consider other approaches? I am not yet convinced this middleware solution is the best way to implement this. When I look at the Django Social Auth app I see some pointers around customizing the middleware and exception handling:

* https://github.com/omab/django-social-auth/blob/699571a3b6d84aa2c25ffce59daa4c7f3559a0e4/example/example/middleware.py

* https://github.com/omab/edx-platform/blob/f098633cee8b941d04e1beb1ff3b3acd5a3511e4/common/djangoapps/third_party_auth/middleware.py

* https://github.com/omab/django-social-auth/blob/699571a3b6d84aa2c25ffce59daa4c7f3559a0e4/doc/configuration.rst#exceptions-middleware

Could you take a look and/or convince us that the proposed solution in this PR is the best fit?

Thank you for the guidance here @valentijnscholten. Learned something new :-)
How about the PR now?

@valentijnscholten
Copy link
Copy Markdown
Member

Looks nice and clean @manuel-sommer :-) I don't have a way to test this. Dis you manage to test these specific types or errors? We need to make sure we don't break the SSO for the Pro clients :-)

@valentijnscholten valentijnscholten added this to the 2.52.0 milestone Oct 26, 2025
@manuel-sommer
Copy link
Copy Markdown
Contributor Author

manuel-sommer commented Oct 26, 2025

@valentijnscholten, I implemented a unittest, but don't have the chance to test all different possibilities in a real environment.

Comment thread dojo/middleware.py Outdated
Comment thread dojo/middleware.py Outdated
@manuel-sommer manuel-sommer requested a review from kiblik October 27, 2025 14:34
Copy link
Copy Markdown
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@mtesauro
Copy link
Copy Markdown
Contributor

@kiblik Are you good with this? Wanted to ask before we merged it since you had requested changes that haven't been dismissed.

@Maffooch
Copy link
Copy Markdown
Contributor

@kiblik I'm gonna go ahead and merge this one so that the changes can be used in #13572

@Maffooch Maffooch merged commit 16c749c into DefectDojo:bugfix Oct 30, 2025
149 checks passed
@manuel-sommer manuel-sommer deleted the fix_auth_provider_500 branch October 30, 2025 15:29
Maffooch pushed a commit to valentijnscholten/django-DefectDojo that referenced this pull request Feb 16, 2026
…ully (DefectDojo#13523)

* 🎉 add middleware to handle social auth provider unavailability gracefully

* -

* -

* update according to recommendation

* add unittest

* update

* update on unittest

* add integrationtest

* update unittest description

* udpate

* udpate

* fix unittest

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

Labels

settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR unittests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants