Ejemplo n.º 1
0
def load_form_config(
    app, 
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.form',
):
    app = RequireEnvironKey(
        app,
        'paste.auth_tkt.set_user',
        missing_error=(
            'Missing the key %(key)s from the environ. '
            'Have you added the cookie method after the form method?'
        )
    )
    template_conf = strip_base(auth_conf, 'template.')
    if template_conf:
        template_ = get_template(template_conf, prefix=prefix+'template.')
    else:
        template_ = template
    authenticate_conf = strip_base(auth_conf, 'authenticate.')
    app, authfunc, users = get_authenticate_function(
        app, 
        authenticate_conf, 
        prefix=prefix+'authenticate.', 
        format='basic'
    )
    charset=auth_conf.get('charset')
    method =auth_conf.get('method', 'post')
    if method.lower() not in ['get','post']:
        raise Exception('Form method should be GET or POST, not %s'%method)
    return app, {'authfunc':authfunc, 'template':template_, 'charset':charset, 'method':method}, None
Ejemplo n.º 2
0
def load_form_config(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.form',
):
    app = RequireEnvironKey(
        app,
        'paste.auth_tkt.set_user',
        missing_error=(
            'Missing the key %(key)s from the environ. '
            'Have you added the cookie method after the form method?'))
    template_conf = strip_base(auth_conf, 'template.')
    if template_conf:
        template_ = get_template(template_conf, prefix=prefix + 'template.')
    else:
        template_ = template
    authenticate_conf = strip_base(auth_conf, 'authenticate.')
    app, authfunc, users = get_authenticate_function(app,
                                                     authenticate_conf,
                                                     prefix=prefix +
                                                     'authenticate.',
                                                     format='basic')
    charset = auth_conf.get('charset')
    return app, {
        'authfunc': authfunc,
        'template': template_,
        'charset': charset
    }, None
Ejemplo n.º 3
0
def load_google_config(app, auth_conf, app_conf, global_conf, prefix):
    authenticate_conf = strip_base(auth_conf, "authenticate.")
    app, authfunc, users = get_authenticate_function(
        app, authenticate_conf, prefix=prefix + "authenticate.", format="basic"
    )

    auth_handler_params = {"authfunc": authfunc}

    user_setter_params = {
        "signout_path": auth_conf.get("signoutpath", None),
        "admin_role": auth_conf.get("adminrole", None),
    }

    return app, auth_handler_params, user_setter_params
Ejemplo n.º 4
0
def load_basic_config(app, auth_conf, app_conf=None, global_conf=None, prefix="authkit.basic"):
    auth_handler_params = {}
    user_setter_params = {}

    authenticate_conf = strip_base(auth_conf, "authenticate.")
    app, authfunc, users = get_authenticate_function(
        app, authenticate_conf, prefix=prefix + "authenticate.", format="basic"
    )
    realm = auth_conf.get("realm", "AuthKit")
    auth_handler_params["realm"] = realm
    auth_handler_params["authfunc"] = authfunc
    user_setter_params["realm"] = realm
    user_setter_params["authfunc"] = authfunc
    user_setter_params["users"] = users
    return app, auth_handler_params, user_setter_params
Ejemplo n.º 5
0
def load_form_config(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.form',
):
    app = RequireEnvironKey(
        app,
        'paste.auth_tkt.set_user',
        missing_error=(
            'Missing the key %(key)s from the environ. '
            'Have you added the cookie method after the form method?'))
    template_conf = strip_base(auth_conf, 'template.')
    if template_conf:
        template_ = get_template(template_conf, prefix=prefix + 'template.')
    else:
        template_ = template
    authenticate_conf = strip_base(auth_conf, 'authenticate.')
    app, authfunc, users = get_authenticate_function(app,
                                                     authenticate_conf,
                                                     prefix=prefix +
                                                     'authenticate.',
                                                     format='basic')
    charset = auth_conf.get('charset')
    method = auth_conf.get('method', 'post')
    action = auth_conf.get('action')
    user_data = auth_conf.get('userdata')
    if method.lower() not in ['get', 'post']:
        raise Exception('Form method should be GET or POST, not %s' % method)
    return app, {
        'authfunc': authfunc,
        'template': template_,
        'charset': charset,
        'method': method,
        'action': action,
        'user_data': user_data or None,
    }, None
Ejemplo n.º 6
0
def load_basic_config(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.basic',
):
    auth_handler_params = {}
    user_setter_params = {}

    authenticate_conf = strip_base(auth_conf, 'authenticate.')
    app, authfunc, users = get_authenticate_function(app,
                                                     authenticate_conf,
                                                     prefix=prefix +
                                                     'authenticate.',
                                                     format='basic')
    realm = auth_conf.get('realm', 'AuthKit')
    auth_handler_params['realm'] = realm
    auth_handler_params['authfunc'] = authfunc
    user_setter_params['realm'] = realm
    user_setter_params['authfunc'] = authfunc
    user_setter_params['users'] = users
    return app, auth_handler_params, user_setter_params
Ejemplo n.º 7
0
def load_digest_config(
    app,
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.digest', 
):
    auth_handler_params = {}
    user_setter_params = {}
    authenticate_conf = strip_base(auth_conf, 'authenticate.')
    app, authfunc, users = get_authenticate_function(
        app, 
        authenticate_conf, 
        prefix=prefix+'authenticate.', 
        format='digest'
    )
    realm = auth_conf.get('realm', 'AuthKit')
    auth_handler_params['realm'] = realm
    auth_handler_params['authfunc'] = authfunc
    user_setter_params['realm'] = realm
    user_setter_params['authfunc'] = authfunc
    user_setter_params['users'] = users
    return app, auth_handler_params, user_setter_params