-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from girder/https
Configure robust HTTPS serving in production
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Optional, Tuple | ||
|
||
from ._base import ConfigMixin | ||
|
||
|
||
class HttpsMixin(ConfigMixin): | ||
"""Configure Django's security middleware for HTTPS.""" | ||
|
||
SECURE_SSL_REDIRECT = True | ||
|
||
# This must be set when deployed behind a proxy | ||
SECURE_PROXY_SSL_HEADER: Optional[Tuple[str, str]] = None | ||
|
||
SESSION_COOKIE_SECURE = True | ||
CSRF_COOKIE_SECURE = True | ||
|
||
# Enable HSTS | ||
SECURE_HSTS_SECONDS = 60 * 60 * 24 * 365 # 1 year | ||
# This is already False by default, but it's important to ensure HSTS is not forced on other | ||
# subdomains which may have different HTTPS practices. | ||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False |