<commit_before>from magpie.definitions.pyramid_definitions import *
from magpie.definitions.ziggurat_definitions import *
from magpie.api.login import esgfopenid, wso2
from magpie.constants import get_constant
from magpie import models
from authomatic import Authomatic, provider_id
from authomatic.providers import oauth2, openid
import logging
AUTHOMATIC_LOGGER = logging.getLogger('magpie.authomatic')
AUTHOMATIC_LOGGER.setLevel(logging.DEBUG)


def auth_config_from_settings(settings):
    magpie_secret = get_constant('MAGPIE_SECRET', settings=settings, settings_name='magpie.secret')
    magpie_cookie_expire = get_constant('MAGPIE_COOKIE_EXPIRE', settings=settings,
                                        settings_name='magpie.cookie_expire', default_value=None,
                                        raise_missing=False, raise_not_set=False, print_missing=True)
    magpie_cookie_name = get_constant('MAGPIE_COOKIE_NAME', settings=settings,
                                      settings_name='magpie.token_name', default_value='auth_tkt',
                                      raise_missing=False, raise_not_set=False, print_missing=True)
    authn_policy = AuthTktAuthenticationPolicy(
        magpie_secret,
        cookie_name=magpie_cookie_name,
        callback=groupfinder,
        # Protect against JavaScript CSRF attacks attempting cookies retrieval
        http_only=True,
        # Automatically refresh the cookie unless inactivity reached 'timeout'
        timeout=magpie_cookie_expire,
        reissue_time=int(magpie_cookie_expire / 10) if magpie_cookie_expire else None,
    )
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=models.RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy
    )
    return config


def authomatic_setup(request):<commit_msg>adjust convert cookie expire int<commit_after>from magpie.definitions.pyramid_definitions import *
from magpie.definitions.ziggurat_definitions import *
from magpie.api.login import esgfopenid, wso2
from magpie.constants import get_constant
from magpie import models
from authomatic import Authomatic, provider_id
from authomatic.providers import oauth2, openid
import logging
AUTHOMATIC_LOGGER = logging.getLogger('magpie.authomatic')
AUTHOMATIC_LOGGER.setLevel(logging.DEBUG)


def auth_config_from_settings(settings):
    magpie_secret = get_constant('MAGPIE_SECRET', settings=settings, settings_name='magpie.secret')
    magpie_cookie_expire = get_constant('MAGPIE_COOKIE_EXPIRE', settings=settings,
                                        settings_name='magpie.cookie_expire', default_value=None,
                                        raise_missing=False, raise_not_set=False, print_missing=True)
    magpie_cookie_name = get_constant('MAGPIE_COOKIE_NAME', settings=settings,
                                      settings_name='magpie.cookie_name', default_value='auth_tkt',
                                      raise_missing=False, raise_not_set=False, print_missing=True)
    authn_policy = AuthTktAuthenticationPolicy(
        magpie_secret,
        cookie_name=magpie_cookie_name,
        callback=groupfinder,
        # Protect against JavaScript CSRF attacks attempting cookies retrieval
        http_only=True,
        # Automatically refresh the cookie unless inactivity reached 'timeout'
        timeout=magpie_cookie_expire,
        reissue_time=int(magpie_cookie_expire) / 10 if magpie_cookie_expire else None,
    )
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=models.RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy
    )
    return config


def authomatic_setup(request):
{'fraction_non_alphanumeric': 0.06390780513357779, 'fraction_numerical': 0.0020953378732320588, 'mean_word_length': 3.519526627218935, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2084736', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1056, 'n_words': 197}