Skip to content

Commit bdc7db1

Browse files
authored
Add algorithm parameter (Django 3.1) (#489)
* add algorithm parameter * add algorithm field * reformat
1 parent 49ed9c9 commit bdc7db1

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

django-stubs/contrib/auth/tokens.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from django.contrib.auth.base_user import AbstractBaseUser
66
class PasswordResetTokenGenerator:
77
key_salt: str = ...
88
secret: Any = ...
9+
algorithm: str = ...
910
def make_token(self, user: AbstractBaseUser) -> str: ...
1011
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...
1112
def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int) -> str: ...

django-stubs/core/signing.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class SignatureExpired(BadSignature): ...
66

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

1212
class Serializer(Protocol):
@@ -32,7 +32,14 @@ class Signer:
3232
key: str = ...
3333
sep: str = ...
3434
salt: str = ...
35-
def __init__(self, key: Optional[Union[bytes, str]] = ..., sep: str = ..., salt: Optional[str] = ...) -> None: ...
35+
algorithm: str = ...
36+
def __init__(
37+
self,
38+
key: Optional[Union[bytes, str]] = ...,
39+
sep: str = ...,
40+
salt: Optional[str] = ...,
41+
algorithm: Optional[str] = ...,
42+
) -> None: ...
3643
def signature(self, value: Union[bytes, str]) -> str: ...
3744
def sign(self, value: str) -> str: ...
3845
def unsign(self, signed_value: str) -> str: ...

django-stubs/utils/crypto.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ from typing import Callable, Optional, Union
33

44
using_sysrandom: bool
55

6-
def salted_hmac(key_salt: str, value: Union[bytes, str], secret: Optional[Union[bytes, str]] = ...) -> HMAC: ...
6+
def salted_hmac(
7+
key_salt: str, value: Union[bytes, str], secret: Optional[Union[bytes, str]] = ..., algorithm: str = ...
8+
) -> HMAC: ...
79
def get_random_string(length: int = ..., allowed_chars: str = ...) -> str: ...
810
def constant_time_compare(val1: Union[bytes, str], val2: Union[bytes, str]) -> bool: ...
911
def pbkdf2(

0 commit comments

Comments
 (0)