Files
microsoft-365-service/app/config.py
T
JiriUhlirandClaude Fable 5.1 d80193da8b Hlavicky X-MS365-* jako obycejne hodnoty, GET /users/{user_id}/calendar
- credentials: sifrovani AES-GCM/HKDF odstraneno, tri hlavicky se berou
  tak, jak jsou; bez hlavicek se pouziji hodnoty z prostredi
- zrusena promenna MS365_CREDENTIAL_ENCODING_SECRET a zavislost cryptography
- novy endpoint GET /users/{user_id}/calendar (objekt kalendare schranky,
  id a name) pro read-only overeni pristupu pres e-mail schranky
- C# ukazka posila hodnoty primo, CredentialEncoder smazan
- README: sekce o hlavickach vcetne PowerShell ukazky, zaznam zmen
- .gitignore: bin/ a obj/, zaverzovane obj/ soubory ukazky odstraneny z gitu

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-22 12:49:25 +02:00

35 lines
1.2 KiB
Python

import os
from dataclasses import dataclass, replace
@dataclass(frozen=True)
class Settings:
app_name: str = os.getenv("APP_NAME", "Microsoft 365 Service")
app_version: str = os.getenv("APP_VERSION", "1.1.0")
root_path: str = os.getenv("ROOT_PATH", "")
tenant_id: str = os.getenv("MS365_TENANT_ID", "")
client_id: str = os.getenv("MS365_CLIENT_ID", "")
client_secret: str = os.getenv("MS365_CLIENT_SECRET", "")
graph_base_url: str = os.getenv("MS365_GRAPH_BASE_URL", "https://graph.microsoft.com/v1.0")
graph_scope: str = os.getenv("MS365_GRAPH_SCOPE", "https://graph.microsoft.com/.default")
request_timeout_seconds: float = float(os.getenv("MS365_REQUEST_TIMEOUT_SECONDS", "30"))
@property
def token_url(self) -> str:
return f"https://login.microsoftonline.com/{self.tenant_id}/oauth2/v2.0/token"
@property
def is_configured(self) -> bool:
return bool(self.tenant_id and self.client_id and self.client_secret)
def with_credentials(self, tenant_id: str, client_id: str, client_secret: str) -> "Settings":
return replace(
self,
tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret,
)
settings = Settings()