Skip to content

Add algorithm parameter (Django 3.1) #489

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

Merged
merged 3 commits into from
Jan 20, 2021
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
1 change: 1 addition & 0 deletions django-stubs/contrib/auth/tokens.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from django.contrib.auth.base_user import AbstractBaseUser
class PasswordResetTokenGenerator:
key_salt: str = ...
secret: Any = ...
algorithm: str = ...
def make_token(self, user: AbstractBaseUser) -> str: ...
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...

Expand Down
11 changes: 9 additions & 2 deletions django-stubs/core/signing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SignatureExpired(BadSignature): ...

def b64_encode(s: bytes) -> bytes: ...
def b64_decode(s: bytes) -> bytes: ...
def base64_hmac(salt: str, value: Union[bytes, str], key: Union[bytes, str]) -> str: ...
def base64_hmac(salt: str, value: Union[bytes, str], key: Union[bytes, str], algorithm: str = ...) -> str: ...
def get_cookie_signer(salt: str = ...) -> TimestampSigner: ...

class Serializer(Protocol):
Expand All @@ -32,7 +32,14 @@ class Signer:
key: str = ...
sep: str = ...
salt: str = ...
def __init__(self, key: Optional[Union[bytes, str]] = ..., sep: str = ..., salt: Optional[str] = ...) -> None: ...
algorithm: str = ...
def __init__(
self,
key: Optional[Union[bytes, str]] = ...,
sep: str = ...,
salt: Optional[str] = ...,
algorithm: Optional[str] = ...,
) -> None: ...
def signature(self, value: Union[bytes, str]) -> str: ...
def sign(self, value: str) -> str: ...
def unsign(self, signed_value: str) -> str: ...
Expand Down
4 changes: 3 additions & 1 deletion django-stubs/utils/crypto.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ from typing import Callable, Optional, Union

using_sysrandom: bool

def salted_hmac(key_salt: str, value: Union[bytes, str], secret: Optional[Union[bytes, str]] = ...) -> HMAC: ...
def salted_hmac(
key_salt: str, value: Union[bytes, str], secret: Optional[Union[bytes, str]] = ..., algorithm: str = ...
) -> HMAC: ...
def get_random_string(length: int = ..., allowed_chars: str = ...) -> str: ...
def constant_time_compare(val1: Union[bytes, str], val2: Union[bytes, str]) -> bool: ...
def pbkdf2(
Expand Down