You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **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.
67
64
68
65
# Usage
69
66
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.
71
68
72
69
### Global password protection
73
70
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
75
72
76
73
```yaml
77
74
plugins:
@@ -81,11 +78,11 @@ plugins:
81
78
82
79
If a password is defined in an article, it will **ALWAYS** overwrite the global password.
83
80
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** !
85
82
86
83
### Extra vars customization
87
84
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.
89
86
90
87
```yaml
91
88
plugins:
@@ -116,8 +113,7 @@ Defaut encryption information message is `Contact your administrator for access
116
113
117
114
> **Enable by default**
118
115
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.
121
117
122
118
When enable the following part of the template is add to force reloading decrypted content.
Related to [issue #12](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/12)
137
133
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.
142
137
143
138
```jinja
144
139
{% if arithmatex %}
@@ -156,10 +151,7 @@ Related to [issue #7](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/i
156
151
157
152
This feature add an additional attribute `encrypted` with value `True` to the mkdocs type `mkdocs.nav.page` object.
158
153
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),
163
155
164
156
When enable, it becomes possible to use `encrypted` attribute in the jinja template of your theme, as a condition to perform custom modification.
165
157
@@ -194,44 +186,41 @@ plugins:
194
186
195
187
Related to [issue #6](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/6)
196
188
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.
198
190
>
199
191
> Instead of using this feature, I recommend to use a password manager with its web plugins.
200
192
> 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.
201
193
202
194
If you do not have password manager, you can set `remember_password: True` in your `mkdocs.yml` to enable password remember feature.
203
195
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.
207
199
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.
210
202
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.
214
205
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 ...
217
208
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 :
223
210
```yaml
224
211
plugins:
225
212
- encryptcontent:
226
213
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)
228
215
```
229
216
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
231
220
232
221
Related to [issue #9](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/9)
233
222
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.
235
224
236
225
Add `encrypted_something: {}` in the plugin configuration variable, to encrypt something else.
237
226
@@ -254,7 +243,7 @@ Prefer to use an `'id'`, however depending on the template of your theme, it is
254
243
So we can use the class attribute to define your unique name inside html tag.
255
244
BeautifulSoup will encrypt all HTML elements discovered with the class.
256
245
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.
258
247
259
248
By default **every child items** are encrypted and the encrypted elements have `style=display:none` to hide their content.
260
249
@@ -313,29 +302,53 @@ plugins:
313
302
mkdocs-encrypted-footer-meta: [div, id]
314
303
```
315
304
305
+
### Search index encryption
316
306
317
-
### Do not encrypt search index
307
+
> **Default value is "encrypted"**
318
308
319
309
Related to [issue #13](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/13)
320
310
321
-
> :warning: **This feature is NOT SECURE and CAUSE DATA LEAK**
311
+
> :warning: **The configuration mode "clear" of this functionality can cause DATA LEAK**
322
312
>
323
313
> The unencrypted content of each page is accessible through the search index.
324
314
> Not encrypting the search index means completely removing the protection provided by this plugin.
325
315
> You have been warned
326
316
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**".
328
325
329
326
```yaml
330
327
plugins:
331
328
- encryptcontent:
332
-
decrypt_search: True
329
+
search_index: 'dynamically'
333
330
```
334
331
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.
336
333
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.
338
335
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
+
```
339
352
340
353
### Reload scripts
341
354
@@ -345,9 +358,8 @@ You can set `reload_scripts:` in your `mkdocs.yml` with list of script source, t
345
358
346
359
```yaml
347
360
plugins:
348
-
- encryptcontent:
349
-
reload_scripts:
350
-
- "./js/example.js"
361
+
reload_scripts:
362
+
- "./js/example.js"
351
363
```
352
364
353
365
This feature use the following JQuery function to remove, add and reload javascripts.
@@ -359,7 +371,6 @@ var reload_js = function(src) {
359
371
};
360
372
```
361
373
362
-
363
374
# Contributing
364
375
365
376
From reporting a bug to submitting a pull request: every contribution is appreciated and welcome.
0 commit comments