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

feat(auth): add stub for BasePasswordHasher decode method and salt_entropy variable #1647

Merged
Show file tree
Hide file tree
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
29 changes: 22 additions & 7 deletions django-stubs/contrib/auth/hashers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,45 @@ def identify_hasher(encoded: str) -> BasePasswordHasher: ...
def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ...

class BasePasswordHasher:
algorithm: str
library: str | tuple[str, str]
algorithm: str | None
library: str | tuple[str, str] | None
rounds: int
time_cost: int
memory_cost: int
parallelism: int
digest: Any
iterations: int
salt_entropy: int
def salt(self) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def encode(self, password: str, salt: str) -> Any: ...
def decode(self, encoded: str) -> dict[str, Any]: ...
def safe_summary(self, encoded: str) -> Any: ...
def must_update(self, encoded: str) -> bool: ...
def harden_runtime(self, password: str, encoded: str) -> None: ...

class PBKDF2PasswordHasher(BasePasswordHasher):
def encode(self, password: str, salt: str, iterations: int | None = ...) -> str: ...
def decode(self, encoded: str) -> dict[str, str | int]: ...

class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher): ...
class Argon2PasswordHasher(BasePasswordHasher): ...
class BCryptSHA256PasswordHasher(BasePasswordHasher): ...

class BCryptSHA256PasswordHasher(BasePasswordHasher):
def decode(self, encoded: str) -> dict[str, str | int]: ...

class BCryptPasswordHasher(BCryptSHA256PasswordHasher): ...
class SHA1PasswordHasher(BasePasswordHasher): ...
class MD5PasswordHasher(BasePasswordHasher): ...
class UnsaltedSHA1PasswordHasher(BasePasswordHasher): ...
class UnsaltedMD5PasswordHasher(BasePasswordHasher): ...

class SHA1PasswordHasher(BasePasswordHasher):
def decode(self, encoded: str) -> dict[str, str]: ...

class MD5PasswordHasher(BasePasswordHasher):
def decode(self, encoded: str) -> dict[str, str]: ...

class UnsaltedSHA1PasswordHasher(BasePasswordHasher):
def decode(self, encoded: str) -> dict[str, str | None]: ...

class UnsaltedMD5PasswordHasher(BasePasswordHasher):
def decode(self, encoded: str) -> dict[str, str | None]: ...

class CryptPasswordHasher(BasePasswordHasher): ...
12 changes: 0 additions & 12 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,12 @@ django.contrib.auth.forms.UserChangeForm.Meta.model
django.contrib.auth.forms.UserChangeForm.declared_fields
django.contrib.auth.forms.UserCreationForm.declared_fields
django.contrib.auth.forms.UserModel
django.contrib.auth.hashers.Argon2PasswordHasher.decode
django.contrib.auth.hashers.Argon2PasswordHasher.params
django.contrib.auth.hashers.BCryptSHA256PasswordHasher.decode
django.contrib.auth.hashers.BasePasswordHasher.algorithm
django.contrib.auth.hashers.BasePasswordHasher.decode
django.contrib.auth.hashers.BasePasswordHasher.library
django.contrib.auth.hashers.BasePasswordHasher.salt_entropy
django.contrib.auth.hashers.CryptPasswordHasher.__init__
django.contrib.auth.hashers.CryptPasswordHasher.decode
django.contrib.auth.hashers.MD5PasswordHasher.decode
django.contrib.auth.hashers.PBKDF2PasswordHasher.decode
django.contrib.auth.hashers.SHA1PasswordHasher.__init__
django.contrib.auth.hashers.SHA1PasswordHasher.decode
django.contrib.auth.hashers.ScryptPasswordHasher
django.contrib.auth.hashers.UnsaltedMD5PasswordHasher.__init__
django.contrib.auth.hashers.UnsaltedMD5PasswordHasher.decode
django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher.__init__
django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher.decode
django.contrib.auth.hashers.must_update_salt
django.contrib.auth.hashers.reset_hashers
django.contrib.auth.management.commands.createsuperuser.Command.get_input_data
Expand Down