Python SDK for IDaaS (Identity as a Service) AKless Adapter - Enables AK-free authentication for AWS services
Project description
cloud-idaas-akless-aws-adapter
简体中文 | English
Python SDK for IDaaS (Identity as a Service) AKless AWS Adapter — Enables AK-free authentication for AWS services using IDaaS PAM (Privileged Access Management) to obtain AWS STS temporary credentials.
How It Works
┌──────────┐ OIDC Token ┌──────────────┐ AWS STS Credentials ┌─────────────┐
│ IDaaS │ ──────────────► │ PAM │ ──────────────────────► │ AWS │
│ Core │ │ Developer │ (accessKeyId, │ Service │
│ SDK │ │ API │ secretAccessKey, │ (S3, etc.) │
└──────────┘ └──────────────┘ sessionToken) └─────────────┘
- The IDaaS Core SDK obtains an OIDC Token via machine-to-machine authentication
- This adapter sends the OIDC Token to the PAM Developer API to obtain AWS STS temporary credentials
- The temporary credentials are used to authenticate with AWS services (S3, DynamoDB, Lambda, EC2, SQS, etc.)
- Credentials are automatically cached and refreshed before expiration
Features
- AK-free Authentication: Eliminates the need for long-term AWS AccessKey, uses OIDC Token to obtain AWS STS temporary credentials via IDaaS PAM, reducing the risk of credential leakage
- AWS SDK Compatible: Provides
resolve_credentials()andget_boto3_session(), can be used with all AWS service clients (S3, DynamoDB, Lambda, EC2, SQS, etc.) - Automatic Credential Refresh: Built-in credential caching with stale-time and prefetch-time based automatic refresh, ensuring seamless credential rotation
- Simple Integration: Factory class provides one-line creation of credential providers, minimizing integration effort
Requirements
- Python >= 3.9
- Dependencies:
- cloud-idaas-core >= 0.0.5b0
- boto3 >= 1.26.0 (optional, required only for
get_boto3_session())
Installation
# Basic installation (resolve_credentials() only)
pip install cloud-idaas-akless-aws-adapter
# With boto3 support (for get_boto3_session())
pip install cloud-idaas-akless-aws-adapter[boto3]
Prerequisites
This SDK depends on cloud-idaas-core. You need to complete the IDaaS Core SDK initialization before using this adapter.
-
Install and configure
cloud-idaas-core, refer to cloud-idaas-core README for details. -
In the configuration file, set the
scopeto the IDaaS built-in scope for PAM:{ "scope": "urn:cloud:idaas:pam|.all" }
-
Complete the IDaaS Core SDK initialization:
from cloud_idaas.core import IDaaSCredentialProviderFactory IDaaSCredentialProviderFactory.init()
Quick Start
The simplest way to use this SDK is through the IDaaSPamAklessCredentialFactory factory class:
from cloud_idaas.core import IDaaSCredentialProviderFactory
from cloud_idaas.adapter.aws.pam import IDaaSPamAklessCredentialFactory
# 1. Initialize IDaaS Core SDK
IDaaSCredentialProviderFactory.init()
# 2. Create an AWS credentials provider
provider = IDaaSPamAklessCredentialFactory.get_aws_credentials_provider(
role_arn="your-role-arn"
)
# 3. Create a boto3 session and use any AWS service
session = provider.get_boto3_session(region_name="us-east-1")
s3 = session.client("s3")
print(s3.list_buckets())
Usage Examples
Amazon S3
from cloud_idaas.core import IDaaSCredentialProviderFactory
from cloud_idaas.adapter.aws.pam import IDaaSPamAklessCredentialFactory
# Initialize
IDaaSCredentialProviderFactory.init()
# Create credentials provider
provider = IDaaSPamAklessCredentialFactory.get_aws_credentials_provider(
role_arn="your-role-arn"
)
# Create boto3 session and S3 client
session = provider.get_boto3_session(region_name="us-east-1")
s3 = session.client("s3")
# List buckets
response = s3.list_buckets()
for bucket in response["Buckets"]:
print(f" {bucket['Name']} (created: {bucket['CreationDate']})")
Amazon DynamoDB
from cloud_idaas.core import IDaaSCredentialProviderFactory
from cloud_idaas.adapter.aws.pam import IDaaSPamAklessCredentialFactory
# Initialize
IDaaSCredentialProviderFactory.init()
# Create credentials provider
provider = IDaaSPamAklessCredentialFactory.get_aws_credentials_provider(
role_arn="your-role-arn"
)
# Create boto3 session and DynamoDB client
session = provider.get_boto3_session(region_name="us-east-1")
dynamodb = session.client("dynamodb")
# List tables
response = dynamodb.list_tables()
for table in response["TableNames"]:
print(f" Table: {table}")
Using resolve_credentials() Directly
For scenarios where you need raw credentials without boto3:
from cloud_idaas.adapter.aws.pam import IDaaSPamAklessCredentialFactory
provider = IDaaSPamAklessCredentialFactory.get_aws_credentials_provider(
role_arn="your-role-arn"
)
# Get raw credentials
creds = provider.resolve_credentials()
print(f"AccessKeyId: {creds.access_key_id}")
print(f"SecretAccessKey: {creds.secret_access_key}")
print(f"SessionToken: {creds.session_token}")
print(f"Expiration: {creds.expiration}")
Using Context Manager
from cloud_idaas.adapter.aws.pam import IDaaSPamAklessCredentialFactory
with IDaaSPamAklessCredentialFactory.get_aws_credentials_provider(
role_arn="your-role-arn"
) as provider:
session = provider.get_boto3_session(region_name="us-east-1")
s3 = session.client("s3")
print(s3.list_buckets())
Advanced Configuration
If you need to customize the endpoint, timeouts, or provide your own OIDC Token provider, use the constructor directly:
from cloud_idaas.adapter.aws.pam import IDaaSPamAwsCredentialsProvider
provider = IDaaSPamAwsCredentialsProvider(
developer_api_endpoint="https://your-pam-endpoint.example.com",
idaas_instance_id="your-instance-id",
oidc_token_provider=oidc_token_provider, # from Core SDK
role_arn="your-role-arn",
connect_timeout=3000,
read_timeout=8000,
)
API Reference
IDaaSPamAklessCredentialFactory
Factory class providing a static method to create credential providers. Automatically reads configuration from the Core SDK.
| Method | Return Type | Description |
|---|---|---|
get_aws_credentials_provider(role_arn) |
IDaaSPamAwsCredentialsProvider |
Creates a provider using Core SDK Factory configuration |
IDaaSPamAwsCredentialsProvider
Core credentials provider. Obtains AWS STS temporary credentials from the PAM Developer API using an OIDC Token, with automatic caching and refresh.
Constructor Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| developer_api_endpoint | str | Yes | - | PAM Developer API endpoint |
| idaas_instance_id | str | Yes | - | IDaaS instance ID |
| oidc_token_provider | OidcTokenProvider | Yes | - | OIDC Token provider from Core SDK |
| role_arn | str | Yes | - | Cloud Account Role ARN |
| connect_timeout | int | No | 5000 | Connection timeout in milliseconds |
| read_timeout | int | No | 10000 | Read timeout in milliseconds |
Methods
| Method | Return Type | Description |
|---|---|---|
resolve_credentials() |
AwsSessionCredentials |
Returns cached credentials (includes access_key_id, secret_access_key, session_token, expiration), auto-refreshes if expired |
get_boto3_session(**kwargs) |
boto3.Session |
Creates a boto3 session with current credentials (static snapshot, does not auto-refresh) |
close() |
None | Releases resources |
AwsSessionCredentials
Frozen dataclass returned by resolve_credentials().
| Field | Type | Description |
|---|---|---|
access_key_id |
str | AWS STS Access Key ID |
secret_access_key |
str | AWS STS Secret Access Key |
session_token |
str | AWS STS Session Token |
expiration |
Optional[datetime] | Credential expiration time (UTC) |
Support and Feedback
- Email: cloudidaas@list.alibaba-inc.com
- Issues: Please submit an Issue for questions or suggestions
License
This project is licensed under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 cloud_idaas_akless_aws_adapter-0.0.1b0.tar.gz.
File metadata
- Download URL: cloud_idaas_akless_aws_adapter-0.0.1b0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfd98c8410cf35b90eb7822633fea8d6cdfd665b7494fb6f6fedce2870ad489c
|
|
| MD5 |
ba53f2bff69fa7436e94db26b6bc62df
|
|
| BLAKE2b-256 |
e796c1aa245c30fa255e916f6d484b18491cb740e80a5dd40c7ef80b549c4ff0
|
Provenance
The following attestation bundles were made for cloud_idaas_akless_aws_adapter-0.0.1b0.tar.gz:
Publisher:
publish.yml on cloud-idaas/idaas-python-akless-aws-adapter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cloud_idaas_akless_aws_adapter-0.0.1b0.tar.gz -
Subject digest:
bfd98c8410cf35b90eb7822633fea8d6cdfd665b7494fb6f6fedce2870ad489c - Sigstore transparency entry: 2210446779
- Sigstore integration time:
-
Permalink:
cloud-idaas/idaas-python-akless-aws-adapter@7345b8d55e6e518057089eb84eb5c3e717eac215 -
Branch / Tag:
refs/tags/v0.0.1b0 - Owner: https://github.com/cloud-idaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7345b8d55e6e518057089eb84eb5c3e717eac215 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cloud_idaas_akless_aws_adapter-0.0.1b0-py3-none-any.whl.
File metadata
- Download URL: cloud_idaas_akless_aws_adapter-0.0.1b0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
066abf6d030be4793d720640bd9fa233d171472b8093ef72611861d8f56c94c6
|
|
| MD5 |
826273d9702781c1092d9e79e83bf020
|
|
| BLAKE2b-256 |
98bfb5cf64c4645669bec58a2e5a4576926336a4d5a84891a481bc486829f879
|
Provenance
The following attestation bundles were made for cloud_idaas_akless_aws_adapter-0.0.1b0-py3-none-any.whl:
Publisher:
publish.yml on cloud-idaas/idaas-python-akless-aws-adapter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cloud_idaas_akless_aws_adapter-0.0.1b0-py3-none-any.whl -
Subject digest:
066abf6d030be4793d720640bd9fa233d171472b8093ef72611861d8f56c94c6 - Sigstore transparency entry: 2210446812
- Sigstore integration time:
-
Permalink:
cloud-idaas/idaas-python-akless-aws-adapter@7345b8d55e6e518057089eb84eb5c3e717eac215 -
Branch / Tag:
refs/tags/v0.0.1b0 - Owner: https://github.com/cloud-idaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7345b8d55e6e518057089eb84eb5c3e717eac215 -
Trigger Event:
push
-
Statement type: