File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed
Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -541,3 +541,9 @@ SECURE_REDIRECT_EXEMPT: list[str]
541541SECURE_REFERRER_POLICY : str
542542SECURE_SSL_HOST : str | None
543543SECURE_SSL_REDIRECT : bool
544+
545+ ##################
546+ # CSP MIDDLEWARE #
547+ ##################
548+ SECURE_CSP : dict [str , Any ] = {}
549+ SECURE_CSP_REPORT_ONLY : dict [str , Any ] = {}
Original file line number Diff line number Diff line change 1+ from typing import TYPE_CHECKING
2+
3+ from django .utils .csp import CSP as CSP
4+
5+ if TYPE_CHECKING :
6+ from django .http import HttpRequest , HttpResponse
7+ from django .utils .deprecation import MiddlewareMixin
8+
9+ class CSPMiddleware (MiddlewareMixin ):
10+ def process_request (self , request : HttpRequest ) -> None : ...
11+ def process_response (self , request : HttpRequest , response : HttpResponse ) -> HttpResponse : ...
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ if sys .version_info >= (3 , 11 ):
4+ from enum import StrEnum
5+ else :
6+ from enum import Enum
7+
8+ class ReprEnum (Enum ): ... # type: ignore[misc]
9+ class StrEnum (str , ReprEnum ): ... # type: ignore[misc]
10+
11+ class CSP (StrEnum ):
12+ HEADER_ENFORCE = "Content-Security-Policy"
13+ HEADER_REPORT_ONLY = "Content-Security-Policy-Report-Only"
14+
15+ NONE = "'none'"
16+ REPORT_SAMPLE = "'report-sample'"
17+ SELF = "'self'"
18+ STRICT_DYNAMIC = "'strict-dynamic'"
19+ UNSAFE_EVAL = "'unsafe-eval'"
20+ UNSAFE_HASHES = "'unsafe-hashes'"
21+ UNSAFE_INLINE = "'unsafe-inline'"
22+ WASM_UNSAFE_EVAL = "'wasm-unsafe-eval'"
23+
24+ NONCE = "<CSP_NONCE_SENTINEL>"
Original file line number Diff line number Diff line change 1+ from collections .abc import Callable
2+ from typing import Any , TypeVar
3+
4+ _F = TypeVar ("_F" , bound = Callable [..., Any ])
5+
6+ def csp_override (config : dict [str , Any ]) -> Callable [[_F ], _F ]: ...
7+ def csp_report_only_override (config : dict [str , Any ]) -> Callable [[_F ], _F ]: ...
You can’t perform that action at this time.
0 commit comments