grafana/django-saml2-auth

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

Closed this issue · 2 comments

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'))

Also reported in past on upstream:

fangli/django-saml2-auth#28

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