Package: pyramid_upwork
pyramid_upworkallows your users to authorize viaupworkon yourpyramidproject.You can find it onpypiaspyramid_upwork. Also don’t forget to check thedocumentation.Requirementspyramid-redis-sessionsis used to store session inRedisdatabase, so you need to installRedisand configure it to listen to port127.0.0.1.Other packages are installed automatically:pyramid
pyramid_redis_sessions
python-upworkTo activatejinja2renderer, install:pip install pyramid_jinja2InstallationInstall with pip:pip install pyramid_upworkor usingeasy_install:easy_install pyramid_upworkYou need to createUpwork API keysof the typeWeband set appropriate permissions to the generated API key.UsageYou can take a look at thepyramid_upwork_exampleapplication or use
the instructions below.Include following settings in your*.inifile:[app:main]

...

# Redis session settings
redis.sessions.secret = FILL ME

# upwork settings
upwork.api.key = FILL ME
upwork.api.secret = FILL METhen in your project’s__init__.pydefine the following function:def get_acl_group(user_uid, request):
    """Here goes your ACL logic."""
    # All authenticated users have ``view`` permission
    return 'view'This function should return list of ACL groupprincipalsor None if user
is not allowed to have any access groups. See pyramid documentation forsecurityandtutorial.Define a RootFactory in yourmodels.py:class RootFactory(object):
    """This object sets the security for our application."""
    __acl__ = [
        (Allow, Authenticated, 'view'),
        (Deny, Authenticated, 'login'),
        (Allow, Everyone, 'login'),
    ]

    def __init__(self, request):
        passNow registerget_acl_group()function in the config registry to make authorization work. Put in your main method:def get_acl_group(request):
    return ('view',)

def main(global_config, **settings):
    """Main app configuration binding."""

    config = Configurator(settings=settings,
                          root_factory="myapp.models.RootFactory")

    # ACL authorization callback for pyramid-upwork
    config.registry.get_acl_group = get_acl_group

    # External includes
    config.include('pyramid_upwork')

    # Views and routing goes here
    # ...
    #
    config.add_view('myapp.views.MainPage',
                    renderer='templates/main.jinja2',
                    permission='view')

    return config.make_wsgi_app()You can provide customforbidden.jinja2template by overriding asset in your__init__.py:# Override forbidden template                                                                                                                                                                   config.override_asset(
    to_override='pyramid_upwork:templates/forbidden.jinja2',
    override_with='myapp:templates/forbidden.jinja2')See template example inpyramid_upwork/templates/forbidden.jinja2.The “Logout” action is done also via POST request with CSRF protection,
see example of “Logout” buttion inpyramid_upwork_example/templates/layout.jinja2.ContactsThe project is made by Cyril Panshine (@CyrilPanshine). Bug reports and pull requests are very much welcomed!1.1.6Odesk rebranded to Upwork, now using python-upwork library.1.1.5Due to oDesk Public API change we need to get user information now fromclient.hr.get_user_me()1.1.4Implement bugfix for case when session is broken and
request token and secret are not set.1.1.3Store first and last name in the session for further usage in templates1.1.2Login and Logout actions are performed via POST and has protection
against CSRF attacks1.1.1FixBaseHandlerobscuringAttributeErrorduring dispatch1.1Useoverride_offsetfor overridingforbidden.jinja2template.If user is authenticated but is not authrized for some view,
renderforbiddenpage withLog outlink instead of redirect
to avoid redirect loop1.0Initial version.