Skip to content

Commit 9173c58

Browse files
committed
add option for incomplete share links
1 parent 59acd5e commit 9173c58

File tree

10 files changed

+74
-16
lines changed

10 files changed

+74
-16
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ plugins:
467467
### Share link generation
468468

469469
It is possible to share valid credentials by adding them to the hash part of the URL.
470-
The plugin can also generate share links for certain pages if the metag tag `sharelink: true`
470+
The plugin can also generate share links for certain pages if the meta tag `sharelink: true`
471471
is defined in markdown.
472472
It will use the first credential for the pages level or the pages password.
473473
The credentials for auto-generated links are base64url encoded.
@@ -487,6 +487,17 @@ However if `sharelinks: True` is enabled in the plugin configuration you can gen
487487
> Then another condition applies: If non-aphanumeric characters are used in user/password,
488488
> they need to be URLencoded (f.ex. %20 = space character). Some browsers may do that automatically (Do a copy/paste from the browsers address bar then).
489489

490+
#### Incomplete Share links
491+
492+
Since version 3.0.3 it is possible to leave out one part of the password when share links are generated via meta tag.
493+
To do this use the ":" character in a password to divide the part that is incorporated to the share link and the part that remains secret,
494+
like "PartThatIsEncodedToTheShareLink:PartThatRemainsSecret".
495+
The feature is enabled by setting the option `sharelinks_incomplete: true`.
496+
If the password that is read from the share link ends with the ":" character, then an additional password input field is displayed for entering the secret part.
497+
498+
> If the feature is used, then passwords must not end with the ":" character.
499+
500+
490501
### Storage of additional variables in keystore
491502

492503
Since version 3.0.3 it is possible to set arbitrary session store variables after decryption.

documentation/docs/features/index.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ plugins:
124124
### Share link generation
125125

126126
It is possible to share valid credentials by adding them to the hash part of the URL.
127-
The plugin can also generate share links for certain pages if the metag tag `sharelink: true`
127+
The plugin can also generate share links for certain pages if the meta tag `sharelink: true`
128128
is defined in markdown.
129129
It will use the first credential for the pages level or the pages password.
130130
The credentials for auto-generated links are base64url encoded.
@@ -144,6 +144,17 @@ However if `sharelinks: True` is enabled in the plugin configuration you can gen
144144
> Then another condition applies: If non-aphanumeric characters are used in user/password,
145145
> they need to be URLencoded (f.ex. %20 = space character). Some browsers may do that automatically (Do a copy/paste from the browsers address bar then).
146146

147+
#### Incomplete Share links
148+
149+
Since version 3.0.3 it is possible to leave out one part of the password when share links are generated via meta tag.
150+
To do this use the ":" character in a password to divide the part that is incorporated to the share link and the part that remains secret,
151+
like "PartThatIsEncodedToTheShareLink:PartThatRemainsSecret".
152+
The feature is enabled by setting the option `sharelinks_incomplete: true`.
153+
If the password that is read from the share link ends with the ":" character, then an additional password input field is displayed for entering the secret part.
154+
155+
> If the feature is used, then passwords must not end with the ":" character.
156+
157+
147158
### Storage of additional variables in keystore
148159

149160
Since version 3.0.3 it is possible to set arbitrary session store variables after decryption.

documentation/docs/testbench/userpass1.de.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sharelink: true
99
Es ist möglich diese Seite mit einem der folgenden Benutzername/Passwort Kombinationen zu entschlüsseln:
1010

1111
- alice: Racoon Superstore obnoxious23
12-
- bob: AbidingScooterRuinedCCCactus
12+
- bob: AbidingScooterRuinedCC:Cactus
1313
- carol: Worry-Bony-Glide-Mace!
1414
- carlos: Arre5tConfused Pentagon
1515
- charlie: gear.code.blonde.at0ll
@@ -27,7 +27,7 @@ Wenn einer der unteren vier Benutzer eingegeben wird, dann wird auch [Benutzerna
2727
Eines dieser Benutzername/Passwort Kombinationen **wurde** verwendet um diese Seite zu entschlüsseln:
2828

2929
- alice: Racoon Superstore obnoxious23
30-
- bob: AbidingScooterRuinedCCCactus
30+
- bob: AbidingScooterRuinedCC:Cactus
3131
- carol: Worry-Bony-Glide-Mace!
3232
- carlos: Arre5tConfused Pentagon
3333
- charlie: gear.code.blonde.at0ll

documentation/docs/testbench/userpass1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ delete_id: teaser
88
The following user/passwords are valid to decrypt this page:
99

1010
- alice: Racoon Superstore obnoxious23
11-
- bob: AbidingScooterRuinedCCCactus
11+
- bob: AbidingScooterRuinedCC:Cactus
1212
- carol: Worry-Bony-Glide-Mace!
1313
- carlos: Arre5tConfused Pentagon
1414
- charlie: gear.code.blonde.at0ll
@@ -26,7 +26,7 @@ If you use one of the last four users, you'd also be able to decrypt [User/Passw
2626
One of the following user/passwords **were** used to decrypt this page:
2727

2828
- alice: Racoon Superstore obnoxious23
29-
- bob: AbidingScooterRuinedCCCactus
29+
- bob: AbidingScooterRuinedCC:Cactus
3030
- carol: Worry-Bony-Glide-Mace!
3131
- carlos: Arre5tConfused Pentagon
3232
- charlie: gear.code.blonde.at0ll

documentation/encryptcontent.cache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ password:
1212
SpotChestOilCycle22: 0155d08357940a620f4048ffcd66a3aa3be257d46e52d20098b026e2e2348f47;e1f147135505838c5e8d4bebd144c66f;6f166999fdb5968851efd563c9231546c349da41281db994ec67cc1eeef05c5e
1313
"TeGhD9aq\xDFQnHujmLdsa": a624d0f0390ac17556fa18cabc07fefc262641651e1b669448d19ab10a0f87f3;a5406e022938a90a7a4799fc641f2bbf;46ac08a4fdc9e7dcfd21bc4645e036d42bcf8c7c497a13d5e95f38aa67e29e1a
1414
"WOgh0\xDCwyKHoc*I_das": 9962c6b45cf7e0405304113014c15edc34f9d09538121e790089f7954a953961;53875d959cd9e911dcf442085c176353;2a9afc1fa2f32b7eb75c9052cc0c9978c4808763118afdb6e1baa2e1f365f04d
15-
"[Qw1=s.GK}:LuJ}sd\xF6dsa": d5570bb9ef13babc4ed053d335b702fc8f5e99a70d7975d78664c4573c537540;4341d368a8773909284dba2a4e5e32eb;b9d817f5c19914000dc0d2a23a7092da41eb37ff52869850d6ec0ec9f7711d9c
16-
"gncku\xE4shfliglkffhbvrG": 23cbb6650d67cb3ef3ef10f9cb87a3d10e066eef77a50a0e881a45d0e027b659;c934236bb1cb958d0a0a997061d7b1a0;c812e6cdd92c6db897b4382007c625c476df60a756b751b685440729c4cbaaca
15+
"gncku\xE4shfliglkffhbvrG:Wurst": 96cc0e8b569ce4fa9031d1c2f1bf541c7f89f14029d636cfd52d9d522ace5935;61b1f50904c93f99f75d94a07310cd9f;ccda65e51e9b4643dc381fae28c25dc882989da4fdcbdeb0807479a7b7b25231
1716
m00dy#augmented#Arsonist: ec59d0f5889f8a91ec6a5a4cf9de9c1e1c91af08e4b80822a763cc8a23fc30ec;73a844548f0eac55ffc5e3a293e42c0e;afe95398efc93acd6e37c1bb185e6b07d7ab944aea5a60c6187c717db8673bd5
1817
moist:W00l:kept:royal: 4e85a7361fcb8c8f9f0aebc4bae5506eb465b6b1ad115020956073fb8d7c7d4c;dd0d280832d255fb65d6a0c440c235f8;4bb6ed11fa82cb2f1c9b3ad5dd092e740adfa356fb49102793979fdb7181d1ac
1918
"yDAHKmYjmCsA\xE9kUChasd": c04d21a4eaad20c990773f9e2ec2f0525e762f9339145a7108e23e6a1538ed26;15f36cd61fcd1f72582aa424c3277675;0859304b34a323dd4388e6a7ff248f51dd8ca88d49804cb05dca84d92d2383dd

documentation/mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ plugins:
127127
myToc: [div, id]
128128
myTocButton: [div, id]
129129
search_index: 'dynamically' #dynamically
130-
password_button: True
130+
password_button: true
131131
selfhost: true
132132
selfhost_download: true
133133
selfhost_dir: 'theme_override'
@@ -137,6 +137,7 @@ plugins:
137137
password_file: 'passwords.yml'
138138
additional_storage_file: 'additional_storage.yaml'
139139
sharelinks: true
140+
sharelinks_incomplete: true
140141
#kdf_pow: 4
141142
webcrypto: true
142143
sign_files: 'encryptcontent-plugin.json'

documentation/passwords.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ onlypasswords2:
1717

1818
user_and_passwords1:
1919
alice: 'Racoon Superstore obnoxious23'
20-
bob: 'AbidingScooterRuinedCCCactus'
20+
bob: 'AbidingScooterRuinedCC:Cactus'
2121
carol: 'Worry-Bony-Glide-Mace!'
2222
carlos: 'Arre5tConfused Pentagon'
2323
charlie: 'gear.code.blonde.at0ll'
@@ -31,8 +31,9 @@ user_and_passwords2:
3131
dave: 'nuClear_lullaby_unveiled_g4rlic'
3232
david: 'establishRelishBlushV3nus'
3333

34-
test1: '[Qw1=s.GK}:LuJ}sdödsa'
35-
test2: 'gnckuäshfliglkffhbvrG'
34+
test1:
35+
bob: 'AbidingScooterRuinedCC:Cactus'
36+
test2: 'gnckuäshfliglkffhbvrG:Wurst'
3637
test3: 'yDAHKmYjmCsAékUChasd'
3738
test4: 'TeGhD9aqßQnHujmLdsa'
3839
test5: 'WOgh0ÜwyKHoc*I_das'

documentation/sharelinks.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/obfuscate/#ITpDcmF3bGVyIGJlIGdvbmUh
22
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/onlypasswords1/#ITpDbGlxdWUuU2hhbXBvby5WZTU1ZWw
3-
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test1/#ITpbUXcxPXMuR0t9Okx1Sn1zZMO2ZHNh
4-
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test2/#ITpnbmNrdcOkc2hmbGlnbGtmZmhidnJH
3+
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test1/#IWJvYjpBYmlkaW5nU2Nvb3RlclJ1aW5lZENDOg
4+
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test2/#ITpnbmNrdcOkc2hmbGlnbGtmZmhidnJHOg
55
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test3/#ITp5REFIS21Zam1Dc0HDqWtVQ2hhc2Q
66
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test4/#ITpUZUdoRDlhccOfUW5IdWptTGRzYQ
77
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/testbench/test5/#ITpXT2doMMOcd3lLSG9jKklfZGFz
8-
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test1/#ITpbUXcxPXMuR0t9Okx1Sn1zZMO2ZHNh
9-
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test2/#ITpnbmNrdcOkc2hmbGlnbGtmZmhidnJH
8+
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test1/#IWJvYjpBYmlkaW5nU2Nvb3RlclJ1aW5lZENDOg
9+
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test2/#ITpnbmNrdcOkc2hmbGlnbGtmZmhidnJHOg
1010
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test3/#ITp5REFIS21Zam1Dc0HDqWtVQ2hhc2Q
1111
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test4/#ITpUZUdoRDlhccOfUW5IdWptTGRzYQ
1212
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/de/testbench/test5/#ITpXT2doMMOcd3lLSG9jKklfZGFz

encryptcontent/decrypt-contents.tpl.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,29 @@ function base64url_decode(input) {
540540
username_input.value = sharestring.substring(0,pass_sep);
541541
}
542542
password_input.value = sharestring.substring(pass_sep+1);
543+
{%- if sharelinks_incomplete %}
544+
if (password_input.value.endsWith(':')) {
545+
if (username_input) {
546+
username_input.style.display = "none";
547+
}
548+
let password_input_sharelink = password_input.cloneNode()
549+
password_input_sharelink.id = "mkdocs-content-password-sharelink";
550+
password_input_sharelink.style.display = "none";
551+
password_input_sharelink.value = password_input.value;
552+
password_input.value = "";
553+
password_input.insertAdjacentElement('beforebegin', password_input_sharelink);
554+
} else {
555+
content_decrypted = {% if webcrypto %}await {% endif %}decrypt_action(
556+
username_input, password_input, encrypted_content, decrypted_content
557+
);
558+
decryptor_reaction(content_decrypted, password_input, decrypted_content);
559+
}
560+
{%- else %}
543561
content_decrypted = {% if webcrypto %}await {% endif %}decrypt_action(
544562
username_input, password_input, encrypted_content, decrypted_content
545563
);
546564
decryptor_reaction(content_decrypted, password_input, decrypted_content);
565+
{%- endif %}
547566
}
548567
}
549568
}
@@ -554,6 +573,12 @@ function base64url_decode(input) {
554573
if (decrypt_button) {
555574
decrypt_button.onclick = {% if webcrypto %}async {% endif %}function(event) {
556575
event.preventDefault();
576+
{%- if sharelinks_incomplete %}
577+
let password_input_sharelink = document.getElementById('mkdocs-content-password-sharelink');
578+
if (password_input_sharelink) {
579+
password_input.value = password_input_sharelink.value + password_input.value;
580+
}
581+
{%- endif %}
557582
content_decrypted = {% if webcrypto %}await {% endif %}decrypt_action(
558583
username_input, password_input, encrypted_content, decrypted_content
559584
);
@@ -565,6 +590,12 @@ function base64url_decode(input) {
565590
password_input.addEventListener('keypress', {% if webcrypto %}async {% endif %}function(event) {
566591
if (event.key === "Enter") {
567592
event.preventDefault();
593+
{%- if sharelinks_incomplete %}
594+
let password_input_sharelink = document.getElementById('mkdocs-content-password-sharelink');
595+
if (password_input_sharelink) {
596+
password_input.value = password_input_sharelink.value + password_input.value;
597+
}
598+
{%- endif %}
568599
content_decrypted = {% if webcrypto %}await {% endif %}decrypt_action(
569600
username_input, password_input, encrypted_content, decrypted_content
570601
);

encryptcontent/plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class encryptContentPlugin(BasePlugin):
8383
('additional_storage_file', config_options.Type(string_types, default=None)),
8484
('cache_file', config_options.Type(string_types, default='encryptcontent.cache')),
8585
('sharelinks', config_options.Type(bool, default=False)),
86+
('sharelinks_incomplete', config_options.Type(bool, default=False)),
8687
('sharelinks_output', config_options.Type(string_types, default='sharelinks.txt')),
8788
# default features enabled
8889
('arithmatex', config_options.Type(bool, default=None)),
@@ -368,6 +369,7 @@ def __generate_decrypt_js__(self):
368369
'webcrypto' : self.config['webcrypto'],
369370
'remember_prefix': quote(self.config['remember_prefix'], safe='~()*!\''),
370371
'sharelinks' : self.config['sharelinks'],
372+
'sharelinks_incomplete' : self.config['sharelinks_incomplete'],
371373
'material' : self.setup['theme'] == 'material',
372374
# add extra vars
373375
'extra': self.config['js_extra_vars']
@@ -1164,6 +1166,8 @@ def on_post_build(self, config, **kwargs):
11641166
sharelinks = []
11651167
for page in self.setup['sharelinks']:
11661168
username, password = self.setup['sharelinks'][page]
1169+
if self.config['sharelinks_incomplete'] and ':' in password:
1170+
password = password.rsplit(':',1)[0] + ":" # don't add the remaining part after the last ":" to the sharelink
11671171
sharelinks.append(config.data["site_url"] + page + '#' + self.__b64url_encode__('!' + username + ':' + password))
11681172
with open(self.setup['sharelinks_output'], 'w') as stream:
11691173
stream.write('\n'.join(sharelinks))

0 commit comments

Comments
 (0)