fix: handle dict config in is_allowed() and _validate_allow_from()
getattr() on a dict never finds custom keys — it only searches object attributes, not dict keys. When channel config is loaded as a Pydantic extra field (which is a plain dict), getattr(config, 'allow_from', []) always returns the default [], causing all access to be denied regardless of the allowFrom configuration. Fix both is_allowed() and _validate_allow_from() to use isinstance checks, falling back to dict.get() for dict configs while preserving getattr() for object-style configs.
This commit is contained in:
@@ -75,7 +75,12 @@ class ChannelManager:
|
||||
|
||||
def _validate_allow_from(self) -> None:
|
||||
for name, ch in self.channels.items():
|
||||
if getattr(ch.config, "allow_from", None) == []:
|
||||
cfg = ch.config
|
||||
if isinstance(cfg, dict):
|
||||
allow = cfg.get("allow_from") or cfg.get("allowFrom")
|
||||
else:
|
||||
allow = getattr(cfg, "allow_from", None)
|
||||
if allow == []:
|
||||
raise SystemExit(
|
||||
f'Error: "{name}" has empty allowFrom (denies all). '
|
||||
f'Set ["*"] to allow everyone, or add specific user IDs.'
|
||||
|
||||
Reference in New Issue
Block a user