We don't need to auth in CLI

This commit is contained in:
Alexandre Aubin 2020-05-01 02:03:09 +02:00
parent a34fb7c665
commit d2f68cb536

View file

@ -431,7 +431,7 @@ class Interface(BaseInterface):
self.actionsmap = actionsmap
def run(self, args, output_as=None, password=None, timeout=None):
def run(self, args, output_as=None, timeout=None):
"""Run the moulinette
Process the action corresponding to the given arguments 'args'
@ -443,7 +443,6 @@ class Interface(BaseInterface):
- json: return a JSON encoded string
- plain: return a script-readable output
- none: do not output the result
- password -- The password to use in case of authentication
- timeout -- Number of seconds before this command will timeout because it can't acquire the lock (meaning that another command is currently running), by default there is no timeout and the command will wait until it can get the lock
"""
@ -454,11 +453,7 @@ class Interface(BaseInterface):
argcomplete.autocomplete(self.actionsmap.parser._parser)
# Set handler for authentication
if password:
msignals.set_handler("authenticate", lambda a: a(password=password))
else:
if os.isatty(1):
msignals.set_handler("authenticate", self._do_authenticate)
msignals.set_handler("authenticate", self._do_authenticate)
try:
ret = self.actionsmap.process(args, timeout=timeout)
@ -490,7 +485,11 @@ class Interface(BaseInterface):
Handle the core.MoulinetteSignals.authenticate signal.
"""
# TODO: Allow token authentication?
# Hmpf we have no-use case in yunohost anymore where we need to auth
# because everything is run as root ...
# I guess we could imagine some yunohost-independant use-case where
# moulinette is used to create a CLI for non-root user that needs to
# auth somehow but hmpf -.-
help = authenticator.extra.get("help")
msg = m18n.n(help) if help else m18n.g("password")
return authenticator(password=self._do_prompt(msg, True, False, color="yellow"))