mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-04 20:05:16 +02:00
feat(gateway): add gateway domain primitives
This commit is contained in:
parent
ae3ce91465
commit
c9b7d7b572
13 changed files with 481 additions and 0 deletions
19
surfsense_backend/app/gateway/base/identity.py
Normal file
19
surfsense_backend/app/gateway/base/identity.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
"""Gateway identity helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
|
||||
|
||||
def normalize_external_peer_id(value: str | int | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
return str(value).strip()
|
||||
|
||||
|
||||
def hash_external_id(value: str | int | None) -> str | None:
|
||||
normalized = normalize_external_peer_id(value)
|
||||
if not normalized:
|
||||
return None
|
||||
return hashlib.sha256(normalized.encode("utf-8")).hexdigest()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue