-
-
Save sjmach/0c1572aab5d682ce490c96462190e54a to your computer and use it in GitHub Desktop.
Revisions
-
JeremyPlease revised this gist
Jan 7, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const AWS = require('aws-sdk') // load CloudFront key pair from environment variables // Important: when storing your CloudFront private key as an environment variable string, // you'll need to replace all line breaks with \n, like this: // CF_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIE...1Ar\nwLW...2eL\nFOu...k2E\n-----END RSA PRIVATE KEY-----" const cloudfrontAccessKeyId = process.env.CF_ACCESS_KEY_ID const cloudFrontPrivateKey = process.env.CF_PRIVATE_KEY const signer = new AWS.CloudFront.Signer(cloudfrontAccessKeyId, cloudFrontPrivateKey) -
JeremyPlease revised this gist
Jul 7, 2018 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,12 @@ const AWS = require('aws-sdk') // load CloudFront key pair from environment variables // Important: when storing your CloudFront private key as an environment variable string, // you'll need to replace all line breaks with \n, like this: // CF_PRIVATE_KEY='-----BEGIN RSA PRIVATE KEY-----\nMIIE...1Ar\nwLW...2eL\nFOu...k2E\n-----END RSA PRIVATE KEY-----' const cloudfrontAccessKeyId = process.env.CF_ACCESS_KEY_ID const cloudFrontPrivateKey = process.env.CF_PRIVATE_KEY const signer = new AWS.CloudFront.Signer(cloudfrontAccessKeyId, cloudFrontPrivateKey) // 2 days as milliseconds to use for link expiration const twoDays = 2*24*60*60*1000 -
JeremyPlease revised this gist
Jul 7, 2018 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,19 @@ // load the AWS SDK const AWS = require('aws-sdk') // load CloudFront key pair from environment variables const cloudfrontAccessKeyId = process.env.CF_ACCESS_KEY_ID const cloudFrontPrivateKey = process.env.CF_PRIVATE_KEY const signer = new AWS.CloudFront.Signer(cloudfrontAccessKeyId, process.env.CLOUDFRONT_KEY) // 2 days as milliseconds to use for link expiration const twoDays = 2*24*60*60*1000 // sign a CloudFront URL that expires 2 days from now const signedUrl = signer.getSignedUrl({ url: 'https://248hf0w8hs.cloudfront.net/secret-image.jpg', expires: Math.floor((Date.now() + twoDays)/1000), // Unix UTC timestamp for now + 2 days }) // signedUrl is now a signed CloudFront URL: // https://248hf0w8hs.cloudfront.net/secret-image.jpg?Expires=1531165045&Key-Pair-Id=HDIWEUY39S87XHCJDJUQODJ20AL&Signature=0SGI2...K2JHID__ -
JeremyPlease revised this gist
Jul 7, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ const AWS = require('aws-sdk') const cloudfrontAccessKeyId = process.env.CF_ACCESS_KEY_ID const cloudFrontPrivateKey = process.env.CF_PRIVATE_KEY const cloudfrontUrl = 'https://248hf0w8hs.cloudfront.net/' const twoDays = 2*24*60*60*1000 -
JeremyPlease created this gist
Jul 7, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ const AWS = require('aws-sdk') const cloudfrontAccessKeyId = process.env.CF_ACCESS_KEY const cloudFrontPrivateKey = process.env.CF_PRIVATE_KEY const cloudfrontUrl = 'https://248hf0w8hs.cloudfront.net/' const twoDays = 2*24*60*60*1000 const signer = new AWS.CloudFront.Signer(cloudfrontAccessKeyId, process.env.CLOUDFRONT_KEY) const signedUrl = signer.getSignedUrl({ url: 'https://248hf0w8hs.cloudfront.net/secret-image.jpg', expires: Math.floor((Date.now() + twoDays)/1000), // Unix UTC timestamp }) // signedUrl is now a signed CloudFront URL like: // https://248hf0w8hs.cloudfront.net/secret-image.jpg?Expires=1531165045&Key-Pair-Id=HDIWEUY39S87XHCJDJUQODJ20AL&Signature=0SGI2...K2JHID__