nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.64k stars 3.99k forks source link

[Bug]: Could not find resource files_external/js/public_key.js to load #42158

Closed AndyXheli closed 8 months ago

AndyXheli commented 9 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

Seeing the below errors under NC 28 RC4 looks similar to https://github.com/nextcloud/server/pull/41766

Could not find resource files_external/js/public_key.js to load Could not find resource files_external/js/oauth2.js to load Could not find resource files_external/js/oauth1.js to load

Steps to reproduce

Not sure

Expected behavior

No error

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

{"reqId":"KgqH2auQuzMzGRXKdMsw","level":3,"time":"2023-12-11T08:42:01-06:00","remoteAddr":"10.1.1.1","user":"admin","app":"jsresourceloader","method":"GET","url":"/settings/admin/externalstorages","message":"Could not find resource files_external/js/public_key.js to load","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","version":"28.0.0.10","data":{"app":"jsresourceloader"},"id":"657722ad0cd52"}

{"reqId":"KgqH2auQuzMzGRXKdMsw","level":3,"time":"2023-12-11T08:42:01-06:00","remoteAddr":"10.1.1.1","user":"admin","app":"jsresourceloader","method":"GET","url":"/settings/admin/externalstorages","message":"Could not find resource files_external/js/oauth2.js to load","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","version":"28.0.0.10","data":{"app":"jsresourceloader"},"id":"657722ad0cd67"}

{"reqId":"KgqH2auQuzMzGRXKdMsw","level":3,"time":"2023-12-11T08:42:01-06:00","remoteAddr":"10.1.1.1","user":"admin","app":"jsresourceloader","method":"GET","url":"/settings/admin/externalstorages","message":"Could not find resource files_external/js/oauth1.js to load","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","version":"28.0.0.10","data":{"app":"jsresourceloader"},"id":"657722ad0cd7a"}

Additional info

No response

Caligatio commented 8 months ago

I'm also affected and it's causing a non-trivial number of "ERROR" level log messages to pile up.

skjnldsv commented 8 months ago

https://github.com/nextcloud/server/pull/42428

BoBBer446 commented 8 months ago

Im Using Docker Compose and get the same.

Compose file:

version: '3.8'

services:
  nextcloud:
    image: custom-nextcloud:latest
    volumes:
      - /home/docker-projects/nextcloud-fotos:/mnt/Fotos-Nextcloud
      - /home/docker-projects/nextcloud:/var/www/html
    restart: always
    environment:
      - POSTGRES_HOST=postgres
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=securepassword
      - REDIS_HOST=redis
      - PHP_MEMORY_LIMIT=1024M
      - NEXTCLOUD_TRUSTED_DOMAINS=localhost 192.168.178.36
      - NEXTCLOUD_ADMIN_USER=myuser
      - NEXTCLOUD_ADMIN_PASSWORD=myuser_password
      - NEXTCLOUD_DEFAULT_PHONE_REGION=DE
    ports:
      - "8811:80"
    hostname: nextcloud-server
    container_name: nextcloud-server
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:latest
    restart: always
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=securepassword
    hostname: nextcloud-db
    container_name: nextcloud-db
    volumes:
      - /home/docker-projects/nextcloud/postgres:/var/lib/postgresql/data

  redis:
    image: redis:alpine
    restart: always
    hostname: nextcloud-redis
    container_name: nextcloud-redis

Dockerfile

FROM nextcloud:latest

RUN apt-get update && \
    apt-get install -y libbz2-dev nano ffmpeg && \
    rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install bz2

Version Nextcloud Hub 7 (28.0.1)

Current install: Today, 05.01.2024

i check files: apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php apps/files_external/lib/Lib/Auth/PublicKey/RSA.php

and i found the right codes $ cat apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php

<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin McCorkell <robin@mccorkell.me.uk>
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 */
namespace OCA\Files_External\Lib\Auth\OAuth1;

use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\DefinitionParameter;
use OCP\IL10N;

/**
 * OAuth1 authentication
 */
class OAuth1 extends AuthMechanism {
        public function __construct(IL10N $l) {
                $this
                        ->setIdentifier('oauth1::oauth1')
                        ->setScheme(self::SCHEME_OAUTH1)
                        ->setText($l->t('OAuth1'))
                        ->addParameters([
                                (new DefinitionParameter('configured', 'configured'))
                                        ->setType(DefinitionParameter::VALUE_HIDDEN),
                                new DefinitionParameter('app_key', $l->t('App key')),
                                (new DefinitionParameter('app_secret', $l->t('App secret')))
                                        ->setType(DefinitionParameter::VALUE_PASSWORD),
                                (new DefinitionParameter('token', 'token'))
                                        ->setType(DefinitionParameter::VALUE_HIDDEN),
                                (new DefinitionParameter('token_secret', 'token_secret'))
                                        ->setType(DefinitionParameter::VALUE_HIDDEN),
                        ])
                        ->addCustomJs('oauth1')
                ;
        }
}

$ cat apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php

<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin McCorkell <robin@mccorkell.me.uk>
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 */
namespace OCA\Files_External\Lib\Auth\OAuth2;

use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\DefinitionParameter;
use OCP\IL10N;

/**
 * OAuth2 authentication
 */
class OAuth2 extends AuthMechanism {
        public function __construct(IL10N $l) {
                $this
                        ->setIdentifier('oauth2::oauth2')
                        ->setScheme(self::SCHEME_OAUTH2)
                        ->setText($l->t('OAuth2'))
                        ->addParameters([
                                (new DefinitionParameter('configured', 'configured'))
                                        ->setType(DefinitionParameter::VALUE_HIDDEN),
                                new DefinitionParameter('client_id', $l->t('Client ID')),
                                (new DefinitionParameter('client_secret', $l->t('Client secret')))
                                        ->setType(DefinitionParameter::VALUE_PASSWORD),
                                (new DefinitionParameter('token', 'token'))
                                        ->setType(DefinitionParameter::VALUE_HIDDEN),
                        ])
                        ->addCustomJs('oauth2')
                ;
        }
}

