From 94ccd9b05ce87d8db10910b274c638706a14e063 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 2 Jan 2020 12:30:43 +0800 Subject: [PATCH] use the right authenticator --- moulinette/interfaces/api.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 10e31059..c6a12bcf 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -657,24 +657,19 @@ class ActionsMapParser(BaseActionsMapParser): # Return the created parser return parser - def auth_required(self, args, route, **kwargs): + def auth_required(self, args, **kwargs): try: # Retrieve the tid for the route - tid, _ = self._parsers[route] - if not self.get_conf(tid, "authenticate"): - return False - else: - # TODO: In the future, we could make the authentication - # dependent of the route being hit ... - # e.g. in the context of friend2friend stuff that could - # auth with some custom auth system to access some - # data with something like : - # return self.get_conf(tid, 'authenticator') - return "default" + tid, _ = self._parsers[kwargs.get("route")] except KeyError: - logger.error("no argument parser found for route '%s'", route) + logger.error("no argument parser found for route '%s'", kwargs.get("route")) raise MoulinetteError("error_see_log") + if self.get_conf(tid, "authenticate"): + return self.get_conf(tid, "authenticator") + else: + return False + def parse_args(self, args, route, **kwargs): """Parse arguments