feat(core): Selected authentification plugin is always enabled
This commit is contained in:
parent
653c1c584c
commit
f6c229d2ef
|
@ -36,18 +36,21 @@ class CustomJSONEncoder(JSONEncoder):
|
||||||
|
|
||||||
|
|
||||||
def __load_plugins(app):
|
def __load_plugins(app):
|
||||||
logger.info("Search for plugins")
|
logger.debug("Search for plugins")
|
||||||
|
|
||||||
app.config["FG_PLUGINS"] = {}
|
app.config["FG_PLUGINS"] = {}
|
||||||
for entry_point in pkg_resources.iter_entry_points("flaschengeist.plugins"):
|
for entry_point in pkg_resources.iter_entry_points("flaschengeist.plugins"):
|
||||||
logger.debug("Found plugin: >{}<".format(entry_point.name))
|
logger.debug(f"Found plugin: >{entry_point.name}<")
|
||||||
plugin = None
|
|
||||||
if entry_point.name in config and config[entry_point.name].get("enabled", False):
|
if entry_point.name == config["FLASCHENGEIST"]["auth"] or (
|
||||||
|
entry_point.name in config and config[entry_point.name].get("enabled", False)
|
||||||
|
):
|
||||||
|
logger.debug(f"Load plugin {entry_point.name}")
|
||||||
try:
|
try:
|
||||||
logger.info(f"Load plugin {entry_point.name}")
|
|
||||||
plugin = entry_point.load()
|
plugin = entry_point.load()
|
||||||
if not hasattr(plugin, "name"):
|
if not hasattr(plugin, "name"):
|
||||||
setattr(plugin, "name", entry_point.name)
|
setattr(plugin, "name", entry_point.name)
|
||||||
plugin = plugin(config[entry_point.name])
|
plugin = plugin(config.get(entry_point.name, {}))
|
||||||
if hasattr(plugin, "blueprint") and plugin.blueprint is not None:
|
if hasattr(plugin, "blueprint") and plugin.blueprint is not None:
|
||||||
app.register_blueprint(plugin.blueprint)
|
app.register_blueprint(plugin.blueprint)
|
||||||
except:
|
except:
|
||||||
|
@ -55,16 +58,17 @@ def __load_plugins(app):
|
||||||
f"Plugin {entry_point.name} was enabled, but could not be loaded due to an error.",
|
f"Plugin {entry_point.name} was enabled, but could not be loaded due to an error.",
|
||||||
exc_info=True,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
del plugin
|
|
||||||
continue
|
continue
|
||||||
if isinstance(plugin, AuthPlugin):
|
if isinstance(plugin, AuthPlugin):
|
||||||
logger.debug(f"Found authentication plugin: {entry_point.name}")
|
if entry_point.name != config["FLASCHENGEIST"]["auth"]:
|
||||||
if entry_point.name == config["FLASCHENGEIST"]["auth"]:
|
logger.debug(f"Unload not configured AuthPlugin {entry_point.name}")
|
||||||
app.config["FG_AUTH_BACKEND"] = plugin
|
|
||||||
else:
|
|
||||||
del plugin
|
del plugin
|
||||||
continue
|
continue
|
||||||
if plugin:
|
else:
|
||||||
|
logger.info(f"Using authentication plugin: {entry_point.name}")
|
||||||
|
app.config["FG_AUTH_BACKEND"] = plugin
|
||||||
|
else:
|
||||||
|
logger.info(f"Using plugin: {entry_point.name}")
|
||||||
app.config["FG_PLUGINS"][entry_point.name] = plugin
|
app.config["FG_PLUGINS"][entry_point.name] = plugin
|
||||||
if "FG_AUTH_BACKEND" not in app.config:
|
if "FG_AUTH_BACKEND" not in app.config:
|
||||||
logger.error("No authentication plugin configured or authentication plugin not found")
|
logger.error("No authentication plugin configured or authentication plugin not found")
|
||||||
|
|
|
@ -44,12 +44,8 @@ allowed_mimetypes = [
|
||||||
"image/webp"
|
"image/webp"
|
||||||
]
|
]
|
||||||
|
|
||||||
[auth_plain]
|
|
||||||
enabled = true
|
|
||||||
|
|
||||||
[auth_ldap]
|
[auth_ldap]
|
||||||
# Full documentation https://flaschengeist.dev/Flaschengeist/flaschengeist/wiki/plugins_auth_ldap
|
# Full documentation https://flaschengeist.dev/Flaschengeist/flaschengeist/wiki/plugins_auth_ldap
|
||||||
enabled = false
|
|
||||||
# host = "localhost"
|
# host = "localhost"
|
||||||
# port = 389
|
# port = 389
|
||||||
# base_dn = "dc=example,dc=com"
|
# base_dn = "dc=example,dc=com"
|
||||||
|
|
Loading…
Reference in New Issue