def lambda_handler()

in docdb_rest/auth.py [0:0]


def lambda_handler(event, context):
  print(event)
  action = "Allow"
  authorization = None
  if "Authorization" in event["headers"]:
      authorization = event["headers"]["Authorization"]
  if "authorization" in event["headers"]:
      authorization = event["headers"]["authorization"]
  if None == authorization:
      action = "Deny"
  splits = base64.b64decode(authorization.split(" ")[-1]).decode("utf-8").split(":")
  username = splits[0]
  password = splits[1]
  if (username != os.environ["USERNAME"] or password != os.environ["PASSWORD"]):
      print("Invalid username or password")
      action = "Deny"

  return buildPolicy(event, username, action)