Skip to main content

Social Auth PressPass

Social Auth PressPass provides backend and pipeline implementations for using PressPass with Python Social Auth. It is available on PyPI as social-auth-presspass, and the primary module import is social_auth_presspass.

When a user logs into your application with PressPass, you will receive a list of the organizations that allow the user to access your app on their behalf.

General Installation

Regardless of your web framework (or lack thereof), there are a few key steps you need to take to start using Social Auth PressPass.

Create a PressPass app

Create a PressPass app using the developer dashboard. The name, price, and access controls are all up to you. Then, make sure of the following in the OpenID Connect section:

  • Response types must include Authorization Code Flow (code), as this is how Social Auth PressPass with authenticate with PressPass itself.

  • Client type must be set to Public. (No, this doesn't mean that anyone will be able to log in; it means that client authentication tokens are cryptographically signed by PressPass itself.)

  • Redirect URIs must include both the development URL and production URL of your application login callback. If you installed Social Auth under the auth/ path in Django, this might look like http://localhost:8000/auth/complete/presspass/. You can add additional paths on each line. Wildcards are not supported, so be exact!

In your settings (in Django, this is your settings.py file), set SOCIAL_AUTH_PRESSPASS_KEY to your application's client ID from the PressPass developer dashboard.

From here, you're ready to go! Now you can integrate the PressPass backend into your app just as you would any other Python Social Auth backend. That being said, this can sometimes be tricky, so we've included a Django quickstart below.

Django Installation

  1. Install social-auth-presspass and django-social-auth from PyPI, and follow all the instructions above (in General Installation). You should also follow django-social-auth's setup instructions, though you can augment them to fit your use case with the following steps.

  2. Add the PressPass auth backend to your SOCIAL_AUTH_AUTHENTICATION_BACKENDS setting in settings.py. This will probably look like the following:

SOCIAL_AUTH_AUTHENTICATION_BACKENDS = (
    'social_auth_presspass.backends.PressPassBackend',
)
  1. Add the PressPass backend as a Django Authentication Backend. To do this, change the following setting:
AUTHENTICATION_BACKENDS = (
    'social_auth_presspass.backends.PressPassBackend',
    ...
)

If you still want to allow some users to log in with a username and password (or if you want to use the Admin Panel login system), be sure to keep Django's built-in ModelBackend in AUTHENTICATION_BACKENDS:

AUTHENTICATION_BACKENDS = (
    'social_auth_presspass.backends.PressPassBackend',
    'django.contrib.auth.backends.ModelBackend',
)
  1. If you want information about a user's organizations, add the PressPass pipelines to your social auth pipelines:
SOCIAL_AUTH_PIPELINE = (
    ...
    'social_auth_presspass.pipelines.extract_organizations',
    'social_auth_presspass.pipelines.link_organizations_to_session',
    ...
)

Note that you should probably put these pipelines after the social_details, social_uid, and auth_allowed built-in pipelines. Note also that you don't need to include link_organizations_to_session unless you would like to access a user's PressPass organizations from inside their session without using their user_information (that is, if you're even keeping track of users).

Backends

This package provides only one backend, social_auth_presspass.backends.PressPassBackend. It inherits from the Python Social Auth OpenID Connect backend, and can be used like any other social auth backend.

User Details

This backend provides the presspass_organizations user detail automatically, which is a list containing information about the organizations that the user is both 1) a member of and 2) has access to the app on behalf of. The key fields in each organization are uuid and name.

Pipelines

This package provides one pipeline, social_auth_presspass.pipelines.link_organizations_to_session, which is intended to help apps leverage the PressPass authentication system in lieu of their own. This pipeline creates two session variables for the PressPass-authenticated visitor:

  • presspass_authenticated: True if the visitor has been authenticated with PressPass (we recommend you use this as session.get('presspass_authenticated', False)), as there is no guarantee that this value is defined and non-null.

  • presspass_organizations: a list of organizations the visitor is authorized to access your app as a member of (each organization is a dict serialized from data returned from PressPass itself). If a visitor hasn't authenticated with PressPass, this value will not be set. All authenticated visitors will be a member of at least one organization (even if that organization is just an auto-generated personal one).

Examples

For an example app that uses this package for authentication (in lieu of its own user-management system), check out OpenAlerts.

License

This package is licensed under the MIT License (see LICENSE).

Metadata

Release files for social-auth-presspass 0.2.0

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

Source distribution (sdist)

Source distribution for social-auth-presspass 0.2.0
File Size Uploaded Provenance
social-auth-presspass-0.2.0.tar.gz 4.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for social-auth-presspass 0.2.0
File Interpreter ABI Platform
social_auth_presspass-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / social-auth-presspass-0.2.0.tar.gz

Download URL social-auth-presspass-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e1eee318ebd8f062e77bd5e3a62e0b00f38ad124906e6468dec9b2af7140db05
BLAKE2b-256 checksum
How to use checksums
d1c392debf916f8df4fac239266b7aaae74d543a100f522d8b0b0103d2e18e77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Release files / social_auth_presspass-0.2.0-py3-none-any.whl

Download URL social_auth_presspass-0.2.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
128c1c85da9b15ce3b533510e0ef979d9a606d75a43388ded6b1480e5de79b57
BLAKE2b-256 checksum
How to use checksums
4c46edf2379b339ebfb670bb733544c66eb3569b44be8499412502055bf6ac79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Security for social-auth-presspass 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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