Encryption makes files inaccessible for app APIs
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.
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
Notes APP uses the view class
Steps to reproduce
- Install and enable Notes app
- Enable ownCloud encryption
- 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
I don't think the 401 Unauthorized is raised by the encryption app. Could be something else.
@Raydiation So have you tested the notes app with encryption or do you know if someone else who used it successfully?
Ive tested it locally right now, works perfectly fine.
Ive tested it locally right now, works perfectly fine.
Locally as in the web interface? This issue is about the api accessed by https.
yes, via the API using postman chrome app
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?
Decrypt? Should be done for you when accessing the api
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.
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
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.