grafana / django-saml2-auth

Django SAML2 Authentication Made Easy. Easily integrate with SAML2 SSO identity providers like Okta, Azure AD and others.
Other
189 stars 56 forks source link

if admin:index is undefined, DEFAULT_NEXT_URL still doesn't work #302

Closed rrauenza closed 6 months ago

rrauenza commented 6 months ago

There's a lot of these sprinkled in the code:

next_url = r.session.get('login_next_url', settings.SAML2_AUTH.get('DEFAULT_NEXT_URL', get_reverse('admin:index'))) The problem is if admin:index is not defined, the exception happens regardless of whether DEFAULT_NEXT_URL is defined.

I think this is best done as an if statement so we only trigger the exception if DEFAULT_NEXT_URL is not defined,

def _get_default_next_url(saml2_auth: dict) -> str:
    next_url =  settings.SAML2_AUTH.get('DEFAULT_NEXT_URL', None)
    if next_url is not None:
      return next_url
    return get_reverse('admin:index'))
rrauenza commented 6 months ago

Also reported in past on upstream:

https://github.com/fangli/django-saml2-auth/issues/28

rrauenza commented 6 months ago

User error.. somehow I also had the fangli version installed!