luna.authorization.events
event_source_contract_only
def event_source_contract_only() -> Callable[[EventSourceType, str], bool]
event_source_contract_only enforces that any event must come from a contract
event_source_user_only
def event_source_user_only() -> Callable[[EventSourceType, str], bool]
event_source_user_only enforces that any event must come from a user
event_source_access_list
def event_source_access_list(
access_list: dict[str, bool],
default_action: bool = False
) -> Callable[[EventSourceType, str], bool]
event_source_source_id_access_list enforces that any event must come from source id in the provided access list
This can be used as both an allow or block list. i.e. event_source_source_id_access_list({"1": True, "2": False })
will allow user 1
to send the event, but block user 2
. User 3
who is not in the access_list
would have the value of default_action
returned. By default this is False
so would block them, but can be set to True
to allow true block list semantics.