Esempio n. 1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings, )

    config.set_authentication_policy(
        authentication.AuthTktAuthenticationPolicy(
            config.get_settings().get('mediapublic.authentication_secret',
                                      'changeme'),
            callback=auth.associate_groups,
            hashalg='sha512',
        ))
    config.set_authorization_policy('mediapublic.auth.authz_policy')
    config.add_permission('get')
    config.add_permission('create')
    config.add_permission('update')
    config.add_permission('delete')

    config.include('cornice')
    config.scan('mediapublic.auth')
    config.scan('mediapublic.views')

    config.include('velruse.providers.twitter')

    return config.make_wsgi_app()
Esempio n. 2
0
def config_auth_policy(config, settings):
    policy = authentication.AuthTktAuthenticationPolicy(
        settings['auth_secret'],
        get_principals,
        cookie_name="angularpyramid_auth",
        hashalg="sha512")
    config.set_authentication_policy(policy)
    config.set_authorization_policy(authorization.ACLAuthorizationPolicy())
Esempio n. 3
0
def config_auth_policy(config, settings):
    policy = authentication.AuthTktAuthenticationPolicy(
        settings.get('auth_secret', DEFAULT_AUTH_SECRET),
        get_principals,
        cookie_name="workhours_auth",
        hashalg="sha512",
    )
    config.set_authorization_policy(authorization.ACLAuthorizationPolicy())
    config.set_authentication_policy(policy)

    my_session_factory = SignedCookieSessionFactory(
        settings.get('auth_secret', DEFAULT_COOKIE_SECRET))
    config.set_session_factory(my_session_factory)
Esempio n. 4
0

def users_acl(request):
    if request.authenticated_userid:
        pass


def associate_groups(user_id, request):
    # TODO(ryansb): actually associate users/groups using the
    # UserTypes model
    return 'user', 'admin'


authn_policy = authentication.AuthTktAuthenticationPolicy(
    # TODO(ryansb): load this from config
    'secretsecrets',
    callback=associate_groups,
    hashalg='sha512',
)


authz_policy = authorization.ACLAuthorizationPolicy()


# --------- Auth and login
login = Service(name='login', path='/login',
                description="Auth and such",
                cors_policy=cors_policy)


@login.get(renderer="mediapublic:templates/login.jinja2")
def login_form(request):