feat: accept signed s3 objects for s3 file keys in apps + sign endpoint and helpers

This commit is contained in:
HugoCasa
2025-04-09 18:02:03 +02:00
parent e4d57f9549
commit 0eff6b139d
6 changed files with 189 additions and 32 deletions

View File

@@ -586,6 +586,9 @@ class Windmill:
raise Exception("Could not write file to S3") from e
return S3Object(s3=response["file_key"])
def sign_s3_objects(self, s3_objects: list[S3Object]) -> list[str]:
return self.post(f"/w/{self.workspace}/apps/sign_s3_objects", json={"s3_objects": s3_objects}).json()
def __boto3_connection_settings(self, s3_resource) -> Boto3ConnectionSettings:
endpoint_url_prefix = "https://" if s3_resource["useSSL"] else "http://"
return Boto3ConnectionSettings(
@@ -974,6 +977,15 @@ def write_s3_file(
return _client.write_s3_file(s3object, file_content, s3_resource_path if s3_resource_path != "" else None, content_type, content_disposition)
@init_global_client
def sign_s3_objects(s3_objects: list[S3Object]) -> list[str]:
"""
Sign S3 objects to be used by anonmous users in public apps
Returns a list of signed s3 tokens
"""
return _client.sign_s3_objects(s3_objects)
@init_global_client
def whoami() -> dict:
"""