Skip to content

Commit 1b3bb84

Browse files
committed
🎉 Clear-Site-Data HTTP header added
1 parent 04dd035 commit 1b3bb84

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

secure/headers.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,3 +960,40 @@ def vr(self, *allowlist: str) -> "PermissionsPolicy":
960960
def xr_spatial_tracking(self, *allowlist: str) -> "PermissionsPolicy":
961961
self._build("xr-spatial-tracking", *allowlist)
962962
return self
963+
964+
965+
class ClearSiteData:
966+
"""
967+
The Clear-Site-Data header clears browsing data (cookies, storage, cache) associated with the requesting website. It allows web developers to have more control over the data stored by a client browser for their origins.
968+
Resources:
969+
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data
970+
"""
971+
972+
def __init__(self) -> None:
973+
self.__policy: List[str] = []
974+
self.header = "Clear-Site-Data"
975+
self.value = ""
976+
977+
def _build(self, directive: str) -> None:
978+
self.__policy.append(directive)
979+
self.value = ", ".join(self.__policy)
980+
981+
def clear_storage(self) -> "ClearSiteData":
982+
self._build("Storage")
983+
return self
984+
985+
def clear_cache(self) -> "ClearSiteData":
986+
self._build("Cache")
987+
return self
988+
989+
def clear_cookies(self) -> "ClearSiteData":
990+
self._build("Cookies")
991+
return self
992+
993+
def clear_executionContext(self) -> "ClearSiteData":
994+
self._build("executionContexts")
995+
return self
996+
997+
def clear_wildcard(self) -> "ClearSiteData":
998+
self._build("*")
999+
return self

0 commit comments

Comments
 (0)