Comments (5)
Working example of how to get presigned url to download a s3 object (using the changes in the PR)
def signed_uri(reference, ttl) do
%{
remote_storage_bucket: remote_storage_bucket,
access_key_id: access_key_id,
remote_storage_region: remote_storage_region
} = aws_config()
uri =
URI.parse(
"https://#{remote_storage_bucket}.s3.#{remote_storage_region}.#{aws_client().endpoint}/#{AWS.Util.encode_uri(reference, true)}"
)
now = NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)
long_date = NaiveDateTime.to_iso8601(now, :basic) <> "Z"
short_date = Date.to_iso8601(now, :basic)
query_params = [
{"X-Amz-Expires", Integer.to_string(ttl)},
{"X-Amz-Algorithm", "AWS4-HMAC-SHA256"},
{"X-Amz-Credential",
"#{access_key_id}/#{short_date}/#{remote_storage_region}/s3/aws4_request"},
{"X-Amz-SignedHeaders", "host"},
{"X-Amz-Date", long_date}
]
url = URI.to_string(%{uri | query: URI.encode_query(query_params)})
signature_tuple =
%{aws_client() | service: "s3"}
|> AWS.Signature.sign_v4_query(now, :get, url, [{"Host", uri.host}], nil)
|> Enum.find(fn {key, _value} -> key == "X-Amz-Signature" end)
URI.to_string(%{
uri
| query: URI.encode_query([signature_tuple | query_params])
})
end
from aws-elixir.
Thanks for maintaining this lib @philss, Wish I knew some erlang to help on the aws-beam/aws_signature side
from aws-elixir.
I think a very simple fix like #88 could made the AWS.Signature.sign_v4_query/6
work for this use case
from aws-elixir.
We could also update test/aws/signature_test.exs
sign_v4_query/6 test, since it seems to be target to the same use case. We need to add data to the query string instead of headers
from aws-elixir.
Hi @ceolinrenato 👋
Thank you for opening the issue and the PR. Unfortunately we just removed the signature part from this library. The idea is to keep signature features in https://github.com/aws-beam/aws_signature and share that lib with the generated packages (aws-elixir and aws-erlang).
I think we can support this feature in that lib too.
I'm closing the issue and the PR, but I have opened a new issue there: aws-beam/aws_signature#4
Thanks again!
from aws-elixir.
Related Issues (20)
- AWS.ApiGatewayManagementApi, URL and headers with stage HOT 1
- S3 put_object returns {:error, :timeout} but uploads file correctly HOT 5
- `AWS.S3.delete_objects` content md5 header HOT 5
- SelectObjectContent response HOT 1
- `AWS.STS.assume_role_with_web_identity` should not rely on access_key_id and secret_access_key
- Error calling textractor HOT 3
- Setting endpoint to `amazonaws.com` results in different behaviour as not setting an endpoint HOT 1
- AWS.S3.get_object always returns {:error, :timeout} with hackney > 1.18.1 HOT 5
- Streaming response handling HOT 10
- `put_bucket_cors` request is incorrect HOT 5
- Setup pipeline to automatically roll out new releases upon tagging
- S3 ListParts returns wrong types HOT 7
- QLDB Commit Transaction HOT 2
- NXDOMAIN when calling CostExplorer.get_cost_and_usage HOT 5
- Cannot get AWS Polly synthesize_speech to work HOT 3
- :nxdomain when calling AWS.CloudFront.list_distributions HOT 5
- Wrong region for Route53 requests HOT 12
- AWS.TimestreamWrite does not work. HOT 5
- Support array member names
- New spec is specific to keys in requests being strings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-elixir.