root / utils / decorators.py @ 1534e9c2
History | View | Annotate | Download (427 Bytes)
1 | 97e42c7d | Leonidas Poulopoulos | from django.http import HttpResponseRedirect |
---|---|---|---|
2 | 97e42c7d | Leonidas Poulopoulos | from django.core.urlresolvers import reverse |
3 | 97e42c7d | Leonidas Poulopoulos | |
4 | 97e42c7d | Leonidas Poulopoulos | |
5 | 97e42c7d | Leonidas Poulopoulos | def shib_required(f): |
6 | 97e42c7d | Leonidas Poulopoulos | def wrap(request, *args, **kwargs): |
7 | 97e42c7d | Leonidas Poulopoulos | if 'HTTP_SHIB_SESSION_ID' not in request.META or not request.META['HTTP_SHIB_SESSION_ID']: |
8 | 97e42c7d | Leonidas Poulopoulos | return HttpResponseRedirect(reverse('login')) |
9 | 97e42c7d | Leonidas Poulopoulos | return f(request, *args, **kwargs)
|
10 | 97e42c7d | Leonidas Poulopoulos | |
11 | 97e42c7d | Leonidas Poulopoulos | wrap.__doc__=f.__doc__ |
12 | 97e42c7d | Leonidas Poulopoulos | wrap.__name__=f.__name__ |
13 | 97e42c7d | Leonidas Poulopoulos | return wrap |