We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw this code in it probably works
import json import crypto import boto3 # throw this in a helper folder or sum def serialize_cookie(cookie_dict): cookie_string = '' for key, value in cookie_dict.items(): cookie_string += f'{key}={value}; ' return cookie_string.rstrip('; ') secrets_manager_client = boto3.client('secretsmanager') secret_name = 'resume-book-session-cookie-secret' def lambda_handler(event, context): try: response = secrets_manager_client.get_secret_value(SecretId=secret_name) encryption_key = response['SecretString'] except Exception as e: return { "statusCode": 500, "body": json.dumps("Error: Failed to retrieve encryption key") } user_data = ... # get username and password here serialized_user_data = json.dumps(user_data) cipher = crypto.Cipher(algorithm=crypto.Algorithms.AES, mode=crypto.Modes.CFB, key=encryption_key.encode(), iv=encryption_key.encode()) encrypted_user_data = cipher.encrypt(serialized_user_data.encode()).hex() user_cookie = { "name": "userSession", "value": encrypted_user_data, "httpOnly": True, "max-age": 3600, "secure": True, "sameSite": "Lax" } serialized_cookie = serialize_cookie(user_cookie) response = { "statusCode": 200, "headers": { "Set-Cookie": serialized_cookie, "Content-Type": "text/plain" }, "body": "Cookie has been set." } return response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Throw this code in it probably works
The text was updated successfully, but these errors were encountered: