mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
actor_matches_allow utility function, refs #800
This commit is contained in:
parent
d4c7b85f55
commit
14f6b4d200
3 changed files with 62 additions and 2 deletions
|
|
@ -854,3 +854,22 @@ def call_with_supported_arguments(fn, **kwargs):
|
|||
)
|
||||
call_with.append(kwargs[parameter])
|
||||
return fn(*call_with)
|
||||
|
||||
|
||||
def actor_matches_allow(actor, allow):
|
||||
if allow is None:
|
||||
return True
|
||||
for key, values in allow.items():
|
||||
if values == "*" and key in actor:
|
||||
return True
|
||||
if isinstance(values, str):
|
||||
values = [values]
|
||||
actor_values = actor.get(key)
|
||||
if actor_values is None:
|
||||
return False
|
||||
if isinstance(actor_values, str):
|
||||
actor_values = [actor_values]
|
||||
actor_values = set(actor_values)
|
||||
if actor_values.intersection(values):
|
||||
return True
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue