[GH-ISSUE #129] Unhundled exception when setting up 2FA #42

Closed
opened 2026-02-26 05:32:38 +03:00 by kerem · 8 comments
Owner

Originally created by @mmartinortiz on GitHub (Oct 5, 2018).
Original GitHub issue: https://github.com/nextcloud/twofactor_gateway/issues/129

Two-Factor Gateway: 0.9.0
Nextcloud: 14.0.2 RC1

I've followed the instructions of the admin documentation for setting up the two-factor authentification using telegram. My Nextcloud server runs in a docker container, so I run the occ command with the following command:

docker exec nextcloud sudo -u abc /usr/bin/php -f /config/www/nextcloud/occ twofactorauth:gateway:configure telegram

It raises the following error:

The current PHP memory limit is below the recommended value of 512MB.
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 /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php on line 155 and defined in /config/www/nextcloud/apps/twofactor_gateway/lib/Service/Gateway/Telegram/GatewayConfig.php:54
Stack trace:
#0 /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php(155): OCA\TwoFactorGateway\Service\Gateway\Telegram\GatewayConfig->setBotToken(NULL)
#1 /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php(80): OCA\TwoFactorGateway\Command\Configure->configureTelegram(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /config/www/nextcloud/3rdparty/symfony/console/Command/Command.php(251): OCA\TwoFactorGateway\Command\Configure->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /config/www/nextcloud/3rdparty/symfony/console/Application.php(946): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /config/www/nextcloud/3rdparty/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OCA\TwoFactorGateway\Command\Configure), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /config/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /config/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /config/www/nextcloud/console.php(96): OC\Console\Application->run()
#8 /config/www/nextcloud/occ(11): require_once('/config/www/nex...')
#9 {main}

Can I provide more useful information? I'm not sure how to proceed to getting 2FA working. (I did not try with other providers)

Originally created by @mmartinortiz on GitHub (Oct 5, 2018). Original GitHub issue: https://github.com/nextcloud/twofactor_gateway/issues/129 **Two-Factor Gateway**: 0.9.0 **Nextcloud**: 14.0.2 RC1 I've followed the instructions of the [admin documentation](https://nextcloud-twofactor-gateway.readthedocs.io/en/latest/Admin%20Documentation/) for setting up the two-factor authentification using telegram. My Nextcloud server runs in a docker container, so I run the `occ` command with the following command: ```bash docker exec nextcloud sudo -u abc /usr/bin/php -f /config/www/nextcloud/occ twofactorauth:gateway:configure telegram ``` It raises the following error: ``` The current PHP memory limit is below the recommended value of 512MB. 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 /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php on line 155 and defined in /config/www/nextcloud/apps/twofactor_gateway/lib/Service/Gateway/Telegram/GatewayConfig.php:54 Stack trace: #0 /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php(155): OCA\TwoFactorGateway\Service\Gateway\Telegram\GatewayConfig->setBotToken(NULL) #1 /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php(80): OCA\TwoFactorGateway\Command\Configure->configureTelegram(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #2 /config/www/nextcloud/3rdparty/symfony/console/Command/Command.php(251): OCA\TwoFactorGateway\Command\Configure->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #3 /config/www/nextcloud/3rdparty/symfony/console/Application.php(946): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #4 /config/www/nextcloud/3rdparty/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OCA\TwoFactorGateway\Command\Configure), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #5 /config/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #6 /config/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #7 /config/www/nextcloud/console.php(96): OC\Console\Application->run() #8 /config/www/nextcloud/occ(11): require_once('/config/www/nex...') #9 {main} ``` Can I provide more useful information? I'm not sure how to proceed to getting 2FA working. (I did not try with other providers)
kerem 2026-02-26 05:32:38 +03:00
Author
Owner

@ChristophWurst commented on GitHub (Oct 5, 2018):

Did you enter a bot token when you were asked for it?

<!-- gh-comment-id:427314480 --> @ChristophWurst commented on GitHub (Oct 5, 2018): Did you enter a bot token when you were asked for it?
Author
Owner

@mmartinortiz commented on GitHub (Oct 5, 2018):

I was not asked for a token, I just got the exception after I run the command

Edit:

I've tried using the token as a second argument after telegram and as I expected it complains about "extra arguments"

<!-- gh-comment-id:427319970 --> @mmartinortiz commented on GitHub (Oct 5, 2018): I was not asked for a token, I just got the exception after I run the command **Edit:** I've tried using the token as a second argument after `telegram` and as I expected it complains about "extra arguments"
Author
Owner

@ChristophWurst commented on GitHub (Oct 5, 2018):

That is unexpected. The telegram configure command definitely asks for a token: github.com/nextcloud/twofactor_gateway@aa730883d7/lib/Command/Configure.php (L157-L167)

<!-- gh-comment-id:427342582 --> @ChristophWurst commented on GitHub (Oct 5, 2018): That is unexpected. The telegram configure command definitely asks for a token: https://github.com/nextcloud/twofactor_gateway/blob/aa730883d763ab070c011ba505240d767fda5243/lib/Command/Configure.php#L157-L167
Author
Owner

@mmartinortiz commented on GitHub (Oct 5, 2018):

Interesting... the exception I get points to the line 150, and the function in the repository starts at line 157. I've checked both files (my local file and the one in the repo) and they are different.

Here is the diff:

102c102
<               $providerQuestion = new Question('Please choose a SMS provider (websms, playsms, clockworksms): ', 'websms');
---
>               $providerQuestion = new Question('Please choose a SMS provider (websms, playsms): ', 'websms');
139,149d138
<                       case 'clockworksms':
<                               $config->setProvider($provider);
<                               /** @var ClockworkSmsConfig $providerConfig */
<                               $providerConfig = $config->getProvider()->getConfig();
<
<                               $apitokenQuestion = new Question('Please enter your clockworksms api token: ');
<                               $apitoken = $helper->ask($input, $output, $apitokenQuestion);
<
<                               $providerConfig->setApiToken($apitoken);
<
<                               break;
169c158
< }
---
> }
\ No newline at end of file

I've disabled, removed and download the application again. The file I get installed is the same that I had previously. The appinfo/info.xml file indicates that the version is 0.9.0, though.

<?xml version="1.0"?>
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
        <id>twofactor_gateway</id>
        <name>Two-Factor Gateway</name>
        <summary>Two-factor gateway providers (SMS, Telegram, Signal)</summary>
        <description>A set of Nextcloud two-factor providers to send authentication codes via Signal, SMS and Telegram.</description>
        <version>0.9.0</version>
        <licence>agpl</licence>
        <author>Christoph Wurst</author>
        <namespace>TwoFactorGateway</namespace>
        <category>security</category>
        <website>https://github.com/nextcloud/twofactor_gateway</website>
        <bugs>https://github.com/nextcloud/twofactor_gateway/issues</bugs>
        <screenshot>https://raw.githubusercontent.com/ChristophWurst/twofactor_gateway/3f895bc997c1a3a38c9bae16ccae8bd499af864e/screenshots/settings.png</screenshot>
        <screenshot>https://raw.githubusercontent.com/ChristophWurst/twofactor_gateway/3f895bc997c1a3a38c9bae16ccae8bd499af864e/screenshots/challenge.png</screenshot>
        <dependencies>
                <php min-version="7.0" max-version="7.2"/>
                <nextcloud min-version="14" max-version="14"/>
        </dependencies>

        <two-factor-providers>
                <provider>OCA\TwoFactorGateway\Provider\SignalProvider</provider>
                <provider>OCA\TwoFactorGateway\Provider\SmsProvider</provider>
                <provider>OCA\TwoFactorGateway\Provider\TelegramProvider</provider>
        </two-factor-providers>
        <commands>
                <command>OCA\TwoFactorGateway\Command\Configure</command>
                <command>OCA\TwoFactorGateway\Command\Status</command>
                <command>OCA\TwoFactorGateway\Command\Test</command>
        </commands>
        <settings>
                <personal>OCA\TwoFactorGateway\Settings\PersonalSettings</personal>
        </settings>
