nextcloud / twofactor_gateway

🔑 Second factor provider using an external messaging gateway (SMS, Telegram, Signal)
GNU Affero General Public License v3.0
109 stars 63 forks source link

Cannot configure the gateway #288

Open renal31 opened 5 years ago

renal31 commented 5 years ago

Hi,

I just installed TwoFactor Gateway v0.14.1 on nextcloud server v17.0.0. When I try to configure the SMS client, I get the following exception : `> occ twofactorauth:gateway:configure sms

An unhandled exception has been thrown: TypeError: Argument 1 passed to OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig::setUser() must be of the type string, null given, called in /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php on line 122 and defined in /var/www/html/custom_apps/twofactor_gateway/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php:52 Stack trace:

0 /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php(122): OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig->setUser(NULL)

1 /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php(81): OCA\TwoFactorGateway\Command\Configure->configureSms(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

2 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\TwoFactorGateway\Command\Configure->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

3 /var/www/html/3rdparty/symfony/console/Application.php(908): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

4 /var/www/html/3rdparty/symfony/console/Application.php(269): Symfony\Component\Console\Application->doRunCommand(Object(OCA\TwoFactorGateway\Command\Configure), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

5 /var/www/html/3rdparty/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

6 /var/www/html/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

7 /var/www/html/console.php(97): OC\Console\Application->run()

8 /var/www/html/occ(11): require_once('/var/www/html/c...')

` Is this something known ?

Thanks & regards, Renaud

ChristophWurst commented 5 years ago

Were you asked any questions? It should actually ask for a username. But that is somehow set to null.

JonasOelke commented 4 years ago

Hey Guys! Hope you all had a nice eastern.

I am trying to configure Telegram but I am getting the same error. I am running Nextcloud 18.0.3 and twofactor_gateway 0.15.1.

I am running nextcloud in a Docker-Container connected to a mariadb-server on the host (not dockerized). As of the nextcloud docker image the PHP-Version is 7.3.16.

This is the output of docker exec --user www-data [container-id] php occ twofactorauth:gateway:configure telegram

Using .
An unhandled exception has been thrown:
TypeError: Argument 1 passed to OCA\TwoFactorGateway\Service\Gateway\Telegram\GatewayConfig::setBotToken() must be of the type string, null given, called in /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php on line 266 and defined in /var/www/html/custom_apps/twofactor_gateway/lib/Service/Gateway/Telegram/GatewayConfig.php:54
Stack trace:
#0 /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php(266): OCA\TwoFactorGateway\Service\Gateway\Telegram\GatewayConfig->setBotToken(NULL)
#1 /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php(86): OCA\TwoFactorGateway\Command\Configure->configureTelegram(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\TwoFactorGateway\Command\Configure->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/3rdparty/symfony/console/Application.php(915): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(OCA\TwoFactorGateway\Command\Configure), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/lib/private/Console/Application.php(214): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/console.php(99): OC\Console\Application->run()
#8 /var/www/html/occ(11): require_once('/var/www/html/c...')
#9 {main}

Trying to configure the sms gateway outputs @renal31's error:

An unhandled exception has been thrown:
TypeError: Argument 1 passed to OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig::setUser() must be of the type string, null given, called in /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php on line 124 and defined in /var/www/html/custom_apps/twofactor_gateway/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php:52
Stack trace:
#0 /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php(124): OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig->setUser(NULL)
#1 /var/www/html/custom_apps/twofactor_gateway/lib/Command/Configure.php(83): OCA\TwoFactorGateway\Command\Configure->configureSms(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\TwoFactorGateway\Command\Configure->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/3rdparty/symfony/console/Application.php(915): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(OCA\TwoFactorGateway\Command\Configure), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/lib/private/Console/Application.php(214): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/console.php(99): OC\Console\Application->run()
#8 /var/www/html/occ(11): require_once('/var/www/html/c...')
#9 {main} 

It looks like that the setBotToken()-Function (or for SMS the setUSer()-Function) is called before the actual user input. Anyone having an idea why the user input could be skipped?

Best wishes, Jonas

JonasOelke commented 4 years ago

@ChristophWurst Do you have any idea on this?

ChristophWurst commented 4 years ago

twofactor_gateway 0.15.1.

Please also try with the latest version.

I do not have much time to look into this right now, unfortunately.

ChristophWurst commented 4 years ago

It looks like that the setBotToken()-Function (or for SMS the setUSer()-Function) is called before the actual user input. Anyone having an idea why the user input could be skipped?

Look through the old tickets. This rings a bell but I don't recall what the problem was.

ChristophWurst commented 4 years ago

Oh I think it is due to Docker. The php shell does not detect an interactive prompt, hence questions can't be answered. You need to invoke the command through Docker and pipe stdin into the containerized process.