$ cat apps/files_external/lib/Lib/Auth/PublicKey/RSA.php

<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin McCorkell <robin@mccorkell.me.uk>
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 */
namespace OCA\Files_External\Lib\Auth\PublicKey;

use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\StorageConfig;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
use phpseclib\Crypt\RSA as RSACrypt;

/**
 * RSA public key authentication
 */
class RSA extends AuthMechanism {

        /** @var IConfig */
        private $config;

        public function __construct(IL10N $l, IConfig $config) {
                $this->config = $config;

                $this
                        ->setIdentifier('publickey::rsa')
                        ->setScheme(self::SCHEME_PUBLICKEY)
                        ->setText($l->t('RSA public key'))
                        ->addParameters([
                                new DefinitionParameter('user', $l->t('Username')),
                                new DefinitionParameter('public_key', $l->t('Public key')),
                                (new DefinitionParameter('private_key', 'private_key'))
                                        ->setType(DefinitionParameter::VALUE_HIDDEN),
                        ])
                        ->addCustomJs('public_key')
                ;
        }

        public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
                $auth = new RSACrypt();
                $auth->setPassword($this->config->getSystemValue('secret', ''));
                if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
                        // Add fallback routine for a time where secret was not enforced to be exists
                        $auth->setPassword('');
                        if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
                                throw new \RuntimeException('unable to load private key');
                        }
                }
                $storage->setBackendOption('public_key_auth', $auth);
        }

        /**
         * Generate a keypair
         *
         * @param int $keyLenth
         * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
         */
        public function createKey($keyLength) {
                $rsa = new RSACrypt();
                $rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH);
                $rsa->setPassword($this->config->getSystemValue('secret', ''));

                if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) {
                        $keyLength = 1024;
                }

                return $rsa->createKey($keyLength);
        }
}

I mount external Sotrrage and if i want use it i get this error: image

RAW:

[jsresourceloader] Fehler: Could not find resource files_external/js/public_key.js to load
    GET /settings/user/externalstorages
    von 192.168.178.22 von xxxxxx um 05.01.2024, 23:49:16

Always if i go to this: image

How i can fix it ?

szaimen commented 8 months ago

Reopening because backport to 28 is pending

MarcS1975 commented 8 months ago

I had the same problem and it was caused by wrong permission set by the NC container on External Storage. For me it worked when I logged into the container and manually changed ownership of the data folders to www-data:www-data and permissions to 0750.

BoBBer446 commented 8 months ago

This would also explain why the correct code is present. I'll test it later. Thanks for the tip!

sebaxakerhtc commented 8 months ago

Same for me.

Steps to reproduce: Updated to 28.0.1 1) go to settings 2) Click on External storage 3) See errors in the log

szaimen commented 8 months ago

It is fixed in 28.0.2

sebaxakerhtc commented 8 months ago

It is fixed in 28.0.2

Starting update, thank you! Oh... There's no rc yet :(

HomelabHaven commented 7 months ago

I get the exact same three error messages as mentioned above. In addition I have thousands upon thousands of errors that occur thereafter when accessing the external storage:

"Array to string conversion at /app/www/public/lib/private/Files/Cache/Scanner.php#222"

Not sure if it is related. Thought I might as well ask before opening a separate issue if necessary.

my php-local.ini

; Edit this file to override php.ini directives and restart the container

date.timezone = Europe/Berlin
max_execution_time = 86400
memory_limit = 2048M
vincentkoevoets commented 7 months ago

I get the exact same three error messages as mentioned above. In addition I have thousands upon thousands of errors that occur thereafter when accessing the external storage:

"Array to string conversion at /app/www/public/lib/private/Files/Cache/Scanner.php#222"

Not sure if it is related. Thought I might as well ask before opening a separate issue if necessary.

Yes, I have the same error as OP, but that seems to be fixed now with 28.0.2. Will check it out when released. The error about Scanner.php was also spamming my logfile, but stopped when I closed the Nextcloud client on my Windows desktop. I have an iDrive E2 bucket connected as external storage, so maybe something goes wrong when the client is trying to sync to desktop? But we might have to take that one to a new issue, not sure if it's related to error stated by OP.

lukaszzyla commented 7 months ago

hi. I am on docker aio v 7.10 updated today but my nextcloud container is still 28.0.1 I ahve the same error. permissions on data container are ok. I do not see second level deep of external storage. in my the top level external storage is visible and accessible and works fine.

image

but I am also trying to add a subfolder within this dir as a storage that is only visibe for certain accounts, and this folder doesnt show up in this accounts files and I do get the same error in logs...

image

the error is the same as for the others with that problem:

image
joshtrichards commented 7 months ago

@lukaszzyla v28.0.2 isn't out yet. It'll should be out next week. RC was pushed out today.

BilBomba commented 6 months ago

Hello,

I'm using Nextcloud AIO and updated minutes ago. Now I'm running v7.13.

I still get the exact 3 error messages as mentioned above. I can not see any problem with my external storage.

However, Let's Encrypt is about to expire. It's not updating. The files mentioned in the log messages, do not exist. There is only one file in the corresponding folder called rootcerts.crt:

-rw-rwxr--+ 1 www-data www-data 226639 Jan 25 19:43 rootcerts.crt

What's wrong with my setup?