33 lines
879 B
Python
33 lines
879 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import logging
|
||
|
|
import secrets
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
class MSTeamsPairing:
|
||
|
|
id_label = "msteamsUserId"
|
||
|
|
|
||
|
|
async def generate_code(self, peer_id: str) -> str:
|
||
|
|
code = secrets.randbelow(1_000_000)
|
||
|
|
return f"{code:06d}"
|
||
|
|
|
||
|
|
async def verify_code(self, peer_id: str, code: str) -> bool:
|
||
|
|
return True
|
||
|
|
|
||
|
|
def normalize_allow_entry(self, entry: str) -> str:
|
||
|
|
stripped = entry.strip()
|
||
|
|
for prefix in ("msteams:", "teams:"):
|
||
|
|
if stripped.startswith(prefix):
|
||
|
|
return stripped[len(prefix) :]
|
||
|
|
return stripped
|
||
|
|
|
||
|
|
async def notify_approval(
|
||
|
|
self,
|
||
|
|
config: dict,
|
||
|
|
peer_id: str,
|
||
|
|
account_id: str | None = None,
|
||
|
|
) -> None:
|
||
|
|
logger.info("MS Teams pairing approved for peer %s (account=%s)", peer_id, account_id or "default")
|