This file is indexed.

/usr/lib/python3/dist-packages/social/backends/nk.py is in python3-social-auth 1:0.2.21+dfsg-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
70
71
72
73
74
from urllib import urlencode

import six

from requests_oauthlib import OAuth1

from social.backends.oauth import BaseOAuth2


class NKOAuth2(BaseOAuth2):
    """NK OAuth authentication backend"""
    name = 'nk'
    AUTHORIZATION_URL = 'https://nk.pl/oauth2/login'
    ACCESS_TOKEN_URL = 'https://nk.pl/oauth2/token'
    SCOPE_SEPARATOR = ','
    ACCESS_TOKEN_METHOD = 'POST'
    SIGNATURE_TYPE_AUTH_HEADER = 'AUTH_HEADER'
    EXTRA_DATA = [
        ('id', 'id'),
    ]

    def get_user_details(self, response):
        """Return user details from NK account"""
        entry = response['entry']
        return {
            'username': entry.get('displayName'),
            'email': entry['emails'][0]['value'],
            'first_name': entry.get('displayName').split(' ')[0],
            'id': entry.get('id')
        }

    def auth_complete_params(self, state=None):
        client_id, client_secret = self.get_key_and_secret()
        return {
            'grant_type': 'authorization_code',  # request auth code
            'code': self.data.get('code', ''),  # server response code
            'client_id': client_id,
            'client_secret': client_secret,
            'redirect_uri': self.get_redirect_uri(state),
            'scope': self.get_scope_argument()
        }

    def get_user_id(self, details, response):
        """Return a unique ID for the current user, by default from server
        response."""
        return details.get(self.ID_KEY)

    def user_data(self, access_token, *args, **kwargs):
        """Loads user data from service"""
        url = 'http://opensocial.nk-net.pl/v09/social/rest/people/@me?' + urlencode({
            'nk_token': access_token,
            'fields': 'name,surname,avatar,localization,age,gender,emails,birthdate'
        })
        return self.get_json(
            url,
            auth=self.oauth_auth(access_token)
        )

    def oauth_auth(self, token=None, oauth_verifier=None,
                   signature_type=SIGNATURE_TYPE_AUTH_HEADER):
        key, secret = self.get_key_and_secret()
        oauth_verifier = oauth_verifier or self.data.get('oauth_verifier')
        token = token or {}
        # decoding='utf-8' produces errors with python-requests on Python3
        # since the final URL will be of type bytes
        decoding = None if six.PY3 else 'utf-8'
        state = self.get_or_create_state()
        return OAuth1(key, secret,
                      resource_owner_key=None,
                      resource_owner_secret=None,
                      callback_uri=self.get_redirect_uri(state),
                      verifier=oauth_verifier,
                      signature_type=signature_type,
                      decoding=decoding)