</info>

How can I delete the applications cache? I want to make sure to force the the app to be downloaded again after I remove it.

<!-- gh-comment-id:427349041 --> @mmartinortiz commented on GitHub (Oct 5, 2018): Interesting... the exception I get points to the line 150, and the function in the repository starts at line 157. I've checked both files (my local file and the one in the repo) and they are different. Here is the diff: ```diff 102c102 < $providerQuestion = new Question('Please choose a SMS provider (websms, playsms, clockworksms): ', 'websms'); --- > $providerQuestion = new Question('Please choose a SMS provider (websms, playsms): ', 'websms'); 139,149d138 < case 'clockworksms': < $config->setProvider($provider); < /** @var ClockworkSmsConfig $providerConfig */ < $providerConfig = $config->getProvider()->getConfig(); < < $apitokenQuestion = new Question('Please enter your clockworksms api token: '); < $apitoken = $helper->ask($input, $output, $apitokenQuestion); < < $providerConfig->setApiToken($apitoken); < < break; 169c158 < } --- > } \ No newline at end of file ``` I've disabled, removed and download the application again. The file I get installed is the same that I had previously. The `appinfo/info.xml` file indicates that the version is 0.9.0, though. ```xml <?xml version="1.0"?> <info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd"> <id>twofactor_gateway</id> <name>Two-Factor Gateway</name> <summary>Two-factor gateway providers (SMS, Telegram, Signal)</summary> <description>A set of Nextcloud two-factor providers to send authentication codes via Signal, SMS and Telegram.</description> <version>0.9.0</version> <licence>agpl</licence> <author>Christoph Wurst</author> <namespace>TwoFactorGateway</namespace> <category>security</category> <website>https://github.com/nextcloud/twofactor_gateway</website> <bugs>https://github.com/nextcloud/twofactor_gateway/issues</bugs> <screenshot>https://raw.githubusercontent.com/ChristophWurst/twofactor_gateway/3f895bc997c1a3a38c9bae16ccae8bd499af864e/screenshots/settings.png</screenshot> <screenshot>https://raw.githubusercontent.com/ChristophWurst/twofactor_gateway/3f895bc997c1a3a38c9bae16ccae8bd499af864e/screenshots/challenge.png</screenshot> <dependencies> <php min-version="7.0" max-version="7.2"/> <nextcloud min-version="14" max-version="14"/> </dependencies> <two-factor-providers> <provider>OCA\TwoFactorGateway\Provider\SignalProvider</provider> <provider>OCA\TwoFactorGateway\Provider\SmsProvider</provider> <provider>OCA\TwoFactorGateway\Provider\TelegramProvider</provider> </two-factor-providers> <commands> <command>OCA\TwoFactorGateway\Command\Configure</command> <command>OCA\TwoFactorGateway\Command\Status</command> <command>OCA\TwoFactorGateway\Command\Test</command> </commands> <settings> <personal>OCA\TwoFactorGateway\Settings\PersonalSettings</personal> </settings> </info> ``` How can I delete the applications cache? I want to make sure to force the the app to be downloaded again after I remove it.
Author
Owner

@ChristophWurst commented on GitHub (Oct 5, 2018):

Interesting... the exception I get points to the line 150, and the function in the repository star

Of course, because the master branch has change since the last release. You should be at this specific version: github.com/nextcloud/twofactor_gateway@a5a7d4047e/lib/Command/Configure.php (L146-L156).

Please don't change any files. If you do so and your installation breaks, you're on your own. I suggest to restore a backup with the previous state.

How can I delete the applications cache? I want to make sure to force the the app to be downloaded again after I remove it.

