unverbuggt / mkdocs-encryptcontent-plugin

A MkDocs plugin that encrypt/decrypt markdown content with AES
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/
MIT License
123 stars 15 forks source link

search also gets encrypted #13

Closed abhimanyuchawla closed 3 years ago

abhimanyuchawla commented 3 years ago

I am encrypting all pages using a global password, and it turns out the search index file (site/search/search_index.json) also gets encrypted. When viewing the site in a browser, I am able to decrypt each page using the global password, but the search is still encrypted.

One would expect the search to also get decrypted after supplying the global password. Is there a way you could fix this, or add some option which prevents the search_index.json file to get encrypted in the first place.

Thank you.

CoinK0in commented 3 years ago

I confirm that on the current version (1.0.0) the search does not work on encrypted pages. I added an option do-not-encrypt-search-index to choose if the 'text' search index should be encrypted or not, in version 1.1.0.

I continue to check if it would be possible to, fully or partially, decrypt the search index 'on the fly' when entering a password. But it seems complicated to generalize since the search engines are included in theme's and therefore specific. And this process should be entirely done in JS, which is definitely not my thing ... :dizzy_face:

abhimanyuchawla commented 3 years ago

Hi, Thanks for your prompt fix, much appreciated. I confirm that version 1.1.0 allows one to exclude the search index from encryption. It would be nice to have the search decrypted 'on the fly', but I understand it would be tough to do that for all search engines. But this fix works for my use case, thanks once again!

CoinK0in commented 3 years ago

Your welcome.

I keep trying to make a version of the search engine that could decrypt the search index 'on the fly' and be integrated easly to any template. I probably make a new version if I get a result that's satisfy me.

I close this issue. Fell free to open a new issue if you have any troubles :)

CoinK0in commented 3 years ago

I pushed some time ago an experimental branch Search index encryption. I added different way of managing the search index with this encryption plugin. One mode, "dynamically", seems to meet your expectations.

Could you try it ? Do you have an opinion on it ? Your feedback are welcome :)

abhimanyuchawla commented 3 years ago

Hi Sorry for the delay, I was on vacation. Thanks for adding this feature. I tried the experimental branch and used the 'dynamically' mode, however the search stays encrypted even after supplying the password on the page.

Is it possible that since I am using Material theme that the feature is not working? Thanks.

CoinK0in commented 3 years ago

I confirm this feature does not work with the Material theme :/ The Material theme modifies the way searches work after generating the site by adding its own javascript files. I haven't been able to find a "clean" way to transform these files from this plugin.

I will try to make the necessary modifications in the Javascript files used by the Material theme to reproduce the behaviour with the default theme from mkdocs. I could not automatically manage the modifications / installation of these modified files, so it will probably be necessary to manually modify the javascript files in the Material themes (With all the implications that this will have on version upgrades, bug fixes , etc.).

Thank you for taking it to try this feature and for providing feedback on its use.

abhimanyuchawla commented 3 years ago

Thank you for your efforts. Much appreciated.