Fix issues in previous commits regarding authentication mecanism

This commit is contained in:
Alexandre Aubin 2021-12-23 16:57:43 +01:00
parent ee1e63c7a1
commit 964483b23b
3 changed files with 13 additions and 0 deletions

View file

@ -90,6 +90,11 @@ class APIQueueHandler(logging.Handler):
def emit(self, record): def emit(self, record):
# Prevent triggering this function while moulinette
# is being initialized with --debug
if not self.actionsmap or len(request.cookies) == 0:
return
profile = request.params.get("profile", self.actionsmap.default_authentication) profile = request.params.get("profile", self.actionsmap.default_authentication)
authenticator = self.actionsmap.get_authenticator(profile) authenticator = self.actionsmap.get_authenticator(profile)
@ -484,6 +489,8 @@ class _ActionsMapPlugin(object):
try: try:
s_id = authenticator.get_session_cookie()["id"] s_id = authenticator.get_session_cookie()["id"]
queue = self.log_queues[s_id] queue = self.log_queues[s_id]
except MoulinetteAuthenticationError:
pass
except KeyError: except KeyError:
pass pass
else: else:

View file

@ -61,6 +61,9 @@ class Authenticator(BaseAuthenticator):
return {"id": random_ascii()} return {"id": random_ascii()}
raise MoulinetteAuthenticationError("unable_authenticate") raise MoulinetteAuthenticationError("unable_authenticate")
if not infos and raise_if_no_session_exists:
raise MoulinetteAuthenticationError("unable_authenticate")
if "id" not in infos: if "id" not in infos:
infos["id"] = random_ascii() infos["id"] = random_ascii()

View file

@ -61,6 +61,9 @@ class Authenticator(BaseAuthenticator):
return {"id": random_ascii()} return {"id": random_ascii()}
raise MoulinetteAuthenticationError("unable_authenticate") raise MoulinetteAuthenticationError("unable_authenticate")
if not infos and raise_if_no_session_exists:
raise MoulinetteAuthenticationError("unable_authenticate")
if "id" not in infos: if "id" not in infos:
infos["id"] = random_ascii() infos["id"] = random_ascii()