diff --git a/examples/ridge_bcrypt/Makefile b/examples/ridge_bcrypt/Makefile new file mode 100644 index 0000000..dcf4032 --- /dev/null +++ b/examples/ridge_bcrypt/Makefile @@ -0,0 +1,24 @@ +s3_bucket=temp-$(profile) +stack_name ?= juni-ridge +sam_template_base=sam +sam_template=$(sam_template_base).yml +sam_output=$(sam_template_base)-new.yml + + +build: + juni build + +package: + sam package \ + --s3-bucket $(s3_bucket) \ + --template-file $(sam_template) \ + --output-template-file ./dist/$(sam_output) \ + --profile $(profile) + +deploy: package + sam deploy \ + --template-file ./dist/$(sam_output) \ + --stack-name $(stack_name) \ + --capabilities CAPABILITY_IAM \ + --region us-east-1 \ + --profile $(profile) diff --git a/examples/ridge_bcrypt/lambda_function.py b/examples/ridge_bcrypt/lambda_function.py new file mode 100644 index 0000000..ae818a7 --- /dev/null +++ b/examples/ridge_bcrypt/lambda_function.py @@ -0,0 +1,13 @@ +import bcrypt + + +def lambda_handler(event, context): + password = b"super secret password" + # Hash a password for the first time, with a randomly-generated salt + hashed = bcrypt.hashpw(password, bcrypt.gensalt()) + # Check that an unhashed password matches one that has previously been + # hashed + if bcrypt.checkpw(password, hashed): + return {"value": "It Matches!"} + + return {"value": "It Does not Match :("} diff --git a/examples/ridge_bcrypt/manifest.yml b/examples/ridge_bcrypt/manifest.yml new file mode 100644 index 0000000..1405c99 --- /dev/null +++ b/examples/ridge_bcrypt/manifest.yml @@ -0,0 +1,11 @@ + +functions: + sample: + requirements: ./requirements/base.txt + include: + - ./lambda_function.py + +layers: + + bcrypt: + requirements: ./requirements/bcrypt_layer.txt \ No newline at end of file diff --git a/examples/ridge_bcrypt/requirements/base.txt b/examples/ridge_bcrypt/requirements/base.txt new file mode 100644 index 0000000..e69de29 diff --git a/examples/ridge_bcrypt/requirements/bcrypt_layer.txt b/examples/ridge_bcrypt/requirements/bcrypt_layer.txt new file mode 100644 index 0000000..441145a --- /dev/null +++ b/examples/ridge_bcrypt/requirements/bcrypt_layer.txt @@ -0,0 +1 @@ +bcrypt \ No newline at end of file diff --git a/examples/ridge_bcrypt/sam.yml b/examples/ridge_bcrypt/sam.yml new file mode 100644 index 0000000..03c0726 --- /dev/null +++ b/examples/ridge_bcrypt/sam.yml @@ -0,0 +1,21 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: API Gateway with Lambda Token Authorizer + +Resources: + + APIHandlerFunction: + Type: AWS::Serverless::Function + Properties: + Runtime: python3.6 + Handler: lambda_function.lambda_handler + CodeUri: ./dist/sample.zip + Layers: + - !Ref BcryptLayer + + BcryptLayer: + Type: 'AWS::Serverless::LayerVersion' + Properties: + ContentUri: ./dist/bcrypt.zip + CompatibleRuntimes: # optional + - python3.6 \ No newline at end of file