mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Backported default_allow_sql for 0.63.x, closes #1409
This commit is contained in:
parent
b8cf864fa6
commit
1ec9c9995c
7 changed files with 58 additions and 3 deletions
|
|
@ -116,6 +116,11 @@ SETTINGS = (
|
|||
True,
|
||||
"Allow users to specify columns to facet using ?_facet= parameter",
|
||||
),
|
||||
Setting(
|
||||
"default_allow_sql",
|
||||
True,
|
||||
"Allow anyone to run arbitrary SQL queries",
|
||||
),
|
||||
Setting(
|
||||
"allow_download",
|
||||
True,
|
||||
|
|
|
|||
|
|
@ -36,12 +36,16 @@ def permission_allowed(datasette, actor, action, resource):
|
|||
return None
|
||||
return actor_matches_allow(actor, allow)
|
||||
elif action == "execute-sql":
|
||||
# Only use default_allow_sql setting if it is set to False:
|
||||
default_allow_sql = (
|
||||
None if datasette.setting("default_allow_sql") else False
|
||||
)
|
||||
# Use allow_sql block from database block, or from top-level
|
||||
database_allow_sql = datasette.metadata("allow_sql", database=resource)
|
||||
if database_allow_sql is None:
|
||||
database_allow_sql = datasette.metadata("allow_sql")
|
||||
if database_allow_sql is None:
|
||||
return None
|
||||
return default_allow_sql
|
||||
return actor_matches_allow(actor, database_allow_sql)
|
||||
|
||||
return inner
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue