A Python library for authenticating and accessing CONTACT resources in AWS.
Project description
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file csaccess-0.0.4-py3-none-any.whl.
File metadata
- Download URL: csaccess-0.0.4-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4857efac8e4a8adbf105d9ae321fb32419a6a5a3cead861c3573777b81d6ad6
|
|
| MD5 |
503f74e511aa3b3dcdad4c1d583a59b6
|
|
| BLAKE2b-256 |
b1ca8a11d9af879ae2cfa9c659361b3477fdb65074b230ad5778c20616e57b01
|