Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

feature/bcrypt-example #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions examples/ridge_bcrypt/Makefile
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions examples/ridge_bcrypt/lambda_function.py
Original file line number Diff line number Diff line change
@@ -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 :("}
11 changes: 11 additions & 0 deletions examples/ridge_bcrypt/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

functions:
sample:
requirements: ./requirements/base.txt
include:
- ./lambda_function.py

layers:

bcrypt:
requirements: ./requirements/bcrypt_layer.txt
Empty file.
1 change: 1 addition & 0 deletions examples/ridge_bcrypt/requirements/bcrypt_layer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcrypt
21 changes: 21 additions & 0 deletions examples/ridge_bcrypt/sam.yml
Original file line number Diff line number Diff line change
@@ -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