简体   繁体   English

如何使用python在aws s3的预签名url中隐藏我的访问密钥

[英]how can I hide my access key in pre-signed url by aws s3 using python

I am generating pre-signed url on aws s3 using python.我正在使用 python 在 aws s3 上生成预签名的 url。 ater generating it shows my access key in the url.在生成它之后,它会在 url 中显示我的访问密钥。 how can I generate url with showing my access key?如何通过显示我的访问密钥生成 url?

https://console.wasabisys.com/testing-usman/?AWSAccessKeyId=https://console.wasabisys.com/testing-usman/?AWSAccessKeyId=

This is the code i am using:这是我正在使用的代码:

s3 = boto3.client('s3',
endpoint_url = 'https://console.wasabisys.com',
aws_access_key_id = '<4XR7DSJX1MYFYXETUGBA>',
aws_secret_access_key = '<8aD49ac2cJsuWr7crjRTAN0jqH4JzyV6uQwhJyw1>')

url = s3.generate_presigned_url(
ClientMethod='get_object',
Params={
    'Bucket': 'testing-usman',
    'Key': '.'  

   }
)
print(url)

I need the url without showing my access key.我需要 url 而不显示我的访问密钥。

You need to provide a credential to aws, so to looks less explicit you can add to the boto3 client a config:您需要向 aws 提供凭证,因此为了看起来不那么明确,您可以向 boto3 客户端添加一个配置:

from botocore.client import Config

s3 = boto3.client('s3',
config=Config(signature_version='s3v4'),
endpoint_url = 'https://console.wasabisys.com',
aws_access_key_id = '<4XR7DSJX1MYFYXETUGBA>',
aws_secret_access_key = '<8aD49ac2cJsuWr7crjRTAN0jqH4JzyV6uQwhJyw1>')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在不使用预签名URL的情况下访问私有s3存储桶对象? (boto3,python) - Is it possible to access a private s3 bucket objects without using a pre-signed URL? (boto3, python) 如何使用boto3中的预签名URL从S3获取对象? - How do I get an object from S3 using it's pre-signed url in boto3? S3 Object 使用预签名的 URL 上传到私有存储桶导致访问被拒绝 - S3 Object upload to a private bucket using a pre-signed URL result in Access denied 无法使用S3预签名网址上传原始字符串(csv或json) - Can't upload raw string (csv or json) using S3 pre-signed url 无论我做什么,都无法使用预签名的 URL 将文件上传到 S3。 AWS 命令行有效。 CURL 和其他任何东西 = 403 - Can't upload a file to S3 with pre-signed URL no matter what I do. AWS command line works. CURL and anything else = 403 使用预先签名的POST URL将文件上载到AWS S3时设置随机文件名 - Set random file name when upload file to AWS S3 with pre-signed POST url 使用Boto S3生成预签名URL时参数的含义 - Meanings of parameters when generating pre-signed URL using boto S3 S3 文件访问在使用预签名 url boto3 调用 create_presigned_post() 上传时被拒绝 - S3 File Access Denied when uploaded with pre-signed url boto3 call create_presigned_post() S3:S3 预签名 url 在有效期内的 ExpiredToken 错误 - S3: ExpiredToken error for S3 pre-signed url within expiry period 如何在没有预签名 URL 的情况下将 html 文件输入到 S3 - How to approach html file inputs to S3 without pre-signed URLs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM