Skip to content

Commit 86b68e6

Browse files
authored
argon2 as an optional dependency (#532)
In setups where passwords are not used, it is preferential to not have argon2 be an optional dependency: - If not used, let us not import it - argon2 has C-extensions, so it should ideally not be a hard requirement unless we can avoid it It should still be a install requirement, as it is used by default, but pip allows you to side step that if you insist.
1 parent 19ab0a9 commit 86b68e6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jupyter_server/auth/security.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import traceback
1313
import warnings
1414

15-
import argon2
16-
import argon2.exceptions
17-
from argon2 import PasswordHasher
1815
from ipython_genutils.py3compat import cast_bytes, str_to_bytes, cast_unicode
1916
from traitlets.config import Config, ConfigFileNotFound, JSONFileConfigLoader
2017
from jupyter_core.paths import jupyter_config_dir
@@ -63,7 +60,8 @@ def passwd(passphrase=None, algorithm='argon2'):
6360
raise ValueError('No matching passwords found. Giving up.')
6461

6562
if algorithm == 'argon2':
66-
ph = PasswordHasher(
63+
import argon2
64+
ph = argon2.PasswordHasher(
6765
memory_cost=10240,
6866
time_cost=10,
6967
parallelism=8,
@@ -108,6 +106,8 @@ def passwd_check(hashed_passphrase, passphrase):
108106
True
109107
"""
110108
if hashed_passphrase.startswith('argon2:'):
109+
import argon2
110+
import argon2.exceptions
111111
ph = argon2.PasswordHasher()
112112

113113
try:

0 commit comments

Comments
 (0)