From 9d84733b94d6dcb217058721ab7b0f66832863ee Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Tue, 26 Nov 2024 23:34:53 +0100 Subject: [PATCH] Secrets --- personal_data/fetchers/fin_depo.py | 12 ++--- personal_data/fetchers/steam_community.py | 2 +- personal_data/secrets.py | 65 +++++++++++++++-------- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/personal_data/fetchers/fin_depo.py b/personal_data/fetchers/fin_depo.py index 93c9059..e0eb9b2 100644 --- a/personal_data/fetchers/fin_depo.py +++ b/personal_data/fetchers/fin_depo.py @@ -42,8 +42,8 @@ class KrakenAccountBalances(FinanceDepoScraper): def get_depo_fetcher(self): return fin_depo.defi_kraken.KrakenDepoFetcher( - kraken_key=secrets.KRAKEN_KEY, - kraken_secret=secrets.KRAKEN_SECRET, + kraken_key=secrets.kraken_key(), + kraken_secret=secrets.kraken_secret(), ) @@ -53,9 +53,9 @@ class KucoinAccountBalances(FinanceDepoScraper): def get_depo_fetcher(self): return fin_depo.defi_kucoin.KucoinDepoFetcher( - kucoin_key=secrets.KUCOIN_KEY, - kucoin_secret=secrets.KUCOIN_SECRET, - kucoin_pass=secrets.KUCOIN_PASS, + kucoin_key=secrets.kucoin_key(), + kucoin_secret=secrets.kucoin_secret(), + kucoin_pass=secrets.kucoin_pass(), ) @@ -66,5 +66,5 @@ class MpcBalance(FinanceDepoScraper): def get_depo_fetcher(self): return fin_depo.defi_partisia_blockchain.PartisiaBlockchainAccountDepoFetcher( self.session, - blockchain_address=secrets.PBC_ACCOUNT_ADDRESS, + blockchain_address=secrets.pbc_account_address(), ) diff --git a/personal_data/fetchers/steam_community.py b/personal_data/fetchers/steam_community.py index 8815baa..e7ae5c5 100644 --- a/personal_data/fetchers/steam_community.py +++ b/personal_data/fetchers/steam_community.py @@ -28,7 +28,7 @@ class SteamAchievement(Scraper): deduplicate_mode = DeduplicateMode.BY_ALL_COLUMNS def scrape(self) -> Iterator[dict[str, Any]]: - username: str = secrets.STEAM_USERNAME + username: str = secrets.steam_username() appids = list(self._determine_appids_from_recent_activity(username)) logger.info('Found %d Steam Apps', len(appids)) for appid in appids: diff --git a/personal_data/secrets.py b/personal_data/secrets.py index fa383b4..ed63101 100644 --- a/personal_data/secrets.py +++ b/personal_data/secrets.py @@ -1,47 +1,66 @@ from secret_loader import SecretLoader -load_secret = SecretLoader(env_key_prefix='CF_PD').load +secrets = SecretLoader(env_key_prefix='CF_PD') + # Crunchyroll -CRUNCHYROLL_DEVICE_ID = load_secret('CRUNCHYROLL_DEVICE_ID') -CRUNCHYROLL_AUTH = load_secret('CRUNCHYROLL_AUTH') +CRUNCHYROLL_DEVICE_ID = secrets.load('CRUNCHYROLL_DEVICE_ID') +CRUNCHYROLL_AUTH = secrets.load('CRUNCHYROLL_AUTH') # FFXIV -FFXIV_CHARACTER_ID = load_secret('FFXIV_CHARACTER_ID') +FFXIV_CHARACTER_ID = secrets.load('FFXIV_CHARACTER_ID') # Playstation -PLAYSTATION_PSN_ID = load_secret('PLAYSTATION_PSN_ID') +PLAYSTATION_PSN_ID = secrets.load('PLAYSTATION_PSN_ID') + # Partisia Blockchain -PBC_ACCOUNT_ADDRESS = load_secret('PBC_ACCOUNT_ADDRESS') +def pbc_account_address(): + return secrets.load_or_fail('PBC_ACCOUNT_ADDRESS') + # Steam -STEAM_USERNAME = load_secret('STEAM_USERNAME') +def steam_username(): + return secrets.load_or_fail('STEAM_USERNAME') + # Kucoin -KUCOIN_KEY = load_secret('KUCOIN_KEY') -KUCOIN_SECRET = load_secret('KUCOIN_SECRET') -KUCOIN_PASS = load_secret('KUCOIN_PASS') +def kucoin_key(): + return secrets.load_or_fail('KUCOIN_KEY') + + +def kucoin_secret(): + return secrets.load_or_fail('KUCOIN_SECRET') + + +def kucoin_pass(): + return secrets.load_or_fail('KUCOIN_PASS') + # Kraken -KRAKEN_KEY = load_secret('KRAKEN_KEY') -KRAKEN_SECRET = load_secret('KRAKEN_SECRET') +def kraken_key(): + return secrets.load_or_fail('KRAKEN_KEY') + + +def kraken_secret(): + return secrets.load_or_fail('KRAKEN_SECRET') + # Home Assistant -HOME_ASSISTANT_ROOT = load_secret('HOME_ASSISTANT_ROOT') -HOME_ASSISTANT_LLAK = load_secret('HOME_ASSISTANT_LLAK') +HOME_ASSISTANT_ROOT = secrets.load('HOME_ASSISTANT_ROOT') +HOME_ASSISTANT_LLAK = secrets.load('HOME_ASSISTANT_LLAK') # Email configuration -MAILGUN_API_KEY = load_secret('MAILGUN_API_KEY') -MAILGUN_DOMAIN = load_secret('MAILGUN_DOMAIN') -MAILGUN_RECIPIENT = load_secret('MAILGUN_RECIPIENT') +MAILGUN_API_KEY = secrets.load('MAILGUN_API_KEY') +MAILGUN_DOMAIN = secrets.load('MAILGUN_DOMAIN') +MAILGUN_RECIPIENT = secrets.load('MAILGUN_RECIPIENT') # Jellyfin -JELLYFIN_URL = load_secret('JELLYFIN_URL') -JELLYFIN_USERNAME = load_secret('JELLYFIN_USERNAME') -JELLYFIN_PASSWORD = load_secret('JELLYFIN_PASSWORD') +JELLYFIN_URL = secrets.load('JELLYFIN_URL') +JELLYFIN_USERNAME = secrets.load('JELLYFIN_USERNAME') +JELLYFIN_PASSWORD = secrets.load('JELLYFIN_PASSWORD') # Withings -WITHINGS_CLIENTID = load_secret('WITHINGS_CLIENTID') -WITHINGS_SECRET = load_secret('WITHINGS_SECRET') -WITHINGS_CALLBACK_URI = load_secret('WITHINGS_CALLBACK_URI') +WITHINGS_CLIENTID = secrets.load('WITHINGS_CLIENTID') +WITHINGS_SECRET = secrets.load('WITHINGS_SECRET') +WITHINGS_CALLBACK_URI = secrets.load('WITHINGS_CALLBACK_URI')