/usr/lib/python3/dist-packages/social/apps/django_app/views.py is in python3-social-auth 0.2.13-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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | from django.conf import settings
from django.contrib.auth import login, REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt, csrf_protect
from django.views.decorators.http import require_POST
from django.views.decorators.cache import never_cache
from social.utils import setting_name
from social.actions import do_auth, do_complete, do_disconnect
from social.apps.django_app.utils import psa
NAMESPACE = getattr(settings, setting_name('URL_NAMESPACE'), None) or 'social'
@never_cache
@psa('{0}:complete'.format(NAMESPACE))
def auth(request, backend):
return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
@never_cache
@csrf_exempt
@psa('{0}:complete'.format(NAMESPACE))
def complete(request, backend, *args, **kwargs):
"""Authentication complete view"""
return do_complete(request.backend, _do_login, request.user,
redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
@never_cache
@login_required
@psa()
@require_POST
@csrf_protect
def disconnect(request, backend, association_id=None):
"""Disconnects given backend from current logged in user."""
return do_disconnect(request.backend, request.user, association_id,
redirect_name=REDIRECT_FIELD_NAME)
def _do_login(backend, user, social_user):
user.backend = '{0}.{1}'.format(backend.__module__,
backend.__class__.__name__)
login(backend.strategy.request, user)
if backend.setting('SESSION_EXPIRATION', False):
# Set session expiration date if present and enabled
# by setting. Use last social-auth instance for current
# provider, users can associate several accounts with
# a same provider.
expiration = social_user.expiration_datetime()
if expiration:
try:
backend.strategy.request.session.set_expiry(
expiration.seconds + expiration.days * 86400
)
except OverflowError:
# Handle django time zone overflow
backend.strategy.request.session.set_expiry(None)
|