-
Notifications
You must be signed in to change notification settings - Fork 23
Problem with sessionToken handling #12
Comments
I just ran into the same issue trying to generate an signed STS request. Chain of events went like this:
I'm not exactly sure how the session token signing is supposed to be handled, on lines 193-197 we add it before generating signatures. // when a session token must be "signed" into the canonical request
// (needed for some services, such as s3)
if (options.sessionToken && options.signSessionToken) {
query["X-Amz-Security-Token"] = options.sessionToken;
} But then on line 222-228 it gets removed from the params. // when a session token must NOT be "signed" into the canonical request
// (needed for some services, such as IoT)
if (options.sessionToken && !options.signSessionToken) {
query["X-Amz-Security-Token"] = options.sessionToken;
} else {
delete query["X-Amz-Security-Token"];
} @slaskis would you be able to chime in here? I'd love to get a fix out so I can switch to using the upstream repo vs my personal fork. |
Continue to supply session token when included as part of signature. See department-stockholm#12
I could be mistaken, but I think line 224 is incorrect. Except in the case of a shared secret, all other parts of the signature input must be visible to both sides in order to calculate the same signature. Line 224 would omit the if (options.sessionToken && options.signSessionToken) { |
Maybe related: I am using the package in a Lambda to create a presigned URL for S3. I'm not authenticating with the same credentials as the Lambda is using (which is what is in the environment vars), but rather using an access key and secret key that are returned in a DB query. In order to make it work I had to For reference for others, this is what worked: delete process.env.AWS_SESSION_TOKEN;
let url = v4.createPresignedS3URL(
'Foldername/filename.png',
{
key: config['AwsAccessKey'],
secret: config['AwsSecretKey'],
bucket: process.env.bucketName
}
); |
Hi,
I've been trying to sign an 'execute-api' request to API Gateway using temporary IAM credentials (using 1.4.0). It wasn't working, so I dug into the code to see how the sessionToken is being used. I tried with both signSessionToken set to true and false, but neither worked. I noticed that if it was set to true, you'd delete query["X-Amz-Security-Token"] (line 227) before building the query string. Commenting out this line (so that the sessionToken would still appear in the query string) made it work.
-Ben
The text was updated successfully, but these errors were encountered: