Add permission checks to Rest API (#18639)
* Add permission checks to Rest API * Clean up unnecessary method * Remove all the tuple stuff from entity check * Simplify perms * Correct param name for owner permission * Hass.io make/update user to be admin * Types
This commit is contained in:
parent
f387cdec59
commit
8b8629a5f4
15 changed files with 282 additions and 145 deletions
|
@ -14,7 +14,8 @@ from contextlib import contextmanager
|
|||
|
||||
from homeassistant import auth, core as ha, config_entries
|
||||
from homeassistant.auth import (
|
||||
models as auth_models, auth_store, providers as auth_providers)
|
||||
models as auth_models, auth_store, providers as auth_providers,
|
||||
permissions as auth_permissions)
|
||||
from homeassistant.auth.permissions import system_policies
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
from homeassistant.config import async_process_component_config
|
||||
|
@ -400,6 +401,10 @@ class MockUser(auth_models.User):
|
|||
auth_mgr._store._users[self.id] = self
|
||||
return self
|
||||
|
||||
def mock_policy(self, policy):
|
||||
"""Mock a policy for a user."""
|
||||
self._permissions = auth_permissions.PolicyPermissions(policy)
|
||||
|
||||
|
||||
async def register_auth_provider(hass, config):
|
||||
"""Register an auth provider."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue