SingleStore IAM authentication library for cloud providers
Project description
SingleStore Auth IAM - Python Client Library
A Python client library for getting JWTs from SingleStore's IAM service when running in cloud environments (AWS, GCP, Azure).
Installation
pip install singlestore-auth-iam
Quick Start
import asyncio
from s2iam import get_jwt_database
async def main():
# Get a JWT for database access
jwt = await get_jwt_database("your-workspace-group-id")
print(f"JWT: {jwt}")
# Or without workspace group ID
jwt = await get_jwt_database()
print(f"JWT: {jwt}")
if __name__ == "__main__":
asyncio.run(main())
For API gateway access:
import asyncio
from s2iam import get_jwt_api
async def main():
# Get a JWT for API gateway access
jwt = await get_jwt_api()
print(f"JWT: {jwt}")
if __name__ == "__main__":
asyncio.run(main())
That's it! The library automatically detects your cloud environment and gets the appropriate JWT.
Configuration
Environment Variables
S2IAM_SERVER_URL: Custom authentication server URL (default: https://auth.singlestore.com)S2IAM_DEBUGGING: Set to "true" to enable debug logging
Supported Environments
The library automatically detects and works in:
- AWS: EC2 instances, Lambda functions, ECS tasks
- Google Cloud: Compute Engine, Cloud Functions, Cloud Run
- Azure: Virtual Machines, Functions, Container Instances
Error Handling
from s2iam import get_jwt_database, CloudProviderNotFound
try:
jwt = await get_jwt_database("workspace-id")
except CloudProviderNotFound:
print("Not running in a supported cloud environment")
Configuration
Workspace Group ID
The workspace_group_id parameter is optional for get_jwt_database(). When provided, it scopes the JWT to a specific workspace group. When omitted (or None), the JWT may have broader access depending on your SingleStore configuration.
Environment Variables
S2IAM_DEBUGGING: Set to "true" to enable debug loggingS2IAM_SERVER_URL: Custom authentication server URL (default: https://auth.singlestore.com)
Provider-Specific Configuration
AWS
- Uses standard AWS SDK configuration (AWS_REGION, AWS_PROFILE, etc.)
- Supports IAM roles, EC2 instance profiles, and Lambda execution roles
GCP
- Uses Application Default Credentials (ADC)
- Supports service account impersonation via
GCE_METADATA_HOST
Azure
- Uses Azure SDK configuration
- Supports managed identities and service principals
API Reference
Core Functions
detect_provider(timeout=5.0, logger=None, clients=None)
Automatically detect which cloud provider the application is running on.
Parameters:
timeout(float): Detection timeout in secondslogger(Logger): Custom logger instanceclients(List[CloudProviderClient]): Custom list of provider clients
Returns: CloudProviderClient
get_jwt(jwt_type, workspace_group_id=None, server_url=None, **kwargs)
Get a JWT from SingleStore's authentication service.
Parameters:
jwt_type(JWTType): Type of JWT to requestworkspace_group_id(str): Workspace group IDserver_url(str): Authentication server URL**kwargs: Additional provider-specific parameters
Returns: str (JWT)
Cloud Provider Clients
All provider clients implement the CloudProviderClient interface:
Methods
detect(): Test if running on this cloud providerget_type(): Get the provider typeassume_role(role_identifier): Assume a different role/identityget_identity_headers(additional_params=None): Get authentication headers
Models
CloudIdentity
Represents verified identity information:
@dataclass
class CloudIdentity:
provider: CloudProviderType
identifier: str
account_id: str
region: str
resource_type: str
additional_claims: Dict[str, str]
CloudProviderType
Enum of supported cloud providers:
AWSGCPAZURE
JWTType
Enum of JWT types:
DATABASE_ACCESSAPI_GATEWAY_ACCESS
Error Handling
The library defines several specific exceptions:
CloudProviderNotFound: No cloud provider could be detectedProviderNotDetected: Provider not detected, calldetect()firstProviderIdentityUnavailable: Provider detected but no identity availableAssumeRoleNotSupported: Assume role not supported by provider
Development
Testing
Tests use the Go test server (s2iam_test_server) started with the new --info-file flag for deterministic startup (no stdout JSON parsing). Async tests require pytest-asyncio which is part of the dev extras.
# Install with dev dependencies
pip install -e .[dev]
# Run full test suite (cloud‑dependent tests skip outside cloud VMs)
pytest
# Coverage
pytest --cov=s2iam --cov-report=html
# Example: Just integration tests
pytest -k integration
Manual server run example (atomic startup):
go build -o s2iam_test_server ../go/cmd/s2iam_test_server
tmpfile=$(mktemp)
./s2iam_test_server --port=0 --info-file "$tmpfile" --shutdown-on-stdin-close &
while [ ! -s "$tmpfile" ]; do sleep 0.05; done
jq . "$tmpfile"
Code Quality
# Format
black src tests
isort src tests
# Static checks
flake8 src tests
mypy src
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for your changes
- Run the test suite
- Submit a pull request
Support
For issues and questions, please use the GitHub Issues page.
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 singlestore_auth_iam-0.5.0.tar.gz.
File metadata
- Download URL: singlestore_auth_iam-0.5.0.tar.gz
- Upload date:
- Size: 40.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb33fb9297262ccf33a33d8cfcd35fbf19f3ac366f0546a34c2c2afd6f0e1e37
|
|
| MD5 |
020cb0d59b029a80066f9dfbc589b589
|
|
| BLAKE2b-256 |
7567a3c7bb3b81d6e030c2b5f63d7ca332dec81da55be776f4aed9a2ff0257e0
|
Provenance
The following attestation bundles were made for singlestore_auth_iam-0.5.0.tar.gz:
Publisher:
publish-pypi.yml on singlestore-labs/singlestore-auth-iam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
singlestore_auth_iam-0.5.0.tar.gz -
Subject digest:
bb33fb9297262ccf33a33d8cfcd35fbf19f3ac366f0546a34c2c2afd6f0e1e37 - Sigstore transparency entry: 1842217820
- Sigstore integration time:
-
Permalink:
singlestore-labs/singlestore-auth-iam@7d5e742e3455ffdebecedfed27a66f55a2b8c8da -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/singlestore-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7d5e742e3455ffdebecedfed27a66f55a2b8c8da -
Trigger Event:
push
-
Statement type:
File details
Details for the file singlestore_auth_iam-0.5.0-py3-none-any.whl.
File metadata
- Download URL: singlestore_auth_iam-0.5.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3034603ecb8f270b0eee8cf16738652c7fde9c2fc9b06437b4b6c78e37743907
|
|
| MD5 |
5160ee646514f535aaf44d89757ecdd7
|
|
| BLAKE2b-256 |
752ab13c39d4308ae8ea9756156f3c80f14635a9d5f4e6b795f93560588c8111
|
Provenance
The following attestation bundles were made for singlestore_auth_iam-0.5.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on singlestore-labs/singlestore-auth-iam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
singlestore_auth_iam-0.5.0-py3-none-any.whl -
Subject digest:
3034603ecb8f270b0eee8cf16738652c7fde9c2fc9b06437b4b6c78e37743907 - Sigstore transparency entry: 1842217916
- Sigstore integration time:
-
Permalink:
singlestore-labs/singlestore-auth-iam@7d5e742e3455ffdebecedfed27a66f55a2b8c8da -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/singlestore-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7d5e742e3455ffdebecedfed27a66f55a2b8c8da -
Trigger Event:
push
-
Statement type: