core icon indicating copy to clipboard operation
core copied to clipboard

Encryption makes files inaccessible for app APIs

Open phedlund opened this issue 12 years ago • 13 comments

As described in https://github.com/owncloud/notes/issues/48 encryption prevents an API from accessing files, in this particular case the Notes app. Users are met with a 401 Unauthorized even though credentials are correct.

phedlund avatar Jun 02 '14 22:06 phedlund

Maybe the notes app is not using the right API calls to access files. It should use the View class. If it does, please provide the logs ideally using the issue template: https://raw.github.com/owncloud/core/master/issue_template.md

CC @schiesbn @Raydiation

PVince81 avatar Jun 03 '14 17:06 PVince81

Notes APP uses the view class

BernhardPosselt avatar Jun 03 '14 18:06 BernhardPosselt

Steps to reproduce

  1. Install and enable Notes app
  2. Enable ownCloud encryption
  3. curl -k -u user:pass https://example.com/owncloud/index.php/apps/notes/api/v0.2/notes

Expected behaviour

json with all your notes should be returned

Actual behaviour

401 Unauthorized is returned

Server configuration

CentOS:

Web server: Apache

Database: MySQL

PHP version: 5.3

ownCloud version: 6.0.3 (see ownCloud admin page)

Updated from an older ownCloud or fresh install: Updated

List of activated apps: Stock + News and Notes

The content of config/config.php:

<?php
$CONFIG = array (
  'datadirectory' => 'top_secret',
  'dbtype' => 'mysql',
  'version' => '6.0.3.1',
  'dbname' => 'phedlund_oc',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'top_secret',
  'dbpassword' => 'top_secret',
  'installed' => true,
  'maxZipInputSize' => '838860800',
  'allowZipDownload' => true,
  'instanceid' => '5076f3f070a5f',
  'maintenance' => false,
  'theme' => '',
  'trusted_domains' => 
  array (
    0 => 'secure3120.hostgator.com',
  ),
);

Are you using external storage, if yes which one: No local/smb/sftp/...

Are you using encryption: Yes

phedlund avatar Jun 03 '14 20:06 phedlund

I don't think the 401 Unauthorized is raised by the encryption app. Could be something else.

PVince81 avatar Jun 20 '14 09:06 PVince81

@Raydiation So have you tested the notes app with encryption or do you know if someone else who used it successfully?

karlitschek avatar Jun 24 '14 16:06 karlitschek

Ive tested it locally right now, works perfectly fine.

BernhardPosselt avatar Jun 24 '14 17:06 BernhardPosselt

Ive tested it locally right now, works perfectly fine.

Locally as in the web interface? This issue is about the api accessed by https.

phedlund avatar Jun 24 '14 19:06 phedlund

yes, via the API using postman chrome app

BernhardPosselt avatar Jun 24 '14 19:06 BernhardPosselt

OK, I have to decrypt the data myself. Is seems the blowfish algorithm is used, correct? How do I get the key for decryption, or what else do I need?

phedlund avatar Jun 25 '14 02:06 phedlund

Decrypt? Should be done for you when accessing the api

BernhardPosselt avatar Jun 25 '14 07:06 BernhardPosselt

You are right, it's not decryption that is needed. For some reason using my iOS code I actually get a 404 with the GET api calls when encryption is turned on. It works fine without ownCloud encryption. PUT for updating a note sort of works. The server gets the new data correctly but there is no json returned. Is something altered in the routes? Is there a specific header needed? I would think not since it works for me also using a REST client app in Firefox.

phedlund avatar Jun 26 '14 01:06 phedlund

Developers: I have successfully used curl to login and receive the encrypted notes from my owncloud by calling: curl --data "user=[USERNAME]&password=[PASSWORD]" -c- https://[OWNCLOUD-URL]/index.php -g https://[OWNCLOUD-URL]/index.php/apps/notes/api/v0.2/notes It seems that there is a redirection happening after posting the login data (no basic or digest auth used here!). The second request will use a HTTP GET to fetch the data using the contents of that cookie (use -c cookie.txt instead of -c- to store it in a file). I believe, that MyOwnNotes does not do it that way, probably not following that redirection. Also note, that owncloud has an option in it's config.php, which might automatically lead to an unexpected redirection which is 'forcessl' => true

urenzel avatar Jul 07 '14 16:07 urenzel

For me, your curl command results in a POST that creates a new note. If I add a note id at the end curl --data "user=[USERNAME]&password=[PASSWORD]" -c- https://[OWNCLOUD-URL]/index.php -g https://[OWNCLOUD-URL]/index.php/apps/notes/api/v0.2/notes/[NOTE_ID] I get the note back, but ONLY if encryption is disabled.

phedlund avatar Jul 07 '14 22:07 phedlund