django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

Unable to find oidc_logout_redirect_url for open source deployment

Open ZeeshanDarasa opened this issue 1 year ago • 2 comments

Bug description Tried to use the authentik IdP as OIDC provider in defectdojo but couldn't find the logout redirect url environment variable or configuration anywhere. There's one for SAML but nothing for OIDC.

Steps to reproduce Steps to reproduce the behavior:

  1. Setup an OIDC provider
  2. Login with OIDC provider
  3. Logout (Keeps looping and never logs out)

Expected behavior I should be able to set an IdP session termination url to DD_OIDC_LOGOUT_REDIRECT_URL to terminate my SSO session.

Deployment method (select with an X)

  • [X] Docker Compose
  • [ ] Kubernetes
  • [ ] GoDojo

ZeeshanDarasa avatar Oct 05 '25 16:10 ZeeshanDarasa

Defect Dojo uses https://github.com/python-social-auth/social-app-django. Which env variable do you suggest we make configurable? Personally I don't have experience with OIDC and Defect Dojo.

valentijnscholten avatar Oct 05 '25 17:10 valentijnscholten

I have found a hacky, non-graceful way to handle this as even the social auth documentation lacks logout handling procedure for OIDC, it's only documented for SAML based providers, added the following block to my nginx reverse proxy conf

    # call Dojo logout, then bounce to IdP logout
    location = /logout {
        if ($args = "") {                      # only once, avoid loops
            return 307 https://dojo.internaldomain/logout?next=/sso-logout;
        }
        proxy_pass http://172.17.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
    }

    # IdP RP-initiated logout (Authentik example)
    location = /sso-logout {
        add_header Set-Cookie "sessionid=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Secure; SameSite=Lax" always;
        # optional: also clear csrftoken
        add_header Set-Cookie "csrftoken=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; SameSite=Lax" always;
        return 302 https://sso.authentik.internaldomain/application/o/dojo/end-session/?post_logout_redirect_uri=https%3A%2F%2Fdojo.internaldomain%2F&client_id=redacted;
        # If your IdP requires it, also add &id_token_hint=<last_id_token>
    }
  • First it redirects the request to /logout?next=/sso-logout; to handle any default invalidation that i may have missed.
  • Once redirected to /sso-logout it updates the session cookies to blank via a Set-Cookie header as they were not being invalidated by DD in my experience even upon receiving a legitimate logout request for some reason
  • Once cookies are updated, it terminates the session at my IdP (authentik) for this specific provider, you can update the url according to your own providers documentation

ZeeshanDarasa avatar Oct 08 '25 10:10 ZeeshanDarasa