The `default_permissions.py` file is a bit large and hard to follow: https://github.com/simonw/datasette/blob/68f1179bac991b5e37b99a5482c40134f317c04f/datasette/default_permissions.py. - 494 lines.