Skip to content

Commit

Permalink
Ensure onion_address setting includes http:// protocol
Browse files Browse the repository at this point in the history
The Onion Location Middleware requires this setting to act as a "base"
URL in order to form the correct header value, so we need the
`http://` in this setting.  The validation already tries to make sure
this happens, so we ought to have it in the default value as well.
  • Loading branch information
chigby authored and harrislapiroff committed Oct 13, 2020
1 parent 40028c3 commit 6c1997b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions common/migrations/0006_auto_20201005_1953.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.14 on 2020-10-05 19:53

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0005_auto_20200810_2049'),
]

operations = [
migrations.AlterField(
model_name='footersettings',
name='securedrop_onion_address',
field=models.CharField(default='http://secrdrop5wyphb5x.onion', help_text='Address for the securedrop.org onion service. Displayed in the site footer and the Onion-Location header. Must begin with http or https and end with .onion', max_length=255, validators=[django.core.validators.RegexValidator(message='Enter a valid .onion address.', regex='\\.onion$'), django.core.validators.URLValidator(message='Onion address must be a valid URL beginning with http or https', schemes=['http', 'https'])], verbose_name='SecureDrop Onion Address'),
),
]
2 changes: 1 addition & 1 deletion common/models/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FooterSettings(BaseSetting):
securedrop_onion_address = models.CharField(
'SecureDrop Onion Address',
max_length=255,
default='secrdrop5wyphb5x.onion',
default='http://secrdrop5wyphb5x.onion',
validators=[
RegexValidator(regex=r'\.onion$', message="Enter a valid .onion address."),
URLValidator(schemes=['http', 'https'], message='Onion address must be a valid URL beginning with http or https'),
Expand Down

0 comments on commit 6c1997b

Please sign in to comment.