<commit_before>from django.core.urlresolvers import reverse
from django.http import HttpResponse

from oidc_provider import settings


def redirect(uri):
    """
    Custom Response object for redirecting to a Non-HTTP url scheme.
    """
    response = HttpResponse('', status=302)
    response['Location'] = uri
    return response


def get_issuer():
    """
    Construct the issuer full url. Basically is the site url with some path
    appended.
    """
    site_url = settings.get('SITE_URL')
    path = reverse('oidc_provider:provider_info') \
        .split('/.well-known/openid-configuration')[0]
    issuer = site_url + path

    return issuer


class DefaultUserInfo(object):
    """
    Default class for setting OIDC_USERINFO.
    """

    @classmethod
    def get_by_user(cls, user):
        return None


def default_sub_generator(user):
    """
    Default function for setting OIDC_IDTOKEN_SUB_GENERATOR.
    """
    return str(user.id)


def default_after_userlogin_hook(request, user, client):
    """
    Default function for setting OIDC_AFTER_USERLOGIN_HOOK.
    """
    return None

def default_idtoken_processing_hook(id_token):
    """
    Hook to perform some additional actions ti `id_token` dictionary just before serialization.

    :param id_token: dictionary contains values that going to be serialized into `id_token`
    :type id_token: dict
    :return: custom modified dictionary of values for `id_token`
    :rtype dict
    """
    return id_token
<commit_msg>added 'user' into default_idtoken_processing_hook<commit_after>from django.core.urlresolvers import reverse
from django.http import HttpResponse

from oidc_provider import settings


def redirect(uri):
    """
    Custom Response object for redirecting to a Non-HTTP url scheme.
    """
    response = HttpResponse('', status=302)
    response['Location'] = uri
    return response


def get_issuer():
    """
    Construct the issuer full url. Basically is the site url with some path
    appended.
    """
    site_url = settings.get('SITE_URL')
    path = reverse('oidc_provider:provider_info') \
        .split('/.well-known/openid-configuration')[0]
    issuer = site_url + path

    return issuer


class DefaultUserInfo(object):
    """
    Default class for setting OIDC_USERINFO.
    """

    @classmethod
    def get_by_user(cls, user):
        return None


def default_sub_generator(user):
    """
    Default function for setting OIDC_IDTOKEN_SUB_GENERATOR.
    """
    return str(user.id)


def default_after_userlogin_hook(request, user, client):
    """
    Default function for setting OIDC_AFTER_USERLOGIN_HOOK.
    """
    return None

def default_idtoken_processing_hook(id_token, user):
    """
    Hook to perform some additional actions ti `id_token` dictionary just before serialization.

    :param id_token: dictionary contains values that going to be serialized into `id_token`
    :type id_token: dict
    :param user: user instance 
    :return: custom modified dictionary of values for `id_token`
    :rtype dict
    """
    return id_token

{'fraction_non_alphanumeric': 0.0863754889178618, 'fraction_numerical': 0.002607561929595828, 'mean_word_length': 3.4094827586206895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2627001', 'n_tokens_mistral': 914, 'n_tokens_neox': 890, 'n_words': 270}