Skip to content

refactor: consolidate scattered SSO code into a dedicated dojo/sso/ package#14765

Merged
Maffooch merged 3 commits intoDefectDojo:devfrom
Maffooch:sso-clean-up
Apr 30, 2026
Merged

refactor: consolidate scattered SSO code into a dedicated dojo/sso/ package#14765
Maffooch merged 3 commits intoDefectDojo:devfrom
Maffooch:sso-clean-up

Conversation

@Maffooch
Copy link
Copy Markdown
Contributor

Description

Code cleanup. SSO-related code (OAuth2, SAML2, OIDC, REMOTE_USER auth) was
previously spread across many shared files. This PR consolidates it into a
single dedicated dojo/sso/ Python package so SSO logic lives in one place
and the surrounding shared files (dojo/urls.py, dojo/user/views.py,
dojo/settings/settings.dist.py, dojo/middleware.py,
dojo/context_processors.py, dojo/templates/dojo/login.html) only retain
small, well-defined seams that hook into dojo/sso/.

No behavior changes — settings names, env-var names, URLs, and template
output are all preserved.

Changes

Files moved into dojo/sso/:

  • dojo/pipeline.pydojo/sso/pipeline.py
  • dojo/remote_user.pydojo/sso/remote_user.py
  • dojo/settings/attribute-maps/dojo/sso/attribute_maps/

Code extracted into new modules under dojo/sso/:

  • CustomSocialAuthExceptionMiddleware from dojo/middleware.pydojo/sso/middleware.py
  • SSO context-processor keys from dojo/context_processors.pydojo/sso/context_processors.py
  • SSO env-var schema, authentication backends, social-auth pipeline, and SAML2
    configuration from dojo/settings/settings.dist.pydojo/sso/settings.py
  • Login-form auto-redirect logic from dojo/user/views.pydojo/sso/views.py
  • SSO login buttons from dojo/templates/dojo/login.htmldojo/sso/templates/dojo/sso_login_buttons.html
  • social_django and djangosaml2 URL routes → dojo/sso/urls.py

Other:

  • .dryrunsecurity.yaml updated to reference new paths
  • unittests/test_remote_user.py and unittests/test_social_auth_failure_handling.py updated for new import paths

SSO-related code (OAuth2, SAML2, OIDC, REMOTE_USER auth) was spread
across dojo/middleware.py, dojo/context_processors.py,
dojo/settings/settings.dist.py, dojo/user/views.py,
dojo/templates/dojo/login.html, dojo/pipeline.py, dojo/remote_user.py,
and dojo/settings/attribute-maps/. Move all of it into a single
dojo/sso/ package so SSO logic lives in one place.

No behavior change: settings names, URLs, and template output are
preserved.
@Maffooch Maffooch requested a review from mtesauro as a code owner April 27, 2026 22:08
@github-actions github-actions Bot added settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR unittests ui labels Apr 27, 2026
@Maffooch Maffooch added this to the 2.58.0 milestone Apr 27, 2026
@Maffooch Maffooch added the affects_pro PRs that affect Pro and need a coordinated release/merge moment. label Apr 28, 2026
Copy link
Copy Markdown
Member

@valentijnscholten valentijnscholten left a comment

Choose a reason for hiding this comment

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

Was there any (Smoke) testing done to make sure it works?

@Maffooch
Copy link
Copy Markdown
Contributor Author

Maffooch commented Apr 28, 2026

Yes, tested

  • OAuth: Google
  • OIDC: Keycloak
  • SAML: Keycloak

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

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

(assumed the merge conflict is sorted out)

# Conflicts:
#	dojo/settings/settings.dist.py
@github-actions
Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@Maffooch Maffooch merged commit 171d60b into DefectDojo:dev Apr 30, 2026
157 checks passed
@Maffooch Maffooch deleted the sso-clean-up branch April 30, 2026 04:10
Maffooch pushed a commit to devGregA/django-DefectDojo that referenced this pull request Apr 30, 2026
Pulls in 15 upstream commits including:

* dojo/sso/ consolidation (DefectDojo#14765) — SSO settings/urls/views/templates/
  remote-user moved into a self-contained package.
* dojo/notifications/ consolidation (DefectDojo#14767) — notification helper +
  templates moved into the package, with a new context_processors split.
* dojo/github/ consolidation (DefectDojo#14766) — github_issue_link package
  renamed and reshaped under dojo/github/{models,services,ui,...}.
* test_tag_inheritance.py extension (DefectDojo#14771).
* Bulk-delete findings extension hook (DefectDojo#14740).
* Planned-remediation-version column alignment fix (DefectDojo#14773).
* Dependency bumps (datatables.net, gitpython, python-gitlab, pyopenssl,
  vulners, ruff, postcss).

Conflict resolutions worth flagging:

* dojo/forms.py — kept dev's reshuffled imports (GITHUB_* models now
  re-exported via dojo.github.ui.forms; Global_Role moved to
  dojo.models). Dropped the duplicate Global_Role import; the legacy
  authorization rewrite still imports from
  dojo.authorization.models for the rest.
* dojo/settings/settings.dist.py — kept tailwind's UIPreferenceLoader
  chain and APP_DIRS=False, but added a shared
  _DOJO_EXTRA_TEMPLATE_DIRS list referenced by both TEMPLATES[0]["DIRS"]
  and the FilesystemLoader so that dojo/sso/settings.py:apply_sso_settings
  can append the SSO template dir at startup and have it resolved at
  render time.
* dojo/templates/dojo/login.html — Tailwind tree, kept the inline
  Tailwind-styled SSO buttons rather than dev's
  {% include "dojo/sso_login_buttons.html" %} (which is Bootstrap-classic
  flavored and mounted by the SSO consolidation against the classic tree
  only).
* unittests/test_remote_user.py — adopted dev's import path
  (dojo.sso.remote_user, dojo.models.Dojo_Group_Member).
* dojo/api_v2/permissions.py — added a backward-compat shim
  re-exporting from dojo.authorization.api_permissions because the
  legacy authorization consolidation deleted the old module but
  dojo/notifications/api/views.py (new from dev) still imports from the
  old path.

Verified: ruff clean on touched files; manage.py check passes;
unittests.test_authorized_users_ui + unittests.authorization +
unittests.test_user_ui_timestamps + unittests.test_rest_framework +
unittests.test_remote_user all green (1144 tests, 542 skipped).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects_pro PRs that affect Pro and need a coordinated release/merge moment. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR ui unittests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants