Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argon2 as an optional dependency #532

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jupyter_server/auth/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import traceback
import warnings

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

if algorithm == 'argon2':
ph = PasswordHasher(
import argon2
ph = argon2.PasswordHasher(
memory_cost=10240,
time_cost=10,
parallelism=8,
Expand Down Expand Up @@ -108,6 +106,8 @@ def passwd_check(hashed_passphrase, passphrase):
True
"""
if hashed_passphrase.startswith('argon2:'):
import argon2
import argon2.exceptions
ph = argon2.PasswordHasher()

try:
Expand Down