File: csrf.pyi

package info (click to toggle)
python-django-stubs 5.2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (61 lines) | stat: -rw-r--r-- 1,853 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from collections import defaultdict
from collections.abc import Callable
from logging import Logger
from re import Pattern
from typing import Any

from django.http.request import HttpRequest
from django.http.response import HttpResponseBase, HttpResponseForbidden
from django.utils.deprecation import MiddlewareMixin
from django.utils.functional import cached_property

logger: Logger

invalid_token_chars_re: Pattern[str]

REASON_BAD_ORIGIN: str
REASON_NO_REFERER: str
REASON_BAD_REFERER: str
REASON_NO_CSRF_COOKIE: str
REASON_CSRF_TOKEN_MISSING: str
REASON_MALFORMED_REFERER: str
REASON_INSECURE_REFERER: str

REASON_INCORRECT_LENGTH: str
REASON_INVALID_CHARACTERS: str

CSRF_SECRET_LENGTH: int
CSRF_TOKEN_LENGTH: Any
CSRF_ALLOWED_CHARS: Any
CSRF_SESSION_KEY: str

def get_token(request: HttpRequest) -> str: ...
def rotate_token(request: HttpRequest) -> None: ...

class InvalidTokenFormat(Exception):
    reason: str
    def __init__(self, reason: str) -> None: ...

class RejectRequest(Exception):
    reason: str
    def __init__(self, reason: str) -> None: ...

class CsrfViewMiddleware(MiddlewareMixin):
    @cached_property
    def csrf_trusted_origins_hosts(self) -> list[str]: ...
    @cached_property
    def allowed_origins_exact(self) -> set[str]: ...
    @cached_property
    def allowed_origin_subdomains(self) -> defaultdict[str, list[str]]: ...
    def process_request(self, request: HttpRequest) -> None: ...
    def process_view(
        self,
        request: HttpRequest,
        callback: Callable[..., HttpResponseBase],
        callback_args: tuple[Any, ...],
        callback_kwargs: dict[str, Any],
    ) -> HttpResponseForbidden | None: ...
    def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...

def _get_new_csrf_string() -> str: ...
def _get_new_csrf_token() -> str: ...