Skip to content

Commit

Permalink
feat(auth): add stub for base password hasher class decode method and…
Browse files Browse the repository at this point in the history
… salt_entropy variable
  • Loading branch information
Kadermiyanyedi committed Aug 12, 2023
1 parent e2dc4ea commit 7835df7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
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

0 comments on commit 7835df7

Please sign in to comment.