Skip to content

Commit

Permalink
Make login URL customizable
Browse files Browse the repository at this point in the history
Load LOGIN_URL from settings and use that. Kerberos auth is no longer
hardcoded, but it is still the default settings value.
  • Loading branch information
lubomir committed Sep 30, 2015
1 parent 12dca0e commit 38d227e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions pdc/apps/utils/templatetags/pdctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
# http://opensource.org/licenses/MIT
#
from django import template
from django.conf import settings

from pdc import get_version


def pdc_version():
return get_version()


def login_url(redirect=None):
"""Create login url based on settings.
Optionally, append redirection URL.
"""
url = settings.LOGIN_URL
redirect = redirect or settings.LOGIN_REDIRECT_URL
if redirect:
url += '?next=' + redirect
return url

register = template.Library()

register.simple_tag(pdc_version)
register.simple_tag(login_url)
4 changes: 2 additions & 2 deletions pdc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
'django.contrib.auth.backends.ModelBackend',
)

# LOGIN_URL = '/auth/krb5login'
# LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/auth/krb5login'
LOGIN_REDIRECT_URL = '/'

ROOT_URLCONF = 'pdc.urls'

Expand Down
3 changes: 2 additions & 1 deletion pdc/templates/base_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{% load static %}
{% load i18n %}
{% load pdctags %}

<html>
<head>
Expand Down Expand Up @@ -74,7 +75,7 @@
{% endif %}
{% else %}
<li>
<a href='{% url 'auth/krb5login' %}?next={{ request.path }}'>{% trans 'Log-in' %}</a>
<a href='{% login_url request.path %}'>{% trans 'Log-in' %}</a>
</li>
{% endif %}
</ul>
Expand Down

0 comments on commit 38d227e

Please sign in to comment.