1 """Permissions for Home Assistant."""
3 from __future__
import annotations
5 from collections.abc
import Callable
7 import voluptuous
as vol
9 from .const
import CAT_ENTITIES
10 from .entities
import ENTITY_POLICY_SCHEMA, compile_entities
11 from .merge
import merge_policies
12 from .models
import PermissionLookup
13 from .types
import PolicyType
14 from .util
import test_all
16 POLICY_SCHEMA = vol.Schema({vol.Optional(CAT_ENTITIES): ENTITY_POLICY_SCHEMA})
23 "AbstractPermissions",
30 """Default permissions class."""
32 _cached_entity_func: Callable[[str, str], bool] |
None =
None
35 """Return a function that can test entity access."""
36 raise NotImplementedError
39 """Check if we have a certain access to all entities."""
40 raise NotImplementedError
43 """Check if we can access entity."""
47 return entity_func(entity_id, key)
51 """Handle permissions."""
53 def __init__(self, policy: PolicyType, perm_lookup: PermissionLookup) ->
None:
54 """Initialize the permission class."""
59 """Check if we have a certain access to all entities."""
63 """Return a function that can test entity access."""
66 def __eq__(self, other: object) -> bool:
68 return isinstance(other, PolicyPermissions)
and other._policy == self.
_policy_policy
72 """Owner permissions."""
75 """Check if we have a certain access to all entities."""
79 """Return a function that can test entity access."""
80 return lambda entity_id, key:
True
bool access_all_entities(self, str key)
Callable[[str, str], bool] _entity_func(self)
bool check_entity(self, str entity_id, str key)
bool access_all_entities(self, str key)
Callable[[str, str], bool] _entity_func(self)
None __init__(self, PolicyType policy, PermissionLookup perm_lookup)
bool __eq__(self, object other)
bool access_all_entities(self, str key)
Callable[[str, str], bool] _entity_func(self)
Callable[[str, str], bool] compile_entities(CategoryType policy, PermissionLookup perm_lookup)
bool test_all(CategoryType policy, str key)
web.Response get(self, web.Request request, str config_key)