mirror of
https://github.com/simonw/datasette.git
synced 2026-06-11 11:36:58 +02:00
* Split default_permissions.py into a package, refs #2602 * Remove unused is_resource_allowed() method, improve test coverage - Remove dead code: is_resource_allowed() method was never called - Change isinstance check to assertion with error message - Add test cases for table-level restrictions in restrictions_allow_action() - Coverage for restrictions.py improved from 79% to 99% 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Additional permission test for gap spotted by coverage
29 lines
756 B
Python
29 lines
756 B
Python
"""
|
|
Root user permission handling for Datasette.
|
|
|
|
Grants full permissions to the root user when --root flag is used.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Optional
|
|
|
|
if TYPE_CHECKING:
|
|
from datasette.app import Datasette
|
|
|
|
from datasette import hookimpl
|
|
from datasette.permissions import PermissionSQL
|
|
|
|
|
|
@hookimpl(specname="permission_resources_sql")
|
|
async def root_user_permissions_sql(
|
|
datasette: "Datasette",
|
|
actor: Optional[dict],
|
|
) -> Optional[PermissionSQL]:
|
|
"""
|
|
Grant root user full permissions when --root flag is used.
|
|
"""
|
|
if not datasette.root_enabled:
|
|
return None
|
|
if actor is not None and actor.get("id") == "root":
|
|
return PermissionSQL.allow(reason="root user")
|