Skip to content

Commit

Permalink
Merge pull request #20 from tonnyhideyori/master
Browse files Browse the repository at this point in the history
🎉 Clear-Site-Data HTTP header Policy
  • Loading branch information
cak authored Apr 29, 2024
2 parents 04dd035 + 1b3bb84 commit 9a96837
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions secure/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,40 @@ def vr(self, *allowlist: str) -> "PermissionsPolicy":
def xr_spatial_tracking(self, *allowlist: str) -> "PermissionsPolicy":
self._build("xr-spatial-tracking", *allowlist)
return self


class ClearSiteData:
"""
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.
Resources:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data
"""

def __init__(self) -> None:
self.__policy: List[str] = []
self.header = "Clear-Site-Data"
self.value = ""

def _build(self, directive: str) -> None:
self.__policy.append(directive)
self.value = ", ".join(self.__policy)

def clear_storage(self) -> "ClearSiteData":
self._build("Storage")
return self

def clear_cache(self) -> "ClearSiteData":
self._build("Cache")
return self

def clear_cookies(self) -> "ClearSiteData":
self._build("Cookies")
return self

def clear_executionContext(self) -> "ClearSiteData":
self._build("executionContexts")
return self

def clear_wildcard(self) -> "ClearSiteData":
self._build("*")
return self

0 comments on commit 9a96837

Please sign in to comment.