signed-request | Examples of parsing Facebook
kandi X-RAY | signed-request Summary
kandi X-RAY | signed-request Summary
Examples of parsing Facebook's signed_request
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of signed-request
signed-request Key Features
signed-request Examples and Code Snippets
Community Discussions
Trending Discussions on signed-request
QUESTION
I want to expand my software, written in JavaFX, with Amazon Chime API to consume its messaging. I know there's JS SDK that allows establish messaging websocket session with no problems. But in java SDK there're no related classes. So I want to use STOMP library to consuming the websocket endpoint.
At the time I am struggling with making correct request, namely with signing AWS request (calculating X-AMZ-Signature)
According to the post I'm trying to calculate correct X-AMZ-Signature request parameter. Here's the class:
...ANSWER
Answered 2021-Aug-26 at 12:56Wrote fully working code for signing URL for connecting to chime websocket. Hope this will helps somebody!
QUESTION
I am trying to generate a pre-signed web socket URL to get real time messaging notification for the AWS chime in the frontend as shown here . I planning to get this deployed as separate back end API using lambda. I followed exactly as shown here but I am getting "unauthorized" error when connecting to this generated URL in the front end. Can any one help me with what needs to be done to generate this pre-signed URL in python? I think I am using the wrong host/service parameters for chime.
...ANSWER
Answered 2021-May-02 at 17:55Any one who is wondering what the issue was- we have to pass the user_id_arn as arn%3Aaws%3Achime%3Aus-east-1%3A123456789012%3Aapp-instance%2f5abcdefg-cc50-4a70-a88e-fd07351d3c2a%2Fuser%2Fcustom-user-id
instead of arn:aws:chime:us-east-1:123456789012:app-instance/f5abcdefg-cc50-4a70-a88e-fd07351d3c2a/user/custom-user-id
Full working code:
QUESTION
I'm trying to generate a presigned link to API Gateway (that uses IAM authentication), so client may access one of my Lambda functions behind this API Gateway without authenticating request. This is mostly for client convenience, so it may use some links from response transparently, whether they points to the same authenticated API Gateway, some S3 bucket or any arbitrary URL in the Internet.
To do so, I crafting API signature v4 using query parameters (see docs and example)
So, if I try to sign following link scoped for us-west-2
region and execute-api
service:
ANSWER
Answered 2021-Apr-06 at 12:00This is a very interesting question!
At first, I thought it is clearly documented in the S3 docs that X-Amz-Expires
is supported by all services (including API Gateway). [1][2]
After some more research, it turned out that it is not so clear at all if services other than S3 support the X-Amz-Expires
parameter.
There are various sources claiming that only S3 is respecting the parameter. The following is a statement by an AWS employee working on the aws-sdk for go:
The expires time is only relevant for the S3 service. Other services have their own fixed expiration time. Generally this is 15 minutes, but it looks like IoT data service uses a 5 minute expiration time. [3]
They followed up with:
The SDK doesn't have any metadata data available providing which services do or do not use the expiry value. [4]
Then adding a note into the corresponding source code on GitHub:
All other AWS services will use a fixed expiration time of 15 minutes. [5]
There are a ton of examples that show that AWS is using the parameter for the S3 service, e.g. [1][6]. However, there are also examples from AWS docs that show the use of the parameter for the IAM service, e.g. [7][8]. That is very confusing.
There is a comment by an SDE at AWS which is dated back to 2018 in which he makes the same confusing observation [9]:
If S3 is the only service that supports this header I agree that the SDK's documentation should be updated to reflect that - including a note in the description for this header in S3's SigV4 documentation stating that this header is exclusive to presigned URLs for this service would also be helpful.
FWIW I spoke to some folks from AWS Auth and the only service they know of using the header is S3 (interesting that you found a code sample using IAM). They suggested that the 15 minute expiration for STS presigned URLs would not be changing.
Another former AWS employee further noticed:
I was able to reproduce this behavior both on the AWS SDKs for Go and PHP with presigned URLs for EC2, IAM, STS, and Route 53. The only service I observed that invalidated a presigned URL after the time specified in the "x-amz-expires" header (instead of the default 15 minutes) was S3.
Thus, I guess it is not possible to increase pre-signed link validity duration for API Gateway access. I think that AWS did not design the signature signing algorithm to support your use case. I think that the S3 presigned URL action is one of the rare exceptions for which AWS allows an extended expiry period.
When looking at their motivation behind creating the signing algorithm the way it is, I noticed that they try to minimize the attack surface for replay attacks:
Protect against potential replay attacks
In most cases, a request must reach AWS within five minutes of the time stamp in the request. Otherwise, AWS denies the request. [10]
There are some more resources [11][12] that lead to the conclusion that letting customers choose lengthy expiry values would undermine the original security purpose of that parameter.
I think there is no generic way to create a presigned URL towards an AWS service's REST API and execute it far in the future.
If I were in your place, I would implement a custom authentication strategy using JWTs and API Gateway Lambda authorizers. [13] That way you can control the signing algorithm and particulary its expiration time on your own. I want to add that JWTs are URL-safe in the same way AWS signature query string parameters are. [14]
[1] https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
[2] https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html
[3] https://github.com/aws/aws-sdk-go/issues/2304#issuecomment-441755864
[4] https://github.com/aws/aws-sdk-go/issues/2304#issuecomment-441758599
[5] https://github.com/aws/aws-sdk-go/blob/6212dfa8032336d438c526c086918c8d2ceb6432/aws/request/request.go#L310
[6] https://github.com/mhart/aws4/blob/master/aws4.js#L130
[7] https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
[8] https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html
[9] https://github.com/aws/aws-sdk-go/issues/2167#issuecomment-428764319
[10] https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html
[11] https://aws.amazon.com/de/articles/making-secure-requests-to-amazon-web-services/?nc1=h_ls (section "Replay Attacks")
[12] https://stackoverflow.com/a/12267408/10473469
[13] https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
[14] https://stackoverflow.com/a/56273952/10473469
QUESTION
I'm trying to create [1] AWS V4 signed URLs to download files stored in a ScaleWay Object Storage bucket. I used the python example from AWS's [2] site and modified it but I can't make it work. When I try to access the generated link, I get a 403 response [3] which you can see below.
I copy my python script [4] here that produces the 403 links.
Could you please take a look at it and let me know what I did wrong? Why can't I generate the proper signature?
[1]: A URL that was generated by the [4] python script: https://laboschqpa.s3.pl-waw.scw.cloud/1SorNemSorCpp.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=%2F20210120%2Fpl-waw%2Fs3%2Faws4_request&X-Amz-Date=20210120T011857Z&X-Amz-Expires=3000&X-Amz-SignedHeaders=host&X-Amz-Signature=8ff4a56eef6dbd555a9b92ce2ac291488fabc6cb97b26711b6eeebfb0052ce15
[2]: The python example on AWS's site: https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html#sig-v4-examples-get-query-string
[3]: The 403 response I get from the scaleway API when accessing my generated link: SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your key and signing method.txb1179690b7a94d92a899a-0060035729
[4]: The python script that I try to generate links with:
...ANSWER
Answered 2021-Jan-21 at 00:36If you use a GET request, you shouldn't use the hash of an empty string (like it is told in the official example) for the canonical request but the raw "UNSIGNED-PAYLOAD" string.
As an example:
Your canonical request will look like this:
QUESTION
ANSWER
Answered 2020-Oct-17 at 13:26I am posting the correct final version of my code in case anyone is facing similar issue. Three things were wrong in my original code.
- X_AMZ_DATE (YYYYMMDDTHHMMSSZ) didn't use it in HEADERS and STRING_TO_SIGN. Hence, was getting
Signature expired
error. - SERVICE I thought would be iot but it is iotdata.
Credential should be scoped to correct service
error was resolved. - CANONICAL_URI should only contain part after the domain and before query parameters. Eg. If request URI is
https://foo.bar.baz.com/foo1/foo2/foo3?bar1=baz1&bar2=baz2
then CANONICAL_URI ="/foo1/foo2/foo3"
QUESTION
I am working with the AWS Transcribe streaming service that boto3 does not support yet, so to make HTTP/2 requests, I need to manually setup the authorization
header with the "AWS Signature Version 4"
I've found some example implementation, but I was hoping to just call whatever function boto3/botocore have implemented using the same configuration object.
Something like
...ANSWER
Answered 2020-Jul-29 at 16:30I have not tested this, but you can likely accomplish this by following along with with this SigV4 unit test:
https://github.com/boto/botocore/blob/master/tests/unit/test_auth_sigv4.py
Note, this constructs a request using the botocore.awsrequest.AWSRequest
helper. You'll likely need to dig around to figure out how to send the actual HTTP request (perhaps with httpsession.py)
QUESTION
I'm developing several AWS serverless applications using Lambda and API gateway.
At one point, I tried to execute an API request on one application (using requests python lib) from code running inside a Lambda function in another application. I get 500 server error. From the logs it appears that the Lambda function behind the API gateway is not starting at all. I don't find any logs that can tell me what happened.
Additional details:
- The API gateway is protected by IAM auth.
- The calling lambda has permission to "execute_api"
- The request is signed according to Signature V4 - I followed the example here: https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html#sig-v4-examples-post .
ANSWER
Answered 2020-Jul-30 at 13:14The issue was that the calling lambda needed permission to execute the second lambda behind the API gateway. I don't know why that is. I also still don't know how I should have debugged this - where are the logs that should tell me what was the issue. Eventually it was a lucky guess on my side.
QUESTION
I am trying to develop a follow up on this AWS request: https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
It works when you do it "as-is", but I'm trying to send a SMS from that script, and keep on getting "signature mismatch" response (HTTP 403):
...ANSWER
Answered 2020-Jun-08 at 07:55Got it! The "request_parameters" string has an order to it, where Version should go at the end.
QUESTION
I am getting Invalid Request with below error message when trying to retrieve secret value using AWS secrets manager REST API GetSecretValue
I followed the steps given here (https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html#sig-v4-examples-post) to sign the request using sigv4.
My code looks like below:
...ANSWER
Answered 2020-May-18 at 01:00Order Matters
Both canonical_headers
and signed_headers
should be sorted. From your link:
Create the canonical headers. Header names must be trimmed and lowercase, and sorted in code point order from low to high.
and
Create the list of signed headers. This lists the headers in the canonical_headers list, delimited with ";" and in alpha order.
This implies that x-amz-security-token
must come before x-amz-target
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install signed-request
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page