Skip to main content

pyramid_odesk

pyramid_odesk allows your users to authorize via odesk on your pyramid project.

You can find it on pypi as pyramid_odesk. Also don’t forget to check the documentation.

Requirements

pyramid-redis-sessions is used to store session in Redis database, so you need to install Redis and configure it to listen to port 127.0.0.1.

Other packages are installed automatically:

pyramid
pyramid_redis_sessions
python-odesk

To activate jinja2 renderer, install:

pip install pyramid_jinja2

Installation

Install with pip:

pip install pyramid_odesk

or using easy_install:

easy_install pyramid_odesk

You need to create oDesk API keys of the type Web and set appropriate permissions to the generated API key.

Usage

You can take a look at the pyramid_odesk_example application or use the instructions below.

Include following settings in your *.ini file:

[app:main]

...

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

# oDesk settings
odesk.api.key = FILL ME
odesk.api.secret = FILL ME

Then in your project’s __init__.py define 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 group principals or None if user is not allowed to have any access groups. See pyramid documentation for security and tutorial.

Define a RootFactory in your models.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):
        pass

Now register get_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-odesk
    config.registry.get_acl_group = get_acl_group

    # External includes
    config.include('pyramid_odesk')

    # 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 custom forbidden.jinja2 template by overriding asset in your __init__.py:

# Override forbidden template                                                                                                                                                                   config.override_asset(
    to_override='pyramid_odesk:templates/forbidden.jinja2',
    override_with='myapp:templates/forbidden.jinja2')

See template example in pyramid_odesk/templates/forbidden.jinja2.

The “Logout” action is done also via POST request with CSRF protection, see example of “Logout” buttion in pyramid_odesk_example/templates/layout.jinja2.

Contacts

The project is made by Cyril Panshine (@CyrilPanshine). Bug reports and pull requests are very much welcomed!

1.1.5

  • Due to oDesk Public API change we need to get user information now from client.hr.get_user_me()

1.1.4

  • Implement bugfix for case when session is broken and request token and secret are not set.

1.1.3

  • Store first and last name in the session for further usage in templates

1.1.2

  • Login and Logout actions are performed via POST and has protection against CSRF attacks

1.1.1

  • Fix BaseHandler obscuring AttributeError during dispatch

1.1

  • Use override_offset for overriding forbidden.jinja2 template.

  • If user is authenticated but is not authrized for some view, render forbidden page with Log out link instead of redirect to avoid redirect loop

1.0

  • Initial version.

Metadata

Release files for pyramid_odesk 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyramid_odesk 1.1.5
File Size Uploaded Provenance Actions
pyramid_odesk-1.1.5.tar.gz 7.0 kB Without provenance Details for pyramid_odesk-1.1.5.tar.gz

Release files / pyramid_odesk-1.1.5.tar.gz

Download URL pyramid_odesk-1.1.5.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8fd3e266742010733d2a9e7f00b1a3994de3ee8a90ebec4552b7280351d5279a
BLAKE2b-256 checksum
How to use checksums
ad75183d910cc9e7024efcd9b3bbdd9d3dbf4712fe74136e8085f0ff1c10442a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyramid_odesk 1.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page