This file contains 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 characters
'use strict'; | |
var jwt = require('jsonwebtoken'); | |
var jwkToPem = require('jwk-to-pem'); | |
var USERPOOLID = '##USERPOOLID##'; | |
var JWKS = '##JWKS##'; | |
var COGNITOREGION = '##COGNITOREGION##'; | |
var iss = 'https://cognito-idp.' + COGNITOREGION + '.amazonaws.com/' + USERPOOLID; | |
var pems; |
This file contains 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 characters
# Need to install DNS package | |
import dns.resolver | |
def lambda_handler(event, context): | |
request = event['Records'][0]['cf']['request'] | |
res = dns.resolver.query("latency-cross-region.example.com", "txt") | |
buff = res[0].to_text().replace('"', '').split(";") | |
bucket_name = buff[0] | |
region = buff[1] | |
domainName = f"{bucket_name}.s3.{region}.amazonaws.com" | |
request['origin']['s3']['domainName'] = domainName |
This file contains 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 characters
function handler(event) { | |
var response = event.response; | |
var headers = response.headers; | |
headers['strict-transport-security'] = { value: 'max-age=63072000; includeSubdomains; preload'}; | |
headers['content-security-policy'] = { value: "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'"}; | |
headers['x-content-type-options'] = { value: 'nosniff'}; | |
headers['x-frame-options'] = {value: 'DENY'}; | |
headers['x-xss-protection'] = {value: '1; mode=block'}; | |
headers['access-control-allow-origin'] = {value: "*"}; |
This file contains 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 characters
const crypto = require('crypto'); | |
function hashText(input) { | |
return crypto.createHash('md5').update(input).digest('hex'); | |
} | |
function handler(event) { | |
var request = event.request; | |
var headers = request.headers; |
This file contains 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 characters
function handler(event) { | |
var request = event.request; | |
var supportedCountries = ['de', 'it', 'fr']; | |
if (request.uri.substr(3, 1) != '/') { | |
var headers = request.headers; | |
var nextUri; | |
if (headers['cloudfront-viewer-country']) { | |
var countryCode = headers['cloudfront-viewer-country'].value.toLowerCase(); |
This file contains 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 characters
### Keybase proof | |
I hereby claim: | |
* I am arthurknoep on github. | |
* I am needlex (https://keybase.io/needlex) on keybase. | |
* I have a public key ASBfryd_koswiTQB6Ul15YFKIDfS1VtPQ0ueUrJKAhh14go | |
To claim this, I am signing this object: |