fix(api): Avoid the creation of users using djangos createsuperuser command
This commit is contained in:
parent
3f5758aa7f
commit
a46c8e7f41
|
@ -281,9 +281,9 @@ ADDITIONAL_APPS = env.list("ADDITIONAL_APPS", default=[])
|
||||||
List of Django apps to load in addition to Funkwhale plugins and apps.
|
List of Django apps to load in addition to Funkwhale plugins and apps.
|
||||||
"""
|
"""
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
DJANGO_APPS
|
LOCAL_APPS
|
||||||
|
+ DJANGO_APPS
|
||||||
+ THIRD_PARTY_APPS
|
+ THIRD_PARTY_APPS
|
||||||
+ LOCAL_APPS
|
|
||||||
+ tuple(ADDITIONAL_APPS)
|
+ tuple(ADDITIONAL_APPS)
|
||||||
+ tuple(plugins.trigger_filter(plugins.PLUGINS_APPS, [], enabled=True))
|
+ tuple(plugins.trigger_filter(plugins.PLUGINS_APPS, [], enabled=True))
|
||||||
)
|
)
|
||||||
|
|
|
@ -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)
|
|
@ -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)
|
Loading…
Reference in New Issue