Skip to content

Commit

Permalink
Load private and public key content into constants #4
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Dec 20, 2023
1 parent 3e160b1 commit c0f14e3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ldap_jwt_auth/core/constants.py
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}")

0 comments on commit c0f14e3

Please sign in to comment.