Add option to not collect IP addresses (closes #18)
This commit is contained in:
parent
a210e23bb3
commit
26778f0219
@ -42,8 +42,9 @@ SESSION_MEMORY_TIMEOUT=1800
|
||||
# them to be able to create services of their own.
|
||||
ONLY_SUPERUSERS_CREATE=True
|
||||
|
||||
# Whether to perform checks and setup at startup. For most setups,
|
||||
# the recommended value is True.
|
||||
# Whether to perform checks and setup at startup, including applying unapplied
|
||||
# migrations. For most setups, the recommended value is True. Defaults to True.
|
||||
# Will skip only if value is False.
|
||||
PERFORM_CHECKS_AND_SETUP=True
|
||||
|
||||
# Your admin user's email. A temporary password will be printed
|
||||
|
18
shynet/analytics/migrations/0003_auto_20200502_1227.py
Normal file
18
shynet/analytics/migrations/0003_auto_20200502_1227.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-02 16:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0002_auto_20200415_1742'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='session',
|
||||
name='ip',
|
||||
field=models.GenericIPAddressField(db_index=True, null=True),
|
||||
),
|
||||
]
|
@ -39,7 +39,7 @@ class Session(models.Model):
|
||||
default="OTHER",
|
||||
)
|
||||
os = models.TextField()
|
||||
ip = models.GenericIPAddressField(db_index=True)
|
||||
ip = models.GenericIPAddressField(db_index=True, null=True)
|
||||
|
||||
# GeoIP data
|
||||
asn = models.TextField(blank=True)
|
||||
|
@ -103,7 +103,7 @@ def ingress_request(
|
||||
device_type = "DESKTOP"
|
||||
session = Session.objects.create(
|
||||
service=service,
|
||||
ip=ip,
|
||||
ip=ip if service.collect_ips else None,
|
||||
user_agent=user_agent,
|
||||
identifier=identifier.strip(),
|
||||
browser=ua.browser.family or "",
|
||||
|
18
shynet/core/migrations/0004_service_collect_ips.py
Normal file
18
shynet/core/migrations/0004_service_collect_ips.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-02 16:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0003_service_respect_dnt'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='service',
|
||||
name='collect_ips',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
@ -42,6 +42,7 @@ class Service(models.Model):
|
||||
max_length=2, choices=SERVICE_STATUSES, default=ACTIVE, db_index=True
|
||||
)
|
||||
respect_dnt = models.BooleanField(default=True)
|
||||
collect_ips = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name", "uuid"]
|
||||
|
@ -8,15 +8,17 @@ from core.models import Service, User
|
||||
class ServiceForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Service
|
||||
fields = ["name", "link", "respect_dnt", "origins", "collaborators"]
|
||||
fields = ["name", "link", "respect_dnt", "collect_ips", "origins", "collaborators"]
|
||||
widgets = {
|
||||
"name": forms.TextInput(),
|
||||
"origins": forms.TextInput(),
|
||||
"respect_dnt": forms.RadioSelect(choices=[(True, "Yes"), (False, "No")]),
|
||||
"collect_ips": forms.RadioSelect(choices=[(True, "Yes"), (False, "No")]),
|
||||
}
|
||||
labels = {
|
||||
"origins": "Allowed Hostnames",
|
||||
"respect_dnt": "Respect DNT",
|
||||
"collect_ips": "Collect IP addresses"
|
||||
}
|
||||
help_texts = {
|
||||
"name": _("What should the service be called?"),
|
||||
@ -25,6 +27,7 @@ class ServiceForm(forms.ModelForm):
|
||||
"At what hostnames does the service operate? This sets CORS headers, so use '*' if you're not sure (or don't care)."
|
||||
),
|
||||
"respect_dnt": "Should visitors who have enabled <a href='https://en.wikipedia.org/wiki/Do_Not_Track'>Do Not Track</a> be excluded from all data?",
|
||||
"collect_ips": "Should individual IP addresses be collected? IP metadata (location, host, etc) will still be collected."
|
||||
}
|
||||
|
||||
collaborators = forms.CharField(
|
||||
|
@ -8,5 +8,6 @@
|
||||
<summary class="cursor-pointer text-sm">Advanced settings</summary>
|
||||
<hr class="sep h-4">
|
||||
{{form.respect_dnt|a17t}}
|
||||
{{form.collect_ips|a17t}}
|
||||
{{form.origins|a17t}}
|
||||
</details>
|
@ -60,7 +60,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<p>IP</p>
|
||||
<p class="label" title="{{session.ip}}">{{session.ip|truncatechars:"16"}}</p>
|
||||
<p class="label" title="{{session.ip}}">{{session.ip|default:"Not Collected"|truncatechars:"16"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $PERFORM_CHECKS_AND_SETUP == True ]]; then
|
||||
if [[ ! $PERFORM_CHECKS_AND_SETUP == False ]]; then
|
||||
./startup_checks.sh
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user