Skip to content

Commit 4abe4e6

Browse files
committed
Version 2.0.0
2 parents 2fd2b1f + 9b8db06 commit 4abe4e6

File tree

9 files changed

+4235
-314
lines changed

9 files changed

+4235
-314
lines changed

README.md

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ The content is encrypted with AES-256 in Python using PyCryptodome, and decrypte
2929
* [HighlightJS support](#highlightjs-support) *(default)*
3030
* [Arithmatex support](#arithmatex-support) *(default)*
3131
* [Tag encrypted page](#tag-encrypted-page) *(default)*
32-
* [Add button](#add-button)
3332
* [Rebember password](#rebember-password)
3433
* [Encrypt something](#encrypt-something)
35-
* [Do not encrypt search index](#do-not-encrypt-search-index)
34+
* [Search index encryption](#search-index-encryption)
35+
* [Add button](#add-button)
3636
* [Reload scripts](#reload-scripts)
3737
* [Contributing](#contributing)
3838

@@ -50,28 +50,25 @@ Install the package from source with pip:
5050
```bash
5151
cd mkdocs-encryptcontent-plugin/
5252
python3 setup.py sdist bdist_wheel
53-
pip3 install dist/mkdocs_encryptcontent_plugin-1.2.2-py3-none-any.whl
53+
pip3 install dist/mkdocs_encryptcontent_plugin-2.0.0.1-py3-none-any.whl
5454
```
5555

5656
Enable the plugin in your `mkdocs.yml`:
5757

5858
```yaml
5959
plugins:
60-
- search:
60+
- search: {}
6161
- encryptcontent: {}
6262
```
63-
64-
> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin.
65-
> MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.
66-
63+
> **NOTE:** If you have no `plugins` entry in your configuration file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.
6764

6865
# Usage
6966

70-
Add an meta tag `password: secret_password` in your markdown files to protect the
67+
Add an meta tag `password: secret_password` in your markdown files to protect them.
7168

7269
### Global password protection
7370

74-
Add `global_password: your_password` in plugin config variable, to protect by default your articles with this password
71+
Add `global_password: your_password` in plugin configuration variable, to protect by default your articles with this password
7572

7673
```yaml
7774
plugins:
@@ -81,11 +78,11 @@ plugins:
8178

8279
If a password is defined in an article, it will **ALWAYS** overwrite the global password.
8380

84-
> **NOTE** Keep in mind that if the `password:` tag exists without value in an article, it will not be protected !
81+
> **NOTE** Keep in mind that if the `password:` tag exists without value in an article, it will **not be protected** !
8582

8683
### Extra vars customization
8784

88-
Optionally you can use some extra variables in plugin config to customize default messages.
85+
Optionally you can use some extra variables in plugin configuration to customize default messages.
8986

9087
```yaml
9188
plugins:
@@ -116,8 +113,7 @@ Defaut encryption information message is `Contact your administrator for access
116113

117114
> **Enable by default**
118115

119-
If HighlightJS module is detected in your theme, reload colors renderer after decryption process.
120-
If HighlightJS module is not correctly detected, you can force it by adding `hljs: True` on the plugin configuration or set `hljs: False` to disable this feature.
116+
If HighlightJS module is detected in your theme to improve code color rendering, reload renderer after decryption process. If HighlightJS module is not correctly detected, you can force the detection by adding `hljs: True` on the plugin configuration or set `hljs: False` to disable this feature.
121117

122118
When enable the following part of the template is add to force reloading decrypted content.
123119

@@ -135,10 +131,9 @@ document.getElementById("mkdocs-decrypted-content").querySelectorAll('pre code')
135131

136132
Related to [issue #12](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/12)
137133

138-
If Arithmatex markdown extension is detected in your markdown extensions, reload math equation rendering after decryption process.
139-
If Arithmatex markdown extension is not correctly detected, you can force it by adding `arithmatex: True` on the plugin configuration or set `arithmatex: False` to disable this feature.
140-
141-
When enable the following part of the template is add to force math equations rendering on decrypted content.
134+
If Arithmatex markdown extension is detected in your markdown extensions to improve math equations rendering, reload renderer after decryption process. If the Arithmatex markdown extension is not correctly detected, you can force the detection by adding `arithmatex: True` on the plugin configuration or set `arithmatex: False` to disable this feature.
135+
136+
When enable, the following part of the template is add to force math equations rendering on decrypted content.
142137

143138
```jinja
144139
{% if arithmatex %}
@@ -156,10 +151,7 @@ Related to [issue #7](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/i
156151

157152
This feature add an additional attribute `encrypted` with value `True` to the mkdocs type `mkdocs.nav.page` object.
158153

159-
You can add `tag_encrypted_page: False` in plugin configuration, to disable tagging of encrypted pages.
160-
This feature is neccessary for others feature working correctly.
161-
162-
If you disable this feature, **do no use** [Encrypt Somethings](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#encrypt-something),
154+
You can add `tag_encrypted_page: False` in plugin configuration, to disable tagging of encrypted pages. **BUT** This feature is neccessary for others feature working correctly. If you disable this feature, do no use [Encrypt Somethings](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#encrypt-something),
163155

164156
When enable, it becomes possible to use `encrypted` attribute in the jinja template of your theme, as a condition to perform custom modification.
165157

@@ -194,44 +186,41 @@ plugins:
194186
195187
Related to [issue #6](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/6)
196188
197-
> :warning: **This feature is not really secure !** Password are store in clear text inside local cookie without httpOnly flag.
189+
> :warning: **This feature is not really secure !** Password are store in clear text inside local storage.
198190
>
199191
> Instead of using this feature, I recommend to use a password manager with its web plugins.
200192
> For example **KeepassXC** allows you, with a simple keyboard shortcut, to detect the password field `mkdocs-content-password` and to fill it automatically in a much more secure way.
201193

202194
If you do not have password manager, you can set `remember_password: True` in your `mkdocs.yml` to enable password remember feature.
203195

204-
When enabled, each time you fill password form and press `Enter` a cookie is create with your password as value.
205-
When you reload the page, if you already have an 'encryptcontent' cookie in your browser,
206-
the page will be automatically decrypted using the value of the cookie.
196+
When enabled, each time you fill password form and press `Enter` a key on local storage is create with your password
197+
as value. When you reload the page, if you already have an 'encryptcontent' key in the local storage of your browser,
198+
the page will be automatically decrypted using the value previously created.
207199

208-
By default, the cookie is created with a `path=` relative to the page on which it was generated.
209-
This 'specific' cookie will always be used as first attempt to decrypt the current page when loading.
200+
By default, the key is created with a name relative to the page on which it was generated.
201+
This 'relative' key will always be used as first attempt to decrypt the current page when loading.
210202

211-
If your password is a global password, you can fill in the `mkdocs-content-password` field,
212-
then use the keyboard shortcut `CTRL + ENTER` instead of the classic `ENTER`.
213-
The cookie that will be created with a `path=/` making it accessible, by default, on all the pages of your site.
203+
If your password is a [global password](#global-password-protection), you can fill in the form field `mkdocs-content-password`, then use the keyboard shortcut `CTRL + ENTER` instead of the classic `ENTER`.
204+
The key that will be created with a generic name to making it accessible, by default, on all the pages of your site.
214205

215-
The form of decryption remains visible as long as the content has not been successfully decrypted,
216-
which allows in case of error to modify the created cookie.
206+
The form of decryption remains visible as long as the content has not been successfully decrypted, which allows in case of error to retry.
207+
All keys created with this feature on localstorage have an default expire time daly set to 24 hours, just cause ...
217208

218-
All cookies created with this feature have the default security options `Secure` and` SameSite=Strict`, just cause ...
219-
220-
However *(optionally)*, its possible to remove these two security options by adding `disable_cookie_protection: True` in your` mkdocs.yml`.
221-
222-
Your configuration should look like this when you enabled this feature :
209+
However *(optionally)*, its possible to change the default expire time by setting options `default_expire_dalay: <number>` in your `mkdocs.yml`. Your configuration should look like this when you enabled this feature :
223210
```yaml
224211
plugins:
225212
- encryptcontent:
226213
remember_password: True
227-
disable_cookie_protection: True # <-- Really a bad idea (Dev mode)
214+
default_expire_dalay: 24 # <-- Default expire delay in hours (optional)
228215
```
229216

230-
### Encrypt Something
217+
> **NOTE** The expired elements of the localStorage are only deleted by the execution of the decrypt-content.js scripts and therefore by the navigation on the site. Secret items can therefore remain visible in local storage after their expiration dates.
218+
219+
### Encrypt something
231220

232221
Related to [issue #9](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/9)
233222

234-
The [tag encrypted page feature](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#tag-encrypted-page) **MUST** be enabled *(it's default)* for this feature to work properly.
223+
The [tag encrypted page feature](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#tag-encrypted-page) **MUST** be enabled (it's default) for this feature to work properly.
235224

236225
Add `encrypted_something: {}` in the plugin configuration variable, to encrypt something else.
237226

@@ -254,7 +243,7 @@ Prefer to use an `'id'`, however depending on the template of your theme, it is
254243
So we can use the class attribute to define your unique name inside html tag.
255244
BeautifulSoup will encrypt all HTML elements discovered with the class.
256245

257-
When the feature is enabled, you can use any methods *(password, button, cookie)* to decrypt every elements encrypted on the page.
246+
When the feature is enabled, you can use any methods *(password, button, remember)* to decrypt every elements encrypted on the page.
258247

259248
By default **every child items** are encrypted and the encrypted elements have `style=display:none` to hide their content.
260249

@@ -313,29 +302,53 @@ plugins:
313302
mkdocs-encrypted-footer-meta: [div, id]
314303
```
315304

305+
### Search index encryption
316306

317-
### Do not encrypt search index
307+
> **Default value is "encrypted"**
318308

319309
Related to [issue #13](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/13)
320310

321-
> :warning: **This feature is NOT SECURE and CAUSE DATA LEAK**
311+
> :warning: **The configuration mode "clear" of this functionality can cause DATA LEAK**
322312
>
323313
> The unencrypted content of each page is accessible through the search index.
324314
> Not encrypting the search index means completely removing the protection provided by this plugin.
325315
> You have been warned
326316

327-
You can set `decrypt_search: True` in your `mkdocs.yml` to disable the search index encryption process.
317+
This feature allows you to control the behavior of the encryption plugin with the search index.
318+
Three configuration modes are possible:
319+
320+
* **clear** : Search index is not encrypted. Search is possible even on protected pages.
321+
* **dynamically** : Search index is encrypted on build. Search is possible once the pages have been decrypted ones.
322+
* **encrypted** : Search index is encrypted on build. Search is not possible on all encrypted pages.
323+
324+
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**".
328325

329326
```yaml
330327
plugins:
331328
- encryptcontent:
332-
decrypt_search: True
329+
search_index: 'dynamically'
333330
```
334331

335-
It becomes possible again to make searches on all the pages, even if the content of the page is encrypted.
332+
This functionality overwrite the index creation function of the “search” plug-in provided by mkdocs. The modifications carried out make it possible to encrypt the content of the search index *after* the default plugin has carried out these treatments *(search configuration)*. It is therefore dependent on the default search plugin.
336333

337-
If you still want to protect some pages, even though the search index is not encrypted, you can use [mkdocs-exclude-search](https://github.com/chrieke/mkdocs-exclude-search) to exclude parts or complete articles from the search index.
334+
When the configuration mode is set to "**dynamically**", the [javascripts contribution files](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/tree/experimental/encryptcontent/contrib/templates/search) 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.
338335

336+
> **NOTE** The mode 'dynamically' is currently **not compatible with Material Theme** !
337+
338+
### Add button
339+
340+
Add `password_button: True` in plugin configuration variable, to add button to the right of the password field.
341+
342+
When enable, it allows to decrypt the content just like the classic keypress ENTER. If remember password feature is activated, use button to decrypt generate a 'relative' key on your local storage. You cannot use password button to create global password value.
343+
344+
Optionnally, you can add `password_button_text: 'custom_text_button'` to customize the button text.
345+
346+
```yaml
347+
plugins:
348+
- encryptcontent:
349+
password_button: True
350+
password_button_text: 'custom_text_button'
351+
```
339352
340353
### Reload scripts
341354
@@ -345,9 +358,8 @@ You can set `reload_scripts:` in your `mkdocs.yml` with list of script source, t
345358

346359
```yaml
347360
plugins:
348-
- encryptcontent:
349-
reload_scripts:
350-
- "./js/example.js"
361+
reload_scripts:
362+
- "./js/example.js"
351363
```
352364

353365
This feature use the following JQuery function to remove, add and reload javascripts.
@@ -359,7 +371,6 @@ var reload_js = function(src) {
359371
};
360372
```
361373

362-
363374
# Contributing
364375

365376
From reporting a bug to submitting a pull request: every contribution is appreciated and welcome.

0 commit comments

Comments
 (0)