Esempio n. 1
0
def make_digest_auth_handler(
    app,
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.digest', 
):
    app, auth_handler_params, user_setter_params = load_digest_config(
        app,
        auth_conf, 
        app_conf=None,
        global_conf=None,
        prefix='authkit.digest', 
    )
    app = MultiHandler(app)
    app.add_method(
        'digest', 
        DigestAuthHandler, 
        auth_handler_params['realm'], 
        auth_handler_params['authfunc']
    )
    app.add_checker('digest', status_checker)
    app = DigestUserSetter(
        app, 
        user_setter_params['realm'],
        user_setter_params['authfunc'],
        user_setter_params['users'],
    )
    return app
Esempio n. 2
0
def make_digest_auth_handler(
    app,
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.digest', 
):
    app, auth_handler_params, user_setter_params = load_digest_config(
        app,
        auth_conf, 
        app_conf=None,
        global_conf=None,
        prefix='authkit.digest', 
    )
    app = MultiHandler(app)
    app.add_method(
        'digest', 
        DigestAuthHandler, 
        auth_handler_params['realm'], 
        auth_handler_params['authfunc']
    )
    app.add_checker('digest', status_checker)
    app = DigestUserSetter(
        app, 
        user_setter_params['realm'],
        user_setter_params['authfunc'],
        user_setter_params['users'],
    )
    return app
Esempio n. 3
0
def make_basic_auth_handler(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.basic',
):
    app, auth_handler_params, user_setter_params = load_basic_config(
        app,
        auth_conf,
        app_conf=None,
        global_conf=None,
        prefix='authkit.basic',
    )
    app = MultiHandler(app)
    app.add_method('basic', BasicAuthHandler, auth_handler_params['realm'],
                   auth_handler_params['authfunc'])
    app.add_checker('basic', status_checker)
    app = BasicUserSetter(
        app,
        user_setter_params['realm'],
        user_setter_params['authfunc'],
        user_setter_params['users'],
    )
    return app
Esempio n. 4
0
def make_passurl_handler(
    app,
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.openid', 
):
    app, auth_handler_params, user_setter_params = load_openid_config(
        app,
        auth_conf, 
        app_conf=None,
        global_conf=None,
        prefix='authkit.openid', 
    )
    # Note, the session middleware should already be setup by now
    # if we are not using beaker
    app = MultiHandler(app)
    app.add_method(
        'openid', 
        OpenIDAuthHandler,
        template=auth_handler_params['template'],
        path_verify=auth_handler_params['path_verify'],
        baseurl=auth_handler_params['baseurl'],
        charset=auth_handler_params['charset']
    )
    app.add_checker('openid', status_checker)
    # XXX Some of this functionality should be moved into OpenIDAuthHandler
    app = OpenIDUserSetter(
        app,
        **user_setter_params
    )
    return app
Esempio n. 5
0
def make_forward_handler(
    app,
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.forward', 
):
    signin_path = None
    if auth_conf.has_key('internalpath'):
        warnings.warn(
            'The %sinternalpath key is deprecated. Please use '
            '%ssigninpath.'%(prefix, prefix), 
            DeprecationWarning, 
            2
        )
        signin_path = auth_conf['internalpath']
    elif auth_conf.has_key('signinpath'):
        signin_path = auth_conf['signinpath']
    else:
        raise AuthKitConfigError("No %ssigninpath key specified"%prefix)
    app = MultiHandler(app)
    app.add_method(
        'forward', 
        Redirect,  
        signin_path
    )
    app.add_checker('forward', status_checker)
    app = MyRecursive(RecursiveMiddleware(app))
    return app
Esempio n. 6
0
def make_form_handler(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.form',
):
    app, auth_handler_params, user_setter_params = load_form_config(
        app,
        auth_conf,
        app_conf=None,
        global_conf=None,
        prefix='authkit.method.form',
    )
    app = MultiHandler(app)
    app.add_method(
        'form',
        FormAuthHandler,
        authfunc=auth_handler_params['authfunc'],
        template=auth_handler_params['template'],
        charset=auth_handler_params['charset'],
        method=auth_handler_params['method'],
        action=auth_handler_params['action'],
        user_data=auth_handler_params['user_data'],
    )
    app.add_checker('form', status_checker)
    return app
