Modern browsers all support nonce now so drop checking UA
This commit is contained in:
parent
1ba9f2bb56
commit
fc408ef985
1 changed files with 1 additions and 11 deletions
|
@ -274,16 +274,6 @@ class UiRequest(object):
|
||||||
else:
|
else:
|
||||||
return referer
|
return referer
|
||||||
|
|
||||||
def isScriptNonceSupported(self):
|
|
||||||
user_agent = self.env.get("HTTP_USER_AGENT")
|
|
||||||
if "Edge/" in user_agent:
|
|
||||||
is_script_nonce_supported = False
|
|
||||||
elif "Safari/" in user_agent and "Chrome/" not in user_agent:
|
|
||||||
is_script_nonce_supported = False
|
|
||||||
else:
|
|
||||||
is_script_nonce_supported = True
|
|
||||||
return is_script_nonce_supported
|
|
||||||
|
|
||||||
# Send response headers
|
# Send response headers
|
||||||
def sendHeader(self, status=200, content_type="text/html", noscript=False, allow_ajax=False, script_nonce=None, extra_headers=[]):
|
def sendHeader(self, status=200, content_type="text/html", noscript=False, allow_ajax=False, script_nonce=None, extra_headers=[]):
|
||||||
url = self.getRequestUrl()
|
url = self.getRequestUrl()
|
||||||
|
@ -306,7 +296,7 @@ class UiRequest(object):
|
||||||
|
|
||||||
if noscript:
|
if noscript:
|
||||||
headers["Content-Security-Policy"] = "default-src 'none'; sandbox allow-top-navigation allow-forms; img-src *; font-src * data:; media-src *; style-src * 'unsafe-inline';"
|
headers["Content-Security-Policy"] = "default-src 'none'; sandbox allow-top-navigation allow-forms; img-src *; font-src * data:; media-src *; style-src * 'unsafe-inline';"
|
||||||
elif script_nonce and self.isScriptNonceSupported():
|
elif script_nonce:
|
||||||
headers["Content-Security-Policy"] = "default-src 'none'; script-src 'nonce-{0}'; img-src 'self' blob: data:; style-src 'self' blob: 'unsafe-inline'; connect-src *; frame-src 'self' blob:".format(script_nonce)
|
headers["Content-Security-Policy"] = "default-src 'none'; script-src 'nonce-{0}'; img-src 'self' blob: data:; style-src 'self' blob: 'unsafe-inline'; connect-src *; frame-src 'self' blob:".format(script_nonce)
|
||||||
|
|
||||||
if allow_ajax:
|
if allow_ajax:
|
||||||
|
|
Loading…
Reference in a new issue