Search encryption
Search index encryption
Related to issue #13
This feature allows you to control the behavior of the encryption plugin with the search index. Three configuration modes are possible:
- clear : Search index is not encrypted. Search is possible even on protected pages.
- dynamically : Search index is encrypted on build. Search is possible once the pages have been decrypted.
- encrypted : Search index of encrypted pages is removed on build. Search is not possible on encrypted pages.
You can set search_index: '<mode_name>'
in your mkdocs.yml
to change the search index encryption mode. Possible values are clear
, dynamically
, encrypted
. The default mode is "encrypted".
plugins:
- encryptcontent:
search_index: 'dynamically'
This functionality modifies the search index created by the “search” plug-in.
Some themes might override the default search plug-in provided by mkdocs,
but so far the structure of the search/search_index.json
file is consistent.
When the configuration mode is set to "dynamically", the javascripts contribution files are used to override the default search plugin files provided by MkDocs. They include a process of decrypting and keeping the search index in a SessionStorage.
Search index encryption for mkdocs-material
Material for MkDocs uses a different search plugin that
cannot "easily" be overridden like the default search plugin.
However this Plugin will still remove encrypted pages (encrypted
) or encrypt the search entries (dynamically
)
for mkdocs-material
.
In order to be able to decrypt the search index (dynamically
) mkdocs-material
needs to be customized (patched).
Patches for different versions can be found here.
Material 8.x
You'll need some prerequisites and also execute these commands:
git clone https://github.com/squidfunk/mkdocs-material
cd mkdocs-material
pip install mkdocs-minify-plugin
pip install mkdocs-redirects
npm install
#copy material_search_worker.patch to mkdocs-material
patch -p 0 < material_search_worker8.patch
pip install --force-reinstall .
#pip install --force-reinstall --no-deps . #faster if mkdocs-material was already installed
Material 9.x
Follow the instructions for Theme development carefully.
Apply the patch before Building the theme:
patch -p 0 < material_browser_request9.patch # until Material 9.3
patch -p 0 < material_browser_request9_4p.patch # Material 9.4+