Esempio n. 7
0
File: form.py Progetto: masyl/mixxim
def make_form_handler(
    app, 
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.form', 
):
    app, auth_handler_params, user_setter_params = load_form_config(
        app, 
        auth_conf, 
        app_conf=None,
        global_conf=None,
        prefix='authkit.method.form',
    )
    app = MultiHandler(app)
    app.add_method(
        'form', 
        FormAuthHandler, 
        authfunc=auth_handler_params['authfunc'], 
        template=auth_handler_params['template'], 
        charset=auth_handler_params['charset'],
        method=auth_handler_params['method'],
        action=auth_handler_params['action'],
        user_data=auth_handler_params['user_data'],
    )
    app.add_checker('form', status_checker)
    return app
Esempio n. 8
0
def make_passurl_handler(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.openid',
):
    app, auth_handler_params, user_setter_params = load_openid_config(
        app,
        auth_conf,
        app_conf=None,
        global_conf=None,
        prefix='authkit.openid',
    )
    # Note, the session middleware should already be setup by now
    # if we are not using beaker
    app = MultiHandler(app)
    app.add_method(
        'openid',
        OpenIDAuthHandler,
        template=auth_handler_params['template'],
        path_verify=auth_handler_params['path_verify'],
        baseurl=auth_handler_params['baseurl'],
        charset=auth_handler_params['charset'],
    )
    app.add_checker('openid', status_checker)
    # XXX Some of this functionality should be moved into OpenIDAuthHandler
    app = OpenIDUserSetter(app, **user_setter_params)
    return app
Esempio n. 9
0
def make_basic_auth_handler(app, auth_conf, app_conf=None, global_conf=None, prefix="authkit.basic"):
    app, auth_handler_params, user_setter_params = load_basic_config(
        app, auth_conf, app_conf=None, global_conf=None, prefix="authkit.basic"
    )
    app = MultiHandler(app)
    app.add_method("basic", BasicAuthHandler, auth_handler_params["realm"], auth_handler_params["authfunc"])
    app.add_checker("basic", status_checker)
    app = BasicUserSetter(app, user_setter_params["realm"], user_setter_params["authfunc"], user_setter_params["users"])
    return app
Esempio n. 10
0
def make_handler(app, auth_conf, app_conf=None, global_conf=None, prefix="authkit.method.google."):
    app, auth_handler_params, user_setter_params = load_google_config(app, auth_conf, app_conf, global_conf, prefix)
    app = MultiHandler(app)
    app.add_method("google", GoogleAccountHandler)
    app.add_checker("google", status_checker)

    app = GoogleUserSetter(app, **user_setter_params)

    return app
Esempio n. 11
0
def make_redirect_handler(
    app, 
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.redirect.', 
):
    app = MultiHandler(app)
    app.add_method('redirect', HandleRedirect, redirect_to = auth_conf['url'])
    app.add_checker('redirect', status_checker)
    return app
Esempio n. 12
0
def make_redirect_handler(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.redirect.',
):
    app = MultiHandler(app)
    app.add_method('redirect', HandleRedirect, redirect_to=auth_conf['url'])
    app.add_checker('redirect', status_checker)
    return app
Esempio n. 13
0
def make_handler(
    app, 
    auth_conf, 
    app_conf=None,
    global_conf=None,
    prefix='authkit.method.openidprovider.', 
):
    app = MultiHandler(app)
    app.add_method('openidprovider', Handler)
    app.add_checker('openidprovider', status_checker)
    return app
Esempio n. 14
0
def make_forward_handler(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.forward',
):
    if not auth_conf.has_key('internalpath'):
        raise AuthKitConfigError("No %sinternalpath key specified" % prefix)
    app = MultiHandler(app)
    app.add_method('forward', Redirect, auth_conf['internalpath'])
    app.add_checker('forward', status_checker)
    app = MyRecursive(RecursiveMiddleware(app))
    return app
Esempio n. 15
0
def make_forward_handler(
    app,
    auth_conf,
    app_conf=None,
    global_conf=None,
    prefix='authkit.forward',
):
    signin_path = None
    if auth_conf.has_key('internalpath'):
        warnings.warn(
            'The %sinternalpath key is deprecated. Please use '
            '%ssigninpath.' % (prefix, prefix), DeprecationWarning, 2)
        signin_path = auth_conf['internalpath']
    elif auth_conf.has_key('signinpath'):
        signin_path = auth_conf['signinpath']
    else:
        raise AuthKitConfigError("No %ssigninpath key specified" % prefix)
    app = MultiHandler(app)
    app.add_method('forward', Redirect, signin_path)
    app.add_checker('forward', status_checker)
    app = MyRecursive(RecursiveMiddleware(app))
    return app
