Skip to main content

A Python library for authenticating and accessing CONTACT resources in AWS.

Project description

Latest Package Version Supported Python Versions License

csaccess

A Python library for authenticating and accessing CONTACT resources in AWS CodeArtifact and Elastic Container Registry (ECR) using OIDC.

Overview

csaccess simplifies access to CONTACT cloud resources by providing a streamlined authentication flow with support for both interactive user-based and automated service-based authentication methods.

Authentication Methods

Feature

User OIDC

Static OIDC (Client Credentials)

Authentication

Interactive user login via web browser

Application authenticates itself using its secret

Grant Type

Authorization Code with PKCE

Client Credentials

User Context

Represents a specific user

Represents the application/service itself

Security

Relies on user credentials and browser

Relies on the client secret’s security

Use Cases

Applications acting on behalf of a user

Service accounts, background processes

Token Audience

Targeted to specific user and application

Targeted to the application

Security Warning: Be extremely careful when handling access tokens. Treat them like passwords:

  • Avoid logging them or storing them insecurely

  • Never paste sensitive tokens into untrusted online services

  • Use environment variables where possible to avoid exposing secrets

Installation

pip install csaccess

Setup and Configuration

Configuration

  • The “relying party” local server requires port 29398 to be free and available

  • Set environment variables to avoid interactive prompts:

On Linux / macOS:

export CS_AWS_OIDC_CLIENT_SECRET="<OIDC-client-secret>"

Windows CMD:

set CS_AWS_OIDC_CLIENT_SECRET="<OIDC-client-secret>"

Windows PowerShell:

$env:CS_AWS_OIDC_CLIENT_SECRET = "<OIDC-client-secret>"

Usage Examples

Important: unset AWS specific vars existing in local env as they will interfere with AWS STS functionality.

unset AWS_PROFILE
unset AWS_DEFAULT_PROFILE

Basic Usage

Get PyPI index URL with embedded auth token (default action):

import csaccess
index_url = csaccess.get_index_url()

Command-Line Interface

Returns the CodeArtifact URL with an injected token (default):

python -m csaccess

Get the CodeArtifact token:

python -m csaccess ca-auth-token

Get the ECR token:

python -m csaccess ecr-auth-token

Integration Examples

Following are examples for Linux / macOS:

Using with pip

INDEX_URL=$(python -m csaccess --quiet)
pip install -i $INDEX_URL your-private-package

Using with Docker

ECR_TOKEN=$(python -m csaccess ecr-auth-token --quiet)
echo $ECR_TOKEN | docker login -u AWS --password-stdin <ECR-registry-url>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csaccess-0.0.3-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file csaccess-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: csaccess-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for csaccess-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b56b15238385ef39f46a6723b6103c27fc8c0f8be5e548a8b0184ea95d31e80a
MD5 c4734267460a33cad21bff7037bb4f6f
BLAKE2b-256 9b8569aadb33606ab140fb54cc9e08991b8c542ff34fc0f29763dc67fe4e4748

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page