in source/lambda/SFTPCustomAuthLambdaFunction.py [0:0]
def lambda_handler(event, context):
stack_id = str(os.environ['STACK_ID'])
role_arn = str(os.environ['ROLE_ARN'])
#print("stack_id:" + stack_id)
response = {}
if "username" not in event or "serverId" not in event or "password" not in event:
return response
server_id = event["serverId"]
uname = event["username"]
pas = event["password"]
#bucketname = "${AWSTransferForSFTPS3Bucket}"
if (pas != ""):
status_code = auth_with_cognito(uname, pas, stack_id)
if status_code[0] != None:
auth_result = status_code[0]["AuthenticationResult"]
response["Role"] = role_arn
response['HomeDirectoryType'] = "LOGICAL"
response['HomeDirectoryDetails'] = get_user_directory_mapping(uname)
return response
else:
print("Failed to authenticate user {} with Cognito.".format(uname))
else:
print("Failed to authenticate user as the password is blank")