Esempio n. 16
0
def make_multi_middleware(app,
                          auth_conf,
                          app_conf=None,
                          global_conf=None,
                          prefix='authkit.'):

    # Load the configurations and any associated middleware
    app, oid_auth_params, oid_user_params = load_openid_config(
        app, strip_base(auth_conf, 'openid.'))
    app, form_auth_params, form_user_params = load_form_config(
        app, strip_base(auth_conf, 'form.'))
    app, cookie_auth_params, cookie_user_params = load_cookie_config(
        app, strip_base(auth_conf, 'cookie.'))
    app, basic_auth_params, basic_user_params = load_basic_config(
        app, strip_base(auth_conf, 'basic.'))
    app, digest_auth_params, digest_user_params = load_digest_config(
        app, strip_base(auth_conf, 'digest.'))

    # The cookie plugin doesn't provide an AuthHandler so no config
    assert cookie_auth_params == None
    # The form plugin doesn't provide a UserSetter (it uses cookie)
    assert form_user_params == None

    # Setup the MultiHandler to switch between authentication methods
    # based on the value of environ['authkit.authhandler'] if a 401 is
    # raised
    app = MultiHandler(app)
    app.add_method('openid', OpenIDAuthHandler, **oid_auth_params)
    app.add_checker('openid', EnvironKeyAuthSwitcher('openid'))
    app.add_method('basic', BasicAuthHandler, **basic_auth_params)
    app.add_checker('basic', EnvironKeyAuthSwitcher('basic'))
    app.add_method('digest', DigestAuthHandler, **digest_auth_params)
    app.add_checker('digest', EnvironKeyAuthSwitcher('digest'))
    app.add_method('form', FormAuthHandler, **form_auth_params)
    app.add_checker('form', Default())

    # Add the user setters to set REMOTE_USER on each request once the
    # user is signed on.
    app = DigestUserSetter(app, **digest_user_params)
    app = BasicUserSetter(app, **basic_user_params)
    # OpenID relies on cookie so needs to be set up first
    app = OpenIDUserSetter(app, **oid_user_params)
    app = CookieUserSetter(app, **cookie_user_params)

    return app
Esempio n. 17
0
def make_multi_middleware(app, auth_conf, app_conf=None, global_conf=None, 
    prefix='authkit.'):

    # Load the configurations and any associated middleware
    app, oid_auth_params, oid_user_params = load_openid_config(
        app, strip_base(auth_conf, 'openid.'))
    app, form_auth_params, form_user_params = load_form_config(
        app, strip_base(auth_conf, 'form.'))
    app, cookie_auth_params, cookie_user_params = load_cookie_config(
        app, strip_base(auth_conf, 'cookie.'))
    app, basic_auth_params, basic_user_params = load_basic_config(
        app, strip_base(auth_conf, 'basic.'))
    app, digest_auth_params, digest_user_params = load_digest_config(
        app, strip_base(auth_conf, 'digest.'))

    # The cookie plugin doesn't provide an AuthHandler so no config
    assert cookie_auth_params == None
    # The form plugin doesn't provide a UserSetter (it uses cookie)
    assert form_user_params == None

    # Setup the MultiHandler to switch between authentication methods
    # based on the value of environ['authkit.authhandler'] if a 401 is 
    # raised
    app = MultiHandler(app)
    app.add_method('openid', OpenIDAuthHandler, **oid_auth_params)
    app.add_checker('openid', EnvironKeyAuthSwitcher('openid'))
    app.add_method('basic', BasicAuthHandler, **basic_auth_params)
    app.add_checker('basic', EnvironKeyAuthSwitcher('basic'))
    app.add_method('digest', DigestAuthHandler, **digest_auth_params)
    app.add_checker('digest', EnvironKeyAuthSwitcher('digest'))
    app.add_method('form', FormAuthHandler, **form_auth_params)
    app.add_checker('form', Default())

    # Add the user setters to set REMOTE_USER on each request once the
    # user is signed on.
    app = DigestUserSetter(app, **digest_user_params)
    app = BasicUserSetter(app, **basic_user_params)
    # OpenID relies on cookie so needs to be set up first
    app = OpenIDUserSetter(app, **oid_user_params)
    app = CookieUserSetter(app, **cookie_user_params)

    return app