[8.1.4] files: show 405 Method Not Allowed #20713

Closed
PoPoutdoor opened this Issue Nov 24, 2015 · 11 comments

Projects

None yet

5 participants

@PoPoutdoor

/index.php/apps/files_sharing/api/externalShares -> 405 Method Not Allowed

Steps to reproduce

  1. Disable config:
    'asset-pipeline.enabled' => false,
  2. Clear /assets:
    rm -f assets/*
  3. Login

Expected behaviour

Files app should not check api for Federated Cloud Sharing while settings not checked in Admin page.

Server configuration

Operating system: Linux
Web server: nginx
Database: mariadb-10.0.22
PHP version: PHP 5.6.14-pl0-gentoo
ownCloud version: 8.1.4.2
Updated from an older ownCloud or fresh install: upgrade from 8.0.x
List of activated apps:

Enabled:
 - files: 1.1.10
 - files_sharing: 0.6.3
 - files_trashbin: 0.6.3
 - files_versions: 1.0.6
 - galleryplus: 14.3.0
 - mail: 0.3-alpha
 - provisioning_api: 0.2

Disabled:
 - documents
 - encryption
 - files_external
 - user_ldap
 - user_webdavauth

The content of config/config.php:

This is a test instance with default config, except:

  'asset-pipeline.enabled' => false,
  'check_for_working_htaccess' => false,

Are you using external storage: no

Are you using encryption: no

Client configuration

Browser: Firefox 38.4.0
Operating system: Linux

Logs

Web server error log

192.168.1.1 - - [24/Nov/2015:23:38:47 +0800] "GET /index.php/apps/files_sharing/api/externalShares HTTP/1.1" 405 680 "http://192.168.1.15/index.php/apps/files" "Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" "-"

ownCloud log (data/owncloud.log)

None

Admin settings of Sharing

Checked:

-  Allow apps to use the Share API
-  Allow users to share via link
    -  Allow public uploads
-  Allow username autocompletion in share dialog. If this is disabled the full username needs to be entered.
@PVince81
Collaborator

Files app should not load external share api while files_external is not enabled.

files_external is for external storages. It has nothing to do with the share API.

@rullzer @schiesbn any idea about the 405 method not allowed ?

@PVince81 PVince81 added this to the 9.0-current milestone Nov 25, 2015
@rullzer
Contributor
rullzer commented Nov 25, 2015

As @PVince81 said. The external shares have nothing to do with external storage but with federated shares.

The 405 originates in the middleware at https://github.com/owncloud/core/blob/stable8.1/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php#L104

@PoPoutdoor do you probabaly have Allow users on this server to receive shares from other servers disabled?

If so then this is the intended behaviour.

@PoPoutdoor

@rullzer Federated Cloud Sharing settings not checked.

If so then this is the intended behaviour.

From user POV, I don't get your point. If an instance admin not intended to use Federated Cloud Sharing feature, it is logical NOT check those settings.

I think the best approach is when both settings not checked, don't load the Federated Cloud Sharing code.

@rullzer
Contributor
rullzer commented Nov 25, 2015

@PoPoutdoor well the 405 is valid. Since the externalShares are disabled the method to access them is not allowed.

Now if the files app should try to load the endpoint is a totally different thing. Either we fire off a request and if a 405 is returned we know to ignore it. or we hack in yet another config var to the js somehwere (which also has to be loaded from somewhere) and decide there. @PVince81 your call.

@PoPoutdoor

@rullzer So, this is files app's initial check for Federated Cloud Sharing support... hacking another config var is bad if you means an entry in config.php.

The current behaver is this check runs every time... how about caching the result so only one 405 return, or better suppressed the initial 405 and then add result to the cache?

@rullzer
Contributor
rullzer commented Nov 26, 2015

@PoPoutdoor well the problem with caching is that you need to check if it is still valid. If the admin decided to enable federated sharing again the cache must be invalidated.

@PVince81
Collaborator

Are we talking about the call that checks for incoming shares every time the files app is loaded ?
It should be possible to disable that check whenever the config says that incoming fed shares are disabled. Config settings should be available in JS through OC_config

@PVince81
Collaborator

It must be this file: https://github.com/owncloud/core/blob/v8.2.0/apps/files_sharing/js/external.js

Then look for the line where this script is loaded, and don't load it if incoming fed shares are disabled.

@PoPoutdoor

well the problem with caching is that you need to check if it is still valid. If the admin decided to enable federated sharing again the cache must be invalidated.

@rullzer As a quick fix, related settings can only be changed with UI admin page, so the cache update can be triggered by monitoring either of the settings checked.

@PVince81
Collaborator

There is no need for any cache.

Just add a if condition to the line that loads this script: https://github.com/owncloud/core/blob/master/apps/files_sharing/appinfo/app.php#L60 and check if the app config key "incoming_server2server_share_enabled" is false true. And only load the file if it is true.

@rullzer
Contributor
rullzer commented Nov 27, 2015

Ah right. Let me add this to my todo. Should be an easy fix indeed.

@rullzer rullzer added a commit that referenced this issue Dec 2, 2015
@rullzer rullzer [Sharing] Respect disabled incoming federated shares
Only fetch the incoming federated shares if incoming shares are actually
enabled.

Fixes #20713
1e19661
@rullzer rullzer added a commit that referenced this issue Dec 18, 2015
@rullzer rullzer [Sharing] Respect disabled incoming federated shares
Only fetch the incoming federated shares if incoming shares are actually
enabled.

Fixes #20713
b720c96
@rullzer rullzer added a commit that referenced this issue Dec 18, 2015
@rullzer rullzer [Sharing] Respect disabled incoming federated shares
Only fetch the incoming federated shares if incoming shares are actually
enabled.

Fixes #20713
5721038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment