Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Mélanie Chauvel
funkwhale
Commits
81e7b900
Verified
Commit
81e7b900
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Fixed https url-reversing issue in development
parent
b69d9f22
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env.dev
+3
-0
3 additions, 0 deletions
.env.dev
api/config/settings/local.py
+3
-0
3 additions, 0 deletions
api/config/settings/local.py
api/funkwhale_api/common/middleware.py
+22
-0
22 additions, 0 deletions
api/funkwhale_api/common/middleware.py
with
28 additions
and
0 deletions
.env.dev
+
3
−
0
View file @
81e7b900
...
...
@@ -12,3 +12,6 @@ MUSIC_DIRECTORY_PATH=/music
BROWSABLE_API_ENABLED=True
FORWARDED_PROTO=http
LDAP_ENABLED=False
# Uncomment this if you're using traefik/https
# FORCE_HTTPS_URLS=True
This diff is collapsed.
Click to expand it.
api/config/settings/local.py
+
3
−
0
View file @
81e7b900
...
...
@@ -14,6 +14,7 @@ from .common import * # noqa
# DEBUG
# ------------------------------------------------------------------------------
DEBUG
=
env
.
bool
(
"
DJANGO_DEBUG
"
,
default
=
True
)
FORCE_HTTPS_URLS
=
env
.
bool
(
"
FORCE_HTTPS_URLS
"
,
default
=
False
)
TEMPLATES
[
0
][
"
OPTIONS
"
][
"
debug
"
]
=
DEBUG
# SECRET CONFIGURATION
...
...
@@ -80,3 +81,5 @@ CSRF_TRUSTED_ORIGINS = [o for o in ALLOWED_HOSTS]
if
env
.
bool
(
"
WEAK_PASSWORDS
"
,
default
=
False
):
# Faster during tests
PASSWORD_HASHERS
=
(
"
django.contrib.auth.hashers.MD5PasswordHasher
"
,)
MIDDLEWARE
=
(
"
funkwhale_api.common.middleware.DevHttpsMiddleware
"
,)
+
MIDDLEWARE
This diff is collapsed.
Click to expand it.
api/funkwhale_api/common/middleware.py
+
22
−
0
View file @
81e7b900
...
...
@@ -135,3 +135,25 @@ class SPAFallbackMiddleware:
return
serve_spa
(
request
)
return
response
class
DevHttpsMiddleware
:
"""
In development, it
'
s sometimes difficult to have django use HTTPS
when we have django behind nginx behind traefix.
We thus use a simple setting (in dev ONLY) to control that.
"""
def
__init__
(
self
,
get_response
):
self
.
get_response
=
get_response
def
__call__
(
self
,
request
):
if
settings
.
FORCE_HTTPS_URLS
:
setattr
(
request
.
__class__
,
"
scheme
"
,
"
https
"
)
setattr
(
request
,
"
get_host
"
,
lambda
:
request
.
__class__
.
get_host
(
request
).
replace
(
"
:80
"
,
"
:443
"
),
)
return
self
.
get_response
(
request
)
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