kopia lustrzana https://github.com/Yakifo/amqtt
fix missing auth plugin
rodzic
92141d9a54
commit
ecdfd0a464
|
@ -692,17 +692,20 @@ class Broker:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
returns = await self.plugins_manager.map_plugin_auth(session=session)
|
returns = await self.plugins_manager.map_plugin_auth(session=session)
|
||||||
auth_result = True
|
|
||||||
if returns:
|
results = [ result for _, result in returns.items() if result is not None]
|
||||||
for plugin in returns:
|
if len(results) < 1:
|
||||||
res = returns[plugin]
|
self.logger.debug("Authentication failed: no plugin responded with a boolean")
|
||||||
if res is False:
|
return False
|
||||||
auth_result = False
|
|
||||||
self.logger.debug(f"Authentication failed due to '{plugin.__class__}' plugin result: {res}")
|
if all(results):
|
||||||
else:
|
self.logger.debug("Authentication succeeded")
|
||||||
self.logger.debug(f"'{plugin.__class__}' plugin result: {res}")
|
return True
|
||||||
# If all plugins returned True, authentication is success
|
|
||||||
return auth_result
|
for plugin, result in returns.items():
|
||||||
|
self.logger.debug(f"Authentication '{plugin.__class__.__name__}' result: {result}")
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def retain_message(
|
def retain_message(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -79,7 +79,8 @@ async def test_broker_sys_plugin_deprecated_config() -> None:
|
||||||
match group:
|
match group:
|
||||||
case 'tests.mock_plugins':
|
case 'tests.mock_plugins':
|
||||||
return [
|
return [
|
||||||
EntryPoint(name='BrokerSysPlugin', group='tests.mock_plugins', value='amqtt.plugins.sys.broker:BrokerSysPlugin'),
|
EntryPoint(name='broker_sys', group='tests.mock_plugins', value='amqtt.plugins.sys.broker:BrokerSysPlugin'),
|
||||||
|
EntryPoint(name='auth_anonymous', group='test.mock_plugins', value='amqtt.plugins.sys.auth:AuthAnonymousPlugin'),
|
||||||
]
|
]
|
||||||
case _:
|
case _:
|
||||||
return list()
|
return list()
|
||||||
|
@ -91,7 +92,10 @@ async def test_broker_sys_plugin_deprecated_config() -> None:
|
||||||
"listeners": {
|
"listeners": {
|
||||||
"default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
|
"default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
|
||||||
},
|
},
|
||||||
'sys_interval': 1
|
'sys_interval': 1,
|
||||||
|
'auth': {
|
||||||
|
'allow_anonymous': True
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
|
broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
|
||||||
|
@ -131,6 +135,7 @@ async def test_broker_sys_plugin_config() -> None:
|
||||||
"default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
|
"default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
|
||||||
},
|
},
|
||||||
'plugins': [
|
'plugins': [
|
||||||
|
{'amqtt.plugins.authentication.AnonymousAuthPlugin': {'allow_anonymous': True}},
|
||||||
{'amqtt.plugins.sys.broker.BrokerSysPlugin': {'sys_interval': 1}},
|
{'amqtt.plugins.sys.broker.BrokerSysPlugin': {'sys_interval': 1}},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue