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