/usr/share/pyshared/social_auth/decorators.py is in python-django-social-auth 0.7.23-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | from functools import wraps
from django.core.urlresolvers import reverse
from django.views.decorators.http import require_POST
from django.views.decorators.csrf import csrf_protect
from social_auth.backends import get_backend
from social_auth.exceptions import WrongBackend
from social_auth.utils import setting
def dsa_view(redirect_name=None):
"""Decorate djangos-social-auth views. Will check and retrieve backend
or return HttpResponseServerError if backend is not found.
redirect_name parameter is used to build redirect URL used by backend.
"""
def dec(func):
@wraps(func)
def wrapper(request, backend, *args, **kwargs):
if redirect_name:
redirect = reverse(redirect_name, args=(backend,))
else:
redirect = request.path
request.social_auth_backend = get_backend(backend, request,
redirect)
if request.social_auth_backend is None:
raise WrongBackend(backend)
return func(request, request.social_auth_backend, *args, **kwargs)
return wrapper
return dec
def disconnect_view(func):
@wraps(func)
def wrapper(request, *args, **kwargs):
return func(request, *args, **kwargs)
if setting('SOCIAL_AUTH_FORCE_POST_DISCONNECT'):
wrapper = require_POST(csrf_protect(wrapper))
return wrapper
|