nextcloud / twofactor_totp

🔑 Second factor TOTP (RFC 6238) provider for Nextcloud
https://apps.nextcloud.com/apps/twofactor_totp
GNU Affero General Public License v3.0
294 stars 56 forks source link

twofactor_backupcodes db table doesn't exist #254

Closed occirol closed 6 years ago

occirol commented 6 years ago

Steps to reproduce

  1. Install Two Factor TOTP Provider app
  2. Configure an account to use TOTP
  3. Disconnect the account and try to connect again

Expected behaviour

TOTP code should be asked

Actual behaviour

Internal Server Error

Server configuration

Operating system: FreeBSD 11.1

Web server: nginx/1.14

Database: mysql

PHP version: 7.1.18

Version: 13.0.4

Updated from an older version or fresh install: fresh install

List of activated apps:

  - activity: 2.6.1
  - admin_audit: 1.3.0
  - bruteforcesettings: 1.0.3
  - dav: true
  - encryption: 2.0.0
  - federatedfilesharing: true
  - files: true
  - files_sharing: 1.5.0
  - files_trashbin: 1.3.0
  - logreader: 2.0.0
  - lookup_server_connector: true
  - oauth2: true
  - provisioning_api: true
  - theming: 1.4.5
  - twofactor_backupcodes: true
  - twofactor_totp: 1.4.1
  - twofactor_u2f: 1.5.5
  - workflowengine: true

The content of config/config.php:

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "13.0.4.0",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "overwritewebroot": "",
        "overwritecondaddr": "***REMOVED SENSITIVE VALUE***",
        "htaccess.RewriteBase": "\/",
        "apps_paths": [
            {
                "path": "\/usr\/local\/www\/nextcloud\/apps",
                "url": "\/apps",
                "writable": true
            },
            {
                "path": "\/usr\/local\/www\/nextcloud\/apps-pkg",
                "url": "\/apps-pkg",
                "writable": false
            }
        ],
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtpsecure": "tls",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "maintenance": false
    },
    "apps": {
        "activity": {
            "enable_email": "no",
            "enabled": "yes",
            "installed_version": "2.6.1",
            "types": "filesystem"
        },
        "admin_audit": {
            "enabled": "yes",
            "installed_version": "1.3.0",
            "types": "logging"
        },
        "backgroundjob": {
            "lastjob": "7"
        },
        "bruteForce": {
            "whitelist_1": "***REMOVED SENSITIVE VALUE***"
        },
        "bruteforcesettings": {
            "enabled": "yes",
            "installed_version": "1.0.3",
            "types": ""
        },
        "core": {
            "default_encryption_module": "OC_DEFAULT_MODULE",
            "encryption_enabled": "yes",
            "installedat": "1529237885.1705",
            "lastcron": "1529520087",
            "lastupdatedat": "1529237885.1947",
            "moveavatarsdone": "yes",
            "oc.integritycheck.checker": "[]",
            "previewsCleanedUp": "1",
            "public_files": "files_sharing\/public.php",
            "scss.variables": "46e87e61237c78d274e5560e23a2f436",
            "shareapi_default_expire_date": "yes",
            "shareapi_enable_link_password_by_default": "yes",
            "shareapi_enforce_expire_date": "yes",
            "shareapi_enforce_links_password": "yes",
            "vendor": "nextcloud"
        },
        "encryption": {
            "enabled": "yes",
            "installed_version": "2.0.0",
            "masterKeyId": "master_2cddb0f5",
            "publicShareKeyId": "pubShare_2cddb0f5",
            "recoveryKeyId": "recoveryKey_2cddb0f5",
            "types": "filesystem"
        },
        "files_sharing": {
            "enabled": "yes",
            "installed_version": "1.5.0",
            "types": "filesystem"
        },
        "files_trashbin": {
            "enabled": "yes",
            "installed_version": "1.3.0",
            "types": "filesystem"
        },
        "logreader": {
            "enabled": "yes",
            "installed_version": "2.0.0",
            "types": ""
        },
        "survey_client": {
            "enabled": "no",
            "installed_version": "1.1.0",
            "types": ""
        },
        "theming": {
            "cachebuster": "1",
            "enabled": "yes",
            "installed_version": "1.4.5",
            "types": "logging"
        },
        "twofactor_totp": {
            "enabled": "yes",
            "installed_version": "1.4.1",
            "types": ""
        },
        "twofactor_u2f": {
            "enabled": "yes",
            "installed_version": "1.5.5",
            "types": ""
        }
    }
}

Logs

Server log (data/nextcloud.log)
{"reqId":"a6oDfIN3uAj8Vi4yJetI","level":3,"time":"2018-06-20T18:39:57+00:00","remoteAddr":"***REMOVED SENSITIVE VALUE***","user":"***REMOVED SENSITIVE VALUE***","app":"index","method":"GET","url":"\/login\/selectchallenge?redirect_url=\/apps\/files\/","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\TableNotFoundException\",\"Message\":\"An exception occurred while executing 'SELECT `id`, `user_id`, `code`, `used` FROM `oc_twofactor_backupcodes` WHERE `user_id` = ?' with params [\\\"***REMOVED SENSITIVE VALUE***\\\"]:\\n\\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_twofactor_backupcodes' doesn't exist\",\"Code\":0,\"Trace\":\"#0 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(855): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'SELECT `id`, `u...', Array)\\n#2 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/DB\\\/Connection.php(195): Doctrine\\\\DBAL\\\\Connection->executeQuery('SELECT `id`, `u...', Array, Array, NULL)\\n#3 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Query\\\/QueryBuilder.php(206): OC\\\\DB\\\\Connection->executeQuery('SELECT `id`, `u...', Array, Array)\\n#4 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/DB\\\/QueryBuilder\\\/QueryBuilder.php(214): Doctrine\\\\DBAL\\\\Query\\\\QueryBuilder->execute()\\n#5 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/apps-pkg\\\/twofactor_backupcodes\\\/lib\\\/Db\\\/BackupCodeMapper.php(46): OC\\\\DB\\\\QueryBuilder\\\\QueryBuilder->execute()\\n#6 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/apps-pkg\\\/twofactor_backupcodes\\\/lib\\\/Service\\\/BackupCodeStorage.php(123): OCA\\\\TwoFactorBackupCodes\\\\Db\\\\BackupCodeMapper->getBackupCodes(Object(OC\\\\User\\\\User))\\n#7 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/apps-pkg\\\/twofactor_backupcodes\\\/lib\\\/Provider\\\/BackupCodesProvider.php(114): OCA\\\\TwoFactorBackupCodes\\\\Service\\\\BackupCodeStorage->hasBackupCodes(Object(OC\\\\User\\\\User))\\n#8 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/Authentication\\\/TwoFactorAuth\\\/Manager.php(186): OCA\\\\TwoFactorBackupCodes\\\\Provider\\\\BackupCodesProvider->isTwoFactorAuthEnabledForUser(Object(OC\\\\User\\\\User))\\n#9 [internal function]: OC\\\\Authentication\\\\TwoFactorAuth\\\\Manager->OC\\\\Authentication\\\\TwoFactorAuth\\\\{closure}(*** sensitive parameters replaced ***)\\n#10 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/Authentication\\\/TwoFactorAuth\\\/Manager.php(187): array_filter(Array, Object(Closure))\\n#11 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/Authentication\\\/TwoFactorAuth\\\/Manager.php(144): OC\\\\Authentication\\\\TwoFactorAuth\\\\Manager->getProviders(Object(OC\\\\User\\\\User), true)\\n#12 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/core\\\/Controller\\\/TwoFactorChallengeController.php(90): OC\\\\Authentication\\\\TwoFactorAuth\\\\Manager->getBackupProvider(Object(OC\\\\User\\\\User))\\n#13 [internal function]: OC\\\\Core\\\\Controller\\\\TwoFactorChallengeController->selectChallenge('\\\/apps\\\/files\\\/')\\n#14 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(161): call_user_func_array(Array, Array)\\n#15 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(91): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Core\\\\Controller\\\\TwoFactorChallengeController), 'selectChallenge')\\n#16 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/AppFramework\\\/App.php(115): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Core\\\\Controller\\\\TwoFactorChallengeController), 'selectChallenge')\\n#17 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('OC\\\\\\\\Core\\\\\\\\Control...', 'selectChallenge', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#18 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#19 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/private\\\/Route\\\/Router.php(297): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#20 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/lib\\\/base.php(999): OC\\\\Route\\\\Router->match('\\\/login\\\/selectch...')\\n#21 \\\/usr\\\/local\\\/www\\\/nextcloud\\\/index.php(42): OC::handleRequest()\\n#22 {main}\",\"File\":\"\\\/usr\\\/local\\\/www\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":53}","userAgent":"Mozilla\/5.0 (X11; Fedora; Linux x86_64; rv:60.0) Gecko\/20100101 Firefox\/60.0","version":"13.0.4.0"}
occirol commented 6 years ago

Resolved by enabling the twofactor_backupcodes app.

su -m www -c "php ./occ app:enable twofactor_backupcodes"

ChristophWurst commented 6 years ago

Hi and thanks for your report.

I wonder why that app was disabled. IIRC it should be enabled by default.