Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
3e3424aa
Commit
3e3424aa
authored
7 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
hsts
parent
47612a43
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
helios/security.py
+7
-0
7 additions, 0 deletions
helios/security.py
settings.py
+6
-2
6 additions, 2 deletions
settings.py
with
13 additions
and
2 deletions
helios/security.py
+
7
−
0
View file @
3e3424aa
...
...
@@ -20,6 +20,13 @@ import urllib
import
helios
class
HSTSMiddleware
:
def
process_response
(
self
,
request
,
response
):
if
settings
.
STS
:
response
[
'
Strict-Transport-Security
'
]
=
"
max-age=31536000; includeSubDomains; preload
"
return
response
# current voter
def
get_voter
(
request
,
user
,
election
):
"""
...
...
This diff is collapsed.
Click to expand it.
settings.py
+
6
−
2
View file @
3e3424aa
...
...
@@ -101,10 +101,13 @@ if (get_from_env('SSL', '0') == '1'):
SESSION_COOKIE_HTTPONLY
=
True
# let's go with one year because that's the way to do it now
STS
=
False
if
(
get_from_env
(
'
HSTS
'
,
'
0
'
)
==
'
1
'
):
SECURE_HSTS_SECONDS
=
31536000
STS
=
True
# we're using our own custom middleware now
# SECURE_HSTS_SECONDS = 31536000
# not doing subdomains for now cause that is not likely to be necessary and can screw things up.
SECURE_HSTS_INCLUDE_SUBDOMAINS
=
True
#
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_BROWSER_XSS_FILTER
=
True
SECURE_CONTENT_TYPE_NOSNIFF
=
True
...
...
@@ -121,6 +124,7 @@ MIDDLEWARE_CLASSES = (
# secure a bunch of things
'
djangosecure.middleware.SecurityMiddleware
'
,
'
helios.security.HSTSMiddleware
'
,
'
django.middleware.clickjacking.XFrameOptionsMiddleware
'
,
'
django.middleware.common.CommonMiddleware
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment