broker: Pass current action to topic filter.

This will allow a topic filter to act on both subscription requests and
publishing.
pull/69/head
Stuart Longland 2021-06-06 15:24:41 +10:00 zatwierdzone przez Florian Ludwig
rodzic c2e7fcf2cb
commit 75257cb69a
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -703,7 +703,7 @@ class Broker:
# If all plugins returned True, authentication is success
return auth_result
async def topic_filtering(self, session: Session, topic):
async def topic_filtering(self, session: Session, topic, action: str):
"""
This method call the topic_filtering method on registered plugins to check that the subscription is allowed.
User is considered allowed if all plugins called return True.
@ -713,7 +713,8 @@ class Broker:
- None if topic filtering can't be achieved (then plugin result is then ignored)
:param session:
:param listener:
:param topic: Topic in which the client wants to subscribe
:param topic: Topic in which the client wants to subscribe / publish
:param action: What is being done with the topic? subscribe or publish
:return:
"""
topic_plugins = None
@ -724,6 +725,7 @@ class Broker:
"topic_filtering",
session=session,
topic=topic,
action=action,
filter_plugins=topic_plugins,
)
topic_result = True