fix: added validation for crypto_key

This commit is contained in:
ITQ
2025-11-20 19:53:41 +03:00
parent f93c5a5966
commit b3c368f9af
3 changed files with 10 additions and 2 deletions
@@ -5,6 +5,7 @@ from tomllib import loads
from typing import dataclass_transform
from adaptix import P, Retort, loader
from cryptography.fernet import Fernet
from template_project.application.common.containers import SecretString
@@ -24,6 +25,13 @@ class AccessTokenConfiguration:
crypto_key: str
expires_in: timedelta
def __post_init__(self) -> None:
try:
Fernet(self.crypto_key)
except ValueError as error:
msg = "access_token.crypto_key must be a valid 32-byte url-safe base64 key"
raise ValueError(msg) from error
@to_configuration
class ServerConfiguration: