-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load private and public key content into constants #4
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Module for the constants of the application. | ||
""" | ||
import sys | ||
|
||
from ldap_jwt_auth.core.config import config | ||
|
||
# Read the contents of the private and public key files into constants. These are used for encoding and decoding of JWT | ||
# access and refresh tokens. | ||
try: | ||
with open(config.authentication.private_key_path, "r") as f: | ||
PRIVATE_KEY = f.read() | ||
except FileNotFoundError as exc: | ||
sys.exit(f"Cannot find private key: {exc}") | ||
|
||
try: | ||
with open(config.authentication.public_key_path, "r") as f: | ||
PUBLIC_KEY = f.read() | ||
except FileNotFoundError as exc: | ||
sys.exit(f"Cannot find public key: {exc}") |