This file is indexed.

/usr/lib/python3/dist-packages/social/apps/webpy_app/utils.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
60
61
62
63
64
65
66
67
68
69
import warnings

from functools import wraps

import web

from social.utils import setting_name, module_member
from social.backends.utils import get_backend, user_backends_data
from social.strategies.utils import get_strategy


DEFAULTS = {
    'STRATEGY': 'social.strategies.webpy_strategy.WebpyStrategy',
    'STORAGE': 'social.apps.webpy_app.models.WebpyStorage'
}


def get_helper(name, do_import=False):
    config = web.config.get(setting_name(name),
                            DEFAULTS.get(name, None))
    return do_import and module_member(config) or config


def load_strategy():
    return get_strategy(get_helper('STRATEGY'), get_helper('STORAGE'))


def load_backend(strategy, name, redirect_uri):
    backends = get_helper('AUTHENTICATION_BACKENDS')
    Backend = get_backend(backends, name)
    return Backend(strategy, redirect_uri)


def psa(redirect_uri=None):
    def decorator(func):
        @wraps(func)
        def wrapper(self, backend, *args, **kwargs):
            uri = redirect_uri
            if uri and backend and '%(backend)s' in uri:
                uri = uri % {'backend': backend}
            self.strategy = load_strategy()
            self.backend = load_backend(self.strategy, backend, uri)
            return func(self, backend, *args, **kwargs)
        return wrapper
    return decorator


def backends(user):
    """Load Social Auth current user data to context under the key 'backends'.
    Will return the output of social.backends.utils.user_backends_data."""
    return user_backends_data(user, get_helper('AUTHENTICATION_BACKENDS'),
                              get_helper('STORAGE', do_import=True))


def login_redirect():
    """Load current redirect to context."""
    method = web.ctx.method == 'POST' and 'post' or 'get'
    data = web.input(_method=method)
    value = data.get('next')
    return {
        'REDIRECT_FIELD_NAME': 'next',
        'REDIRECT_FIELD_VALUE': value,
        'REDIRECT_QUERYSTRING': value and ('next=' + value) or ''
    }


def strategy(*args, **kwargs):
    warnings.warn('@strategy decorator is deprecated, use @psa instead')
    return psa(*args, **kwargs)