Last active
March 13, 2018 04:38
-
-
Save patrickbrandt/4d8297cd2314d9737e714dd702b5c7fc to your computer and use it in GitHub Desktop.
Revisions
-
patrickbrandt revised this gist
Jan 13, 2017 . 1 changed file with 1 addition and 0 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 @@ -7,6 +7,7 @@ def ping(event, context): print('two different referring IP address parsing techniques ip1: %s and ip2: %s') % (ip1, ip2) referringIP = event['requestContext']['identity']['sourceIp'] #TODO: use a comma-delimited string to store multiple IP address values in the environment variable if (os.environ['IP_WHITELIST'] != referringIP): return { 'statusCode': 401, -
patrickbrandt revised this gist
Jan 13, 2017 . No changes.There are no files selected for viewing
-
patrickbrandt created this gist
Jan 13, 2017 .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,19 @@ import json import os def ping(event, context): ip1 = event['headers']['X-Forwarded-For'].split(',')[0] ip2 = event['requestContext']['identity']['sourceIp'] print('two different referring IP address parsing techniques ip1: %s and ip2: %s') % (ip1, ip2) referringIP = event['requestContext']['identity']['sourceIp'] if (os.environ['IP_WHITELIST'] != referringIP): return { 'statusCode': 401, 'body': 'This IP address is not allowed %s' % referringIP } return { 'statusCode': 200, 'body': 'This IP address is allowed %s' % referringIP } 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,18 @@ service: ip-restrict provider: name: aws runtime: python2.7 stage: dev region: us-west-2 profile: ko-playground-admin environment: IP_WHITELIST: "44.99.53.83" functions: ping: handler: handler.ping events: - http: path: ping method: GET