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 loggingS2IAM_IDENTITY_FORMAT_PREFERENCE: Comma-separated, ordered list of preferred identity formats (e.g.aws-iam-role-arn,aws-arn). See Identity format preferences
Identity format preferences
Clients may select the issued identity representation (the JWT sub) by passing an ordered identity_format_preference list; the verifier picks the first form it supports and reports the choice in the response identityFormat field. See the main README for the full vocabulary, the default ordering, and semantics.
The built-in default names every provider, so the identity is pinned by the client and cannot move if a verifier operator changes the server-side default ordering: ["aws-iam-role-arn", "aws-arn", "gcp-sa-email", "gcp-sa-unique-id", "azure-object-id"]. For AWS that means the session-stripped base IAM role ARN, falling back to the raw ARN for callers that are not an assumed-role session. Request "aws-arn" for the session-bearing raw STS ARN instead:
jwt = await get_jwt_database(
"workspace-id",
identity_format_preference=["aws-arn"],
)
Precedence is explicit argument > S2IAM_IDENTITY_FORMAT_PREFERENCE > built-in default.
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.
Metadata
Release files for singlestore-auth-iam 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| singlestore_auth_iam-0.6.2.tar.gz | 47.7 kB | With provenance | Details for singlestore_auth_iam-0.6.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| singlestore_auth_iam-0.6.2-py3-none-any.whl | Python 3 | none | any | Details for singlestore_auth_iam-0.6.2-py3-none-any.whl |
Total release size: 79.8 kB
Release files / singlestore_auth_iam-0.6.2.tar.gz
| Download URL | singlestore_auth_iam-0.6.2.tar.gz |
|---|---|
| Size | 47.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85b4800d86502890a7dc61fdade0386707faf73933bd2b598361b65703e6e0dc
|
|
BLAKE2b-256 checksum How to use checksums |
0e3a02eaeca64237ea4fcbb15e6bb8e5c29708164a702b5cb3218561e473790b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / singlestore_auth_iam-0.6.2-py3-none-any.whl
| Download URL | singlestore_auth_iam-0.6.2-py3-none-any.whl |
|---|---|
| Size | 32.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a87555c3a7325cce3791e6b560a0ab19bc0b0b85607fd5b65dcabad76a03c622
|
|
BLAKE2b-256 checksum How to use checksums |
c73ddf3495a143457c511e880fe873052c15596626652ddcd001ef0174e99349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logSecurity for singlestore-auth-iam 0.6.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for singlestore_auth_iam-0.6.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.