That functionality does not exist. You can try overwriting the app directory with the latest release tarball.

<!-- gh-comment-id:427356184 --> @ChristophWurst commented on GitHub (Oct 5, 2018): > Interesting... the exception I get points to the line 150, and the function in the repository star Of course, because the master branch has change since the last release. You should be at this specific version: https://github.com/nextcloud/twofactor_gateway/blob/a5a7d4047ef80f485b81725fbca09afa6de20ea2/lib/Command/Configure.php#L146-L156. Please don't change any files. If you do so and your installation breaks, you're on your own. I suggest to restore a backup with the previous state. > How can I delete the applications cache? I want to make sure to force the the app to be downloaded again after I remove it. That functionality does not exist. You can try overwriting the app directory with the latest release tarball.
Author
Owner

@mmartinortiz commented on GitHub (Oct 5, 2018):

If the master branch contains a new development version I think it should have a different version number, like the 0.10.0 or just a 0.9.1-dev.

In any case, I've tried with sms and signal. In the case of signal I get a Using a localhost:5000 what I guess means that the argument is accepted. If I use sms I get an exception:

TypeError: Argument 1 passed to OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig::setUser() must be of the type string, null given, called in /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php on line 118 and defined in /config/www/nextcloud/apps/twofactor_gateway/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php:52```

If I use a wrong gateway, I get a proper error message:

Invalid gateway noway


Could the problem be originated by the class `Question`?
<!-- gh-comment-id:427373057 --> @mmartinortiz commented on GitHub (Oct 5, 2018): If the master branch contains a new development version I think it should have a different version number, like the 0.10.0 or just a 0.9.1-dev. In any case, I've tried with `sms` and `signal`. In the case of signal I get a `Using a localhost:5000` what I guess means that the argument is accepted. If I use `sms` I get an exception: ``` TypeError: Argument 1 passed to OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig::setUser() must be of the type string, null given, called in /config/www/nextcloud/apps/twofactor_gateway/lib/Command/Configure.php on line 118 and defined in /config/www/nextcloud/apps/twofactor_gateway/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php:52``` If I use a wrong gateway, I get a proper error message: ``` Invalid gateway noway ``` Could the problem be originated by the class `Question`?
Author
Owner

@ChristophWurst commented on GitHub (Oct 5, 2018):

If the master branch contains a new development version I think it should have a different version number, like the 0.10.0 or just a 0.9.1-dev.

No, because we need the version bumps to trigger database migrations. Of course we could use even numbers for releases and odd ones for dev versions, but that breaks semver, which I'm a big fan of.

May I ask you what terminal you're using? Sounds like yours is not interactive and thus the questions are not asked. This is weird tbh.

<!-- gh-comment-id:427388056 --> @ChristophWurst commented on GitHub (Oct 5, 2018): > If the master branch contains a new development version I think it should have a different version number, like the 0.10.0 or just a 0.9.1-dev. No, because we need the version bumps to trigger database migrations. Of course we could use even numbers for releases and odd ones for dev versions, but that breaks semver, which I'm a big fan of. May I ask you what terminal you're using? Sounds like yours is not interactive and thus the questions are not asked. This is weird tbh.
Author
Owner

@mmartinortiz commented on GitHub (Oct 5, 2018):

I've checked the terminal. I'm using bash, but I forgot to use the -ti parameters for docker (making it interactive). My fault :-\

Now I'm having the same problem described in this other issue, but I'll add information there.

Thanks for your help

<!-- gh-comment-id:427473802 --> @mmartinortiz commented on GitHub (Oct 5, 2018): I've checked the terminal. I'm using bash, but I forgot to use the `-ti` parameters for docker (making it interactive). My fault :-\ Now I'm having the same problem described in [this other issue](https://github.com/nextcloud/twofactor_gateway/issues/110), but I'll add information there. Thanks for your help
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/twofactor_gateway-nextcloud#42
No description provided.