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

Dynamic search decryption in mkdocs-material #52

Closed ttran2 closed 6 months ago

ttran2 commented 12 months ago

I have set a global_password and used encrypted_something to hide the nav-bar (md-nav), tabs (md-tabs), and search-box (md-search). However, when providing the password and decrypting the page, only the nav-bar and tabs became visible, while the search-box was still hidden.

Here is a snippet from my mkdocs.yml

plugins:
  - search:
      indexing: 'full'
  - encryptcontent:
      search_index: 'clear'
      global_password: 'somepassword'
      encrypted_something:
        md-nav: [nav, class]
        md-tabs: [nav, class]
        md-search: [div, class]

PS. Yes, I am aware that setting the search_index to clear mode can make it possible to get the data by digging up the search indexes, however, downgrading the mkdocs-material to below 9.x.x (and then patching it) is too big of a drawback, and disabling search feature is also a huge drawback.

unverbuggt commented 12 months ago

Hi,

I've tested this and conclude that 'md-search' div is in fact correctly decrypted. However, normally there are events attached to 'md-search', 'md-searchform' and 'md-searchinput' and these events won't magically be attached after decryption. One could try to figure out how to reattach these in a reload_js script, but one might as well fix the dynamical search decryption for material.

The dynamical search decryption for material-theme is a thing I need for a project of ours, so this will hopefully be taken care of some time(TM). But it is not high priority, as the workaround with material 8 exists.
If anyone can help with this, it is highly appreciated.

While testing, I also found that the current material breaks other stuff as well, so thank you for bringing this up.

unverbuggt commented 11 months ago

...I found a way to hack into material 9 that allows modifying the search index.
But it is still only a hack, that exchanges the request to the "search_index.json" file by the modified search index in sessionStorage.

There is hope that material might cache the search index some day, where we could modify it by this plugin. Until then, patching is the not-so-bright-but-only solution I could come up with.

mkdocs_material-9.3.2-py3-none-any (patched encryptcontent-index).zip

ttran2 commented 11 months ago

Hi, thank you very much for the help and the patch, though I myself also ended up patching mkdocs-material myself, in order for it to fetch the search index from the sessionStorage 😅 https://github.com/ttran2/mkdocs-material/tree/support-decryption

W1ndys commented 6 months ago

嗨,非常感谢您的帮助和补丁,尽管我自己也最终修补了mkdocs-material自己,以便它search indexsessionStorage😅 https://github.com/ttran2/mkdocs-material/tree/support-获取解密

Hello, I would like to ask how to solve this problem. My document page cannot be searched after being encrypted, but it can be used without encryption. So I guess it is caused by the encryption plug-in. Could you please tell me the relevant solution. Thank you very much. you

unverbuggt commented 6 months ago

嗨,非常感谢您的帮助和补丁,尽管我自己也最终修补了mkdocs-material自己,以便它search indexsessionStorage😅 https://github.com/ttran2/mkdocs-material/tree/support-获取解密

Hello, I would like to ask how to solve this problem. My document page cannot be searched after being encrypted, but it can be used without encryption. So I guess it is caused by the encryption plug-in. Could you please tell me the relevant solution. Thank you very much. you

Please open up a new issue. I'm going to hide your comment. If you only added one plugin (encryptcontent) to the plugins: section of "mkdocs.yml", then you'll need to manually add "search" there as well (see here).

W1ndys commented 6 months ago

嗨,非常感谢您的帮助和补丁,尽管我自己也最终修补了mkdocs-material自己,以便它search indexsessionStorage😅 https://github.com/ttran2/mkdocs-material/tree/support-获取解密

Hello, I would like to ask how to solve this problem. My document page cannot be searched after being encrypted, but it can be used without encryption. So I guess it is caused by the encryption plug-in. Could you please tell me the relevant solution. Thank you very much. you

Please open up a new issue. I'm going to hide your comment. If you only added one plugin (encryptcontent) to the plugins: section of "mkdocs.yml", then you'll need to manually add "search" there as well (see here).

Yes, thank you for your answer. I accidentally discovered this issue during a debugging process and added search. Thank you very much