Add algorithm parameter (Django 3.1) (#489)

* add algorithm parameter

* add algorithm field

* reformat
This commit is contained in:
Yuta Okamoto
2021-01-20 17:03:51 +09:00
committed by GitHub
parent 49ed9c957f
commit bdc7db1154
3 changed files with 13 additions and 3 deletions

View File

@@ -6,6 +6,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: ...
def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int) -> str: ...

View File

@@ -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):
@@ -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: ...

View File

@@ -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(