fix(api): Avoid the creation of users using djangos createsuperuser command

environments/review-docs-1288-9cqtdw/deployments/17670
Georg Krause 2023-06-07 09:31:59 +02:00 zatwierdzone przez JuniorJPDJ
rodzic 3f5758aa7f
commit a46c8e7f41
3 zmienionych plików z 27 dodań i 2 usunięć

Wyświetl plik

@ -281,9 +281,9 @@ ADDITIONAL_APPS = env.list("ADDITIONAL_APPS", default=[])
List of Django apps to load in addition to Funkwhale plugins and apps.
"""
INSTALLED_APPS = (
DJANGO_APPS
LOCAL_APPS
+ DJANGO_APPS
+ THIRD_PARTY_APPS
+ LOCAL_APPS
+ tuple(ADDITIONAL_APPS)
+ tuple(plugins.trigger_filter(plugins.PLUGINS_APPS, [], enabled=True))
)

Wyświetl plik

@ -0,0 +1,22 @@
import os
from django.contrib.auth.management.commands.createsuperuser import (
Command as BaseCommand,
)
from django.core.management.base import CommandError
class Command(BaseCommand):
def handle(self, *apps_label, **options):
"""
Creating Django Superusers would bypass some of our username checks, which can lead to unexpected behaviour.
We therefore prohibit the execution of the command.
"""
if not os.environ.get("FORCE") == "1":
raise CommandError(
"Running createsuperuser on your Funkwhale instance bypasses some of our checks "
"which can lead to unexpected behavior of your instance. We therefore suggest to "
"run `funkwhale-manage fw users create --superuser` instead."
)
return super().handle(*apps_label, **options)

Wyświetl plik

@ -0,0 +1,3 @@
Prohibit the creation of new users using django's `createsuperuser` command in favor of our own CLI
entry point. Run `funkwhale-manage fw users create --superuser` instead. (#1288)