Révision 9f8bbe95
Ajouté par Thomas Noël il y a plus de 9 ans
usr/local/univnautes/sp/sp/settings.py | ||
---|---|---|
191 | 191 |
'nameid=%(nameid)s', |
192 | 192 |
'multiple=%(multiple)s'] |
193 | 193 |
|
194 |
UNIVNAUTES_CP_DISCONNECT_CMD = [ |
|
195 |
os.path.join(PROJECT_PATH, 'cp_disconnect'), |
|
196 |
'cpzone=%(cpzone)s', |
|
197 |
'ip=%(ip)s'] |
|
198 |
|
|
194 | 199 |
UNIVNAUTES_CP_GET_SESSIONS_CMD = os.path.join(PROJECT_PATH, 'cp_get_sessions') |
195 | 200 |
|
196 | 201 |
# now get some values from config.xml |
usr/local/univnautes/sp/sp/urls.py | ||
---|---|---|
22 | 22 |
urlpatterns = patterns('', |
23 | 23 |
url(r'^$', 'sp.views.homepage', name='homepage'), |
24 | 24 |
url(r'^proxymap/(?P<z>[0-9]+)/(?P<x>[0-9]+)/(?P<y>[0-9]+)\.png$', 'sp.views.proxymap'), |
25 |
url(r'^accounts/logout/', 'django.contrib.auth.views.logout_then_login'), |
|
25 |
url(r'^accounts/logout/', 'sp.views.logout', name='logout'), |
|
26 |
url(r'^accounts/logoutlogin/', 'django.contrib.auth.views.logout_then_login', name='django_logout_then_login'), |
|
26 | 27 |
url(r'^accounts/', include('django.contrib.auth.urls')), |
27 | 28 |
url(r'^authsaml2/', include('authentic2.authsaml2.urls')), |
28 | 29 |
) |
usr/local/univnautes/sp/sp/views.py | ||
---|---|---|
21 | 21 |
from django.contrib.auth.decorators import login_required |
22 | 22 |
import urllib2 |
23 | 23 |
from django.http import HttpResponse |
24 |
from django.shortcuts import redirect |
|
25 |
import subprocess |
|
26 |
|
|
24 | 27 |
|
25 | 28 |
class Homepage(TemplateView): |
26 | 29 |
'''Homepage View, displays a welcome message''' |
27 | 30 |
template_name = 'homepage.html' |
28 |
|
|
29 | 31 |
homepage = login_required(Homepage.as_view()) |
30 | 32 |
|
33 |
|
|
31 | 34 |
def proxymap(request, z, x, y): |
32 | 35 |
url = settings.PROXYMAP_URL % { 'z': int(z), 'x': int(x), 'y': int(y) } |
33 | 36 |
downstream_request = urllib2.Request(url) |
34 | 37 |
page = urllib2.urlopen(downstream_request) |
35 | 38 |
return HttpResponse(page, page.info().getheader('Content-Type')) |
36 | 39 |
|
40 |
def logout(request): |
|
41 |
# 1. disconnect from the captive portal |
|
42 |
cmd = [ c % { |
|
43 |
'cpzone': request.META.get('HTTP_X_PFSENSE_CPZONE') or '', |
|
44 |
'ip': request.META['REMOTE_ADDR'], |
|
45 |
} for c in settings.UNIVNAUTES_CP_DISCONNECT_CMD ] |
|
46 |
p = subprocess.call(cmd) |
|
47 |
# 2. disconnect from django |
|
48 |
return redirect('django_logout_then_login') |
|
49 |
|
Formats disponibles : Unified diff
logout view: disconnect from cp