-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_rep.py
28 lines (23 loc) · 1.02 KB
/
prepare_rep.py
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
from werkzeug.http import http_date
import datetime
def prepare_response_extra_headers(include_security_headers):
response_extra_headers = {
# always
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Last-Modified': http_date(datetime.datetime.now()),
}
if include_security_headers:
response_security_headers = {
# X-Frame-Options: page can only be shown in an iframe of the same site
'X-Frame-Options': 'SAMEORIGIN',
# ensure all app communication is sent over HTTPS
'Strict-Transport-Security': 'max-age=63072000; includeSubdomains',
# instructs the browser not to override the response content type
'X-Content-Type-Options': 'nosniff',
# enable browser cross-site scripting (XSS) filter
'X-XSS-Protection': '1; mode=block',
}
response_extra_headers.update(response_security_headers)
return response_extra_headers