refactor(backend): user app idTags validated against the user record, not the allowlist
'app token of <name>' synthetic allowlist entries are gone: decide() recognizes a user's personal idTag directly, enforces the user's own charger:<cp>:<gun> scopes at the charger-side gate, and attributes the session (who=user, method=app). charger_start no longer auto-enrolls; PUT /api/allowlist/<user-tag> returns 400; stale entries auto-drop at startup. Zero-user open mode still authorizes 'app-remote' for bootstrap. Smoke: 63 checks.
This commit is contained in:
@@ -54,6 +54,12 @@ def _load() -> dict:
|
||||
for key, default in DEFAULTS.items():
|
||||
cfg.setdefault(key, default if not isinstance(default, dict) else dict(default))
|
||||
cfg.pop("learn_mode", None) # superseded by the pending-cards workflow
|
||||
# users' app idTags used to be auto-enrolled as "app token of <name>"
|
||||
# allowlist entries; they now authorize via the user record directly
|
||||
user_tags = {u.get("id_tag") for u in cfg["users"].values()}
|
||||
for tag in [t for t in cfg["authorized"] if t in user_tags]:
|
||||
del cfg["authorized"][tag]
|
||||
log.info("dropped redundant allowlist entry %r (a user's app token)", tag)
|
||||
if not cfg.get("session_secret"):
|
||||
cfg["session_secret"] = secrets.token_hex(32)
|
||||
return cfg
|
||||
|
||||
Reference in New Issue
Block a user