Coverage for fastid / auth / config.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-10-18 16:37 +0000

1from collections.abc import Sequence 

2from pathlib import Path 

3 

4from fastid.core.config import core_settings 

5from fastid.core.schemas import BaseSettings 

6 

7 

8class AuthSettings(BaseSettings): 

9 jwt_algorithm: str = "HS256" 

10 jwt_id_algorithm: str = "RS256" 

11 jwt_key: Path = Path("certs") / "secret.key" 

12 jwt_private_key: Path = Path("certs") / "jwt-private.pem" 

13 jwt_public_key: Path = Path("certs") / "jwt-public.pem" 

14 jwt_access_expires_in: int = 60 * 60 # 1 hour 

15 jwt_refresh_expires_in: int = 30 * 24 * 60 # 30 days 

16 jwt_verify_token_expires_in: int = 5 * 60 # 5 minutes 

17 

18 authorization_code_expires_in: int = 5 * 60 # 5 minutes 

19 verification_code_expires_in: int = 5 * 60 # 5 minutes 

20 

21 hash_schemas: Sequence[str] = ["argon2", "bcrypt"] # Supports reverse compatibility 

22 hash_default: str = "argon2" 

23 argon2_time_cost: int = 2 

24 argon2_memory_cost: int = 19456 

25 argon2_parallelism: int = 1 

26 argon2_salt_len: int = 16 

27 argon2_hash_len: int = 32 

28 

29 app_expires_in_seconds: int = 60 

30 

31 @property 

32 def server_url(self) -> str | None: 

33 if core_settings.public_url is None: 

34 return None 

35 return core_settings.public_url.rstrip("/") 

36 

37 

38auth_settings = AuthSettings()