Skip to content

Commit

Permalink
chore: set cli pwd warning go to stderr (#9536)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidzr authored Jul 11, 2024
1 parent d11c3ee commit d4c50b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 1 addition & 5 deletions harness/determined/cli/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ def log_in_user(args: argparse.Namespace) -> None:
try:
authentication.check_password_complexity(password)
except ValueError as e:
print(
"Warning: your password does not appear to satisfy "
+ f"recommended complexity requirements:\n{e}\n"
+ "Please change your password as soon as possible."
)
authentication.warn_about_complexity(e)

token_store.set_token(sess.username, sess.token)
token_store.set_active(sess.username)
Expand Down
16 changes: 11 additions & 5 deletions harness/determined/common/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import pathlib
import re
import sys
from typing import Any, Dict, Iterator, List, Optional, Tuple
from urllib import parse

Expand All @@ -23,6 +24,15 @@ def salt_and_hash(password: str) -> str:
return password


def warn_about_complexity(e: ValueError) -> None:
print(
"Warning: your password does not appear to satisfy "
+ f"recommended complexity requirements:\n{e}\n"
+ "Please change your password as soon as possible.",
file=sys.stderr,
)


def check_password_complexity(password: Optional[str]) -> None:
"""Raises a ValueError if the password does not meet complexity requirements.
Expand Down Expand Up @@ -239,11 +249,7 @@ def login_with_cache(
try:
check_password_complexity(password)
except ValueError as e:
print(
"Warning: your password does not appear to satisfy "
+ f"recommended complexity requirements:\n{e}\n"
+ "Please change your password as soon as possible."
)
warn_about_complexity(e)

token_store.set_token(user, token)

Expand Down

0 comments on commit d4c50b5

Please sign in to comment.