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_ca_index_url_programmatic()

Get CodeArtifact or ECR tokens in Python:

index_url = csaccess.get_ca_auth_token_programmatic()
index_url = csaccess.get_ecr_auth_token_programmatic()

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.5-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: csaccess-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 20.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 420f7ec8f56893478f8662f2cd4f8ab72b7c8f8515cd73dff76a586a9f598a2b
MD5 0bb4980b7bb1ab3d7709c37d741d9487
BLAKE2b-256 abca5dc7a5b29579055ca394fcb3b910ae7cd93ed769cba3c2104cf9f8b20339

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