improve sample application, add more templates
- add logout link - header line with username - use JS autologin
This commit is contained in:
parent
2879803273
commit
ffa6112042
|
@ -50,6 +50,7 @@ MIDDLEWARE_CLASSES = (
|
|||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'django_kerberos.backends.KerberosBackend',
|
||||
'django_kerberos.backends.KerberosPasswordBackend',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'sample.urls'
|
||||
|
@ -89,6 +90,9 @@ USE_TZ = True
|
|||
STATIC_URL = '/static/'
|
||||
|
||||
LOGIN_URL = 'kerberos-login'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
KERBEROS_BACKEND_CREATE = True
|
||||
KERBEROS_BACKEND_ADMIN_REGEXP = r'^.*/admin$'
|
||||
|
||||
execfile('config.py', globals())
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% include "django_kerberos/autologin.html" %}
|
||||
{% if user.is_authenticated %}
|
||||
<p>Hello {{ user }}</p>
|
||||
{% if user.is_superuser %}
|
||||
<p><a href="/admin">Admin</a></p>
|
||||
{% endif %}
|
||||
<p><a href="{% url "logout" %}?next=/">Logout</a></p>
|
||||
{% else %}
|
||||
<p>Please <a href="{% url "kerberos-login" %}">login with kerberos</a> or with your <a href="{% url "login" %}">password</a></p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button>Login</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -1,7 +1,4 @@
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django import http
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
@login_required
|
||||
def home(request):
|
||||
return http.HttpResponse(u'It worked ' + request.user.username + u'!', content_type='text/plain')
|
||||
return render(request, 'index.html')
|
||||
|
|
Loading…
Reference in New Issue