Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.kdbx file in nextcloud don't open in keeweb #34

derjohannes19 opened this issue Dec 18, 2016 · 87 comments

.kdbx file in nextcloud don't open in keeweb #34

derjohannes19 opened this issue Dec 18, 2016 · 87 comments


Copy link

@derjohannes19 derjohannes19 commented Dec 18, 2016

When I click on a .kdbx file the file will get downloaded, and it don't get open in keeweb.

Also: Webdav is not working, i get http 401 error.

Copy link

@aalaesar aalaesar commented Dec 19, 2016

tested on nextcloud 11.0.0 & 10.0.2

Copy link

@jackxb jackxb commented Dec 19, 2016

tested on nextcloud 11.0.0

Copy link

@xamindar xamindar commented Dec 20, 2016

Same issue here. Just installed it in nextcloud 11 and nothing has changed regarding clicking on kdbx files. Click on them, and they are downloaded. They do not open in keeweb.

Copy link

@geiseri geiseri commented Dec 21, 2016

Same here on 11.

Copy link

@scottharwell scottharwell commented Dec 21, 2016

I don't intend to add another "me too", but I have some other details. I have found that if I disable the app on Nextcloud 11, and then restart it, then I am able to select a keepass db for about 30 mins. After that, the webdav connection seems to "break" and keeweb seems to move the open DB to a managed db outside of the Nextcloud integration. I then get the download behavior that others describe. Deleting the connection from keeweb, disabling keeweb, enabling keeweb, and reopening the ldbx file then allows me to use it again. Maybe this behaviour description will help.

Copy link

@ghost ghost commented Dec 21, 2016

After install the KeeWeb App inside NC11.0.0, you can choose a .kdbx file only one time by klicking the file itself.
When you edit a entry or add one, there is no sync back to the main .kdbx database.
Error: HTTP status 401
So now i cant found a way to drop the file from the WebApp...

Copy link

@Yamakasi Yamakasi commented Dec 24, 2016

Opening in Keeweb worked for me but just stopped without updating anything, only my browser (Chromium) is updated.

Copy link

@Huster-at-github Huster-at-github commented Dec 24, 2016

Same here. Does it need to be registered as a mimetype?

Copy link

@Yamakasi Yamakasi commented Dec 24, 2016

I'm not sure, when I had a browsercache issue when upgraded to NC11 it just worked like that after I fixed that (cleared more hours of cache) and now it just stopped.

I thought I needed Webdav so was kinda surprised that clicking on it just worked!

I hope @jhass that he can give us some idea.

Copy link

@nschiwy nschiwy commented Dec 25, 2016

I've now been able to "fix" this twice by disabling and then re-enabling the app. For the time being I'm probably just going to use a URL shortener to open the URL, which tells it the nextcloud location of the database. (ex. though I can't be sure whether this will allow it to save correctly...

Copy link

@Yamakasi Yamakasi commented Dec 25, 2016

Re-enabeling is a very good tip, this works indeed and happened also at my side when I had caching issues and re-enabled the app after emptying my cache. Maybe some mimetype magic happens in the browsercache when you enable it ?

Copy link

@rocky4546 rocky4546 commented Dec 25, 2016

[updated] I have some info that may help. First, I found the command to update the database indexes that will cause files located in the data area to launch KeeWeb. This command is
sudo -u www-data php [nextcloud home]/occ -vvv files:scan --all

I still have issues, but this is very close. If the file in the data area is updated, either from KeeWeb or externally updated by KeePass, it will break versioning and sharing. Running the occ command will fix launching KeyWeb, but the bugs for versioning and sharing still exist. This is not an option for me since I would like multiple people to access the password file.

The solution I found is to put the file in an external storage area. Uploading the file and then running the occ command seems to make it work. Any updates and running the occ command will also make it work. I plan to run multiple cronjobs with this command. One every so often that does the entire system and others that run very often for places that KeePass files are kept. The command to run only on a specific folder is
sudo -u www-data php [nextcloud home]/occ -vvv --path=/[admin]/files/[external path] files:scan

At some point in the future, it would be nice to not have to have these workarounds in place, but I think I am good for now. Good Luck

Copy link

@juanjux juanjux commented Dec 31, 2016

As a tip, you don't need to disable and reenable the app to use the file from Keeweb: if you open the Keeweb app from the initial app menu the file will show in the list and opening it from there will work even if Keeweb doesn't open from the Files app.

Copy link

@Yamakasi Yamakasi commented Dec 31, 2016

Copy link

@dnauck dnauck commented Jan 7, 2017

For me the workaround with disable/enable the app or scan all files does not help.

I' ve the following message in my java script console:

Resource interpreted as Document but transferred with MIME type application/octet-stream

Looks like the mime type is not registered.

Copy link

@gadolithium gadolithium commented Jan 8, 2017

+1 tested on NC 11.0.0.

Copy link

@dennisheitmann dennisheitmann commented Jan 14, 2017

+1 does not work (click on file in NC 11)

Copy link

@juanjux juanjux commented Jan 14, 2017

@Yamakasi it's true, a little later I lost the session and it dissapeared from the "recent files" list. But maybe I found another workaround? Tested with several different browsers, computers, networks and incognito mode so the session shouldn't exist. If you go directly to the keeweb + file URL like:

It seems to work.

Copy link

@thegrojas thegrojas commented Jan 16, 2017

Tested on Nextcloud 11.0.0

Copy link

@juanjux juanjux commented Jan 16, 2017

Yes, this is still happening on 11.0.1.

Copy link

@SonireolxXx SonireolxXx commented Jan 18, 2017

Same problem here on NC 11.0.1
I'm using WebDAV to sync with other devices, once the file is updated by other clients this problem occurs.

Copy link

@mwalbeck mwalbeck commented Jan 18, 2017

I think I've nailed down the issue. When you edit and save a file, keeweb saves it in a new file with a unix timestamp after the name then proceeds to delete the old file and rename the new one to remove the timestamp. Nextcloud registers the file with the unix timestamp as the extension and caches that information, so the cached mimetype is wrong. It's saved as a hidden file.

Also the way the kdbx mimetype is registered, if you upload a keepass file after you've enabled the app it will be cached with a generic mimetype instead of the kdbx mimetype. I don't really know the details on this one.

You shouldn't use the fix below. It has had serious performance issues for some people. Rather look at the fix here #34 (comment)

I've created a small fix for the above. It's not the best solution but It works. It simply changes the mimetype of any .kdbx file in the filecache everytime you reload a page in nextcloud, so it might effect performance depending on your setup.

If you add

$mimetypeId = $mimeTypeLoader->getId('x-application/kdbx');
$mimeTypeLoader->updateFilecache('%.kdbx', $mimetypeId);


// Register custom mimetype we can hook in the frontend
$mimeTypeDetector->registerType('kdbx', 'x-application/kdbx', 'x-application/kdbx');

In your appinfo/app.php file you should be good. (It's at the bottom)

I can make a pull request if there is interest for this, but none the less I'll try to find a more elegant solution and make a pull request with that instead.

Copy link

@SonireolxXx SonireolxXx commented Jan 18, 2017

@mwalbeck Thank you for the solution, I just tried it on NC 11.0.1 and it works, didn't notice any significant impact on performance.

I think this is the best approach for the issue so far.

Copy link

@Yamakasi Yamakasi commented Jan 19, 2017

Copy link

@mwalbeck mwalbeck commented Jan 24, 2017

@jhass I've send a pull request to upstream nextcloud to fix the issue with mimetype detection on hidden files I talked about here #38. This is only half the problem though. From what I've found the mimetype detection doesn't utilize the oc_mimetypes database tables to look up mimetypes. So the only proper way to currently register the mimetype is in the mimetypemapping file in nextcloud server. So if the mimetype is registered with upstream nextcloud this issue would be resolved with the release of nextcloud 12.


Copy link

@jhass jhass commented Jan 24, 2017

Well, registering the mimetype upstream would certainly work, but that feels like a band-aid to a missing feature in the app API, so I'd prefer to either have the detection use the database or have an API to ship a mimetype used for detection with an app, for example by shipping another json file that's aggregated with the default one.

Copy link

@guddl guddl commented Jan 25, 2017

I had this problem when I resticted the app to be available for a special group only.
After removing the group from "Enable only for specific groups" everything works fine again.

Copy link

@theScrabi theScrabi commented Oct 10, 2017

Yes I can confirm. That worked :)

Copy link

@kevquirk kevquirk commented Oct 12, 2017

I've not tested this workaround yet, but would updating the mimetype be required every time there is an NC update? Frustrating if that's the case. :(

Copy link

@mammuth mammuth commented Oct 13, 2017

@kevquirk The webupdater does not override settings in the config. After the last updates I didn't need to update the mimetypes.

Copy link

@kepuvv kepuvv commented Oct 18, 2017

Thank, zeigerpuppy! Its work for me

@rgeber rgeber mentioned this issue Oct 26, 2017
Copy link

@DMW007 DMW007 commented Oct 31, 2017

I can confirm that the mime-mapping from @zeigerpuppy is working fine on Nextcloud 12. Seems like that the command read the mimetypemappings.json file and copy all those mapping in the database. So afaik it should be possible for the nextcloud-keeweb extension to register it's mapping autmatically after installation?

If not, I agree that we should at least refer to this issue in the documentation/installation guide. Otherwise, a lot of people are wasting time to find out why this is not working. I also did cause it's confusing.

Copy link

@ppmt ppmt commented Nov 18, 2017

My instance of NextCloud is on a hosted site so I don't have access to the command line. Is there another way to update the mime and database?

Copy link

@ggeorgg ggeorgg commented Nov 20, 2017

Upload the following cmd.phpx file to your nextcloud root.
I also had to comment out line 39 in console.php (I am on nextcloud 12.0.3 with php 7.1 cgi, no php 5.6.0)
Open your browser and navigate to the cmd.phpx you have recently uploaded (e.g.
That should do it.
At least undo your changes. Delete the cmd.phpx again and comment in the line in console.php, otherwise your nextcloud instance will complain the next time you want to update)

Copy link

@ppmt ppmt commented Nov 20, 2017

@ggeorg : thanks a lot for the script. I can now open my keepass file from Nextcloud!

I had to activate a module called posix to make the script work and rename it to php from phpx

Copy link

@ludenticus ludenticus commented Nov 24, 2017

Enabling/disabling the app has no effect on Nextcloud 12.0.3

Copy link

@sunjam sunjam commented Dec 6, 2017

I've read through this thread and tried to setup Keeweb Webdav access on Nextcloud 12.0.4, but error I get is a little different.

Copy link

@sbrl sbrl commented Dec 6, 2017

@sunjam I'd suggest opening a separate issue about that.

Copy link

@sesipod sesipod commented Dec 29, 2017

I got it working on Nextcloud 12.0.4 - Debian 9 x64

I put my .kdbx on an " SMB / CIFS " share.
Added the mimetypemapping.json file & restarted apache2.

I now can open the .kdbx form the SMB storage location.
Working for me on the following browsers....
Chrome Version 64.0.3282.39 (Official Build) beta (32-bit)
Firefox 57.0.3 (64-bit)

@jhass jhass mentioned this issue Jan 4, 2018
Copy link

@twocoolbeans twocoolbeans commented Feb 7, 2018

Wanted to add (clarify) a workaround. Granted have never been able to edit a .kdbx file in Nextcloud but this will work for opening and otherwise using a database. Use a bookmark pointing to one's .kdbx database such as: https://server/index.php/apps/keeweb/?open=/AnyFolder/Keepass-database.kdbx

Nextcloud has a bookmarking app that one could put this URL into or could keep in it a simple text document. Not ideal but works.

Copy link

@zerpex zerpex commented Feb 14, 2018

Don't understand this issue, I got it working since Nextcloud 11 & 12 & 13.
many kdbx files on nextcloud file manager : a click on one of them open it directly on keypass... The expected behaviour, right ?

Using Nextcloud on docker with hoellen/nextcloud image :

Copy link

@DovendyrE DovendyrE commented Apr 9, 2018

I'm currently using keeweb in nextcloud 13.0.1
Just edited the /var/www/nextcloud/apps/keeweb/appinfo/info.xml to make it support nextcloud 13 then ran the command below to update mimetypes, and wokrs like charm here.
sudo -u www-data php /var/www/nextcloud/occ maintenance:mimetype:update-db --repair-filecache

PS. this command worked for me when I was still using nextcloud 12.

Copy link

@danger89 danger89 commented Apr 26, 2018

So is it fixed or.. does it still require manual actions from the admin?

Copy link

@jhass jhass commented Feb 11, 2019

Please update to 0.5.0. Pay attention to the required manual steps outlined in the readme.

I really whish there was a better way still...

@jhass jhass closed this Feb 11, 2019
Copy link

@Mycah Mycah commented Sep 19, 2019

I'm having this issue in 16.0.4 with keeweb 0.5.1
I opened an issue with nextcloud

Copy link

@pwnoobz pwnoobz commented Sep 22, 2019

I'm still having this issue on the last version of NextCloud and Debian9.

Copy link

@kugiigi kugiigi commented Oct 11, 2019

My problem here is that everytime the kdbx file is updated or it's newly uploaded, it's not detected correctly until I run file scan or update mimetype filecache. Does this really need to have a custom cron?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.