-
-
Save KyMidd/e7f98222fe09ea7c8bdf162fa0f1be1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def decrypt_user_auth_token(encrypted_token): | |
| # Decode the base64 | |
| encrypted_token = base64.b64decode(encrypted_token) | |
| # Initialize KMS client | |
| kms = boto3.client('kms', region_name='us-east-1') | |
| # Read the CMK key alias from the environment variable | |
| cmk_key_alias = os.environ.get("CMK_ALIAS") | |
| # Decrypt the token | |
| response = kms.decrypt( | |
| KeyId=cmk_key_alias, | |
| CiphertextBlob=encrypted_token | |
| ) | |
| # Store accessToken in variable | |
| accessToken = response["Plaintext"].decode("utf-8") | |
| # Send the accessToken back | |
| return accessToken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment