Skip to content

Commit

Permalink
Removed env variables and added dynamic credential retrieval using AW…
Browse files Browse the repository at this point in the history
…S SSO profiles
  • Loading branch information
KevinHa48 committed Sep 24, 2023
1 parent 5ed9dc0 commit 8608c8d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
3 changes: 0 additions & 3 deletions config/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ def load_env(input: str) -> str:
COGNITO_REGION: str = load_env("COGNITO_REGION")
COGNITO_USERPOOL_ID: str = load_env("COGNITO_USERPOOL_ID")
COGNITO_APP_CLIENT_ID: str = load_env("COGNITO_APP_CLIENT_ID")
AWS_ACCESS_KEY_ID: str = load_env("AWS_ACCESS_KEY_ID") # TODO this should be accessed only with the ~/.aws/credentials file, not directly in the backend
AWS_SECRET_ACCESS_KEY: str = load_env("AWS_SECRET_ACCESS_KEY") # TODO this should be accessed only with the ~/.aws/credentials file, not directly in the backend
AWS_SESSION_TOKEN: str = load_env("AWS_SESSION_TOKEN") # TODO see above
MONGO_URI: str = load_env("MONGO_URI")
MONGO_DB_NAME: str = load_env("MONGO_DB_NAME")
DOCUSIGN_CLIENT_ID: str = load_env("DOCUSIGN_CLIENT_ID")
Expand Down
9 changes: 2 additions & 7 deletions database/cognito.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
from botocore.exceptions import ClientError
import logging
import boto3
from config.env import COGNITO_USERPOOL_ID, COGNITO_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
from config.env import COGNITO_USERPOOL_ID, COGNITO_REGION

class CognitoIdentityProviderWrapper:
"""Encapsulates Amazon Cognito actions"""
def __init__(self):
self.cognito_idp_client = boto3.client('cognito-idp',
region_name=COGNITO_REGION,
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
aws_session_token=AWS_SESSION_TOKEN
)
self.cognito_idp_client = boto3.client('cognito-idp')

def get_user(self, username: str):
"""
Expand Down

0 comments on commit 8608c8d

Please sign in to comment.