Skip to main content

pypicloud-access-github

ci-badge version-badge

This package provides a Github-based authentication backend for pypicloud.

The package binds the PyPICloud instance to a GitHub Organization, and uses GitHub users, teams, and permissions to provide authentication and access control.

Usage

Installation

You can install the package directly from pypi, alongside your pypicloud installation.

poetry add outcome-pypicloud-access-github

Or, if you want to use memcache for caching.

poetry add outcome-pypicloud-access-github[memcache]

Configuration

You need to configure PyPICloud to use the auth backend, in the server.ini:

pypi.auth = outcome.pypicloud_access_github.Poetry

auth.otc.github.organization = <INSERT YOUR ORGANIZATION NAME HERE>
auth.otc.github.token = <INSERT YOUR TOKEN HERE>

You can see a sample here.

Caching

Retrieving the authentication information from GitHub can be a relatively slow process, depending on the size of your organization. The plugin implements an internal TTL cache using dogpile.cache to avoid hitting GitHub on each request.

By default the cache backend is an in-memory cache, that is not shared across threads or processes. You can configure the cache to use a memcache instance that will be shared amongst threads/processes.

auth.otc.github.cache.backend = memory  # Use the memory backend
auth.otc.github.cache.expiration = 300  # Expire the cache items after 300s

For memcache:

auth.otc.github.cache.backend = memcache  # Use the memcache backend
auth.otc.github.cache.expiration = 300  # Expire the cache items after 300s
auth.otc.github.cache.memcache.url = 127.0.0.1:11211  # The server:port of your memcache instance

Options

The full list of configuration options:

Option  Default Description
auth.otc.github.token None  The Github Token used to query Github for the auth information
auth.otc.github.organization None The Github Organization name to use as a directory
auth.otc.github.repo_pattern .* A pattern that will be interpreted as a regular expression to filter repository names
auth.otc.github.repo_include_list [] A list of repository names to include. Names not in the list will be excluded
auth.otc.github.repo_exclude_list [] A list of repository names to exclude. Names in the list will be excluded
auth.otc.github.cache.backend memory The cache backend to use, can be memory or memcache
auth.otc.github.cache.expiration  300 The TTL for each cache key
auth.otc.github.cache.memcache.url 127.0.0.1:11211 The url of the memcache server

Github Token

You can create a Personal Access Token from your Developer Settings. The token must have repo, admin:org, and read:user permissions.

Publishing & Pulling Packages

You can use your standard tools to publish to the repository (see here for Poetry). The username will be the GitHub username of the user, and the token will be a Personal Access Token assigned to that user. The token only requires read:user scopes as it is only used to verify the identity of the user.

How GitHub concepts are mapped to PyPICloud

Authorization & Authentication

The GitHub ACL elements are mapped pretty intuitively onto PyPICloud ACL elements.

  • Users login with their username and PAT (the backend ensures that the username matches the token)
  • Permissions are defined by the GitHub roles applied either on the Team, Repository, or Organization levels

The permissions are mapped as follows:

GitHub Role  PyPI Permissions
admin read, write
maintain read, write
triage read
read read
write read, write

Packages

The backend considers each repository to be a potential package (the backend isn't designed for monorepos). The backend will attempt to retrieve package information from the repository. Currently, the backend only supports Poetry packages, using pyproject.toml, but it is easy to support other file formats by creating a new subclass of the outcome.pypicloud_access_github.access.Access class (see poetry.py as an example.)

For example, the repository for this library contains a pyproject.toml with the following:

[tool.poetry]
name = "outcome-pypicloud-access-github"
version = "0.1.0"
description = "An Github-based access backend for pypicloud."

The backend will read this file and determine that the package is named outcome-pypicloud-access-github.

Development

Remember to run ./pre-commit.sh when you clone the repository.

Testing

The testing is mainly made up of integration tests, read the testing README for more details.

Release files for outcome-pypicloud-access-github 1.2.9

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

Source distribution (sdist)

Source distribution for outcome-pypicloud-access-github 1.2.9
File Size Uploaded
outcome-pypicloud-access-github-1.2.9.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for outcome-pypicloud-access-github 1.2.9
File Interpreter ABI Platform
outcome_pypicloud_access_github-1.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 38.2 kB

Release files / outcome-pypicloud-access-github-1.2.9.tar.gz

Download URL outcome-pypicloud-access-github-1.2.9.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ba41224c580b650e03a7ad4778cc9b680e8cfa3f0ea0444aa24c3b3840082e5c
BLAKE2b-256 checksum
How to use checksums
620ce68ae4891d5cc9165e40dfddb08390bc24293f34839f132c0d5e76f607bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1043-azure

Release files / outcome_pypicloud_access_github-1.2.9-py3-none-any.whl

Download URL outcome_pypicloud_access_github-1.2.9-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
024ac01e5aab5acd9b9477200453c71b662123716f21c6954734dffc87dbc77a
BLAKE2b-256 checksum
How to use checksums
5a55add778c1f062bf77197fc4d6af2268c80b5fde441c912e009afc16535245
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1043-azure

Release history Release notifications | RSS feed

This release

1.2.9 This release

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

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