core: make Source model managed, add inbuilt source
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
43ad4f58ac
commit
5dd29d45d8
|
@ -26,6 +26,9 @@ class SourceSerializer(ModelSerializer, MetaNameSerializer):
|
|||
|
||||
def get_component(self, obj: Source):
|
||||
"""Get object component so that we know how to edit the object"""
|
||||
# pyright: reportGeneralTypeIssues=false
|
||||
if obj.__class__ == Source:
|
||||
return ""
|
||||
return obj.component
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -14,3 +14,4 @@ class AuthentikCoreConfig(AppConfig):
|
|||
|
||||
def ready(self):
|
||||
import_module("authentik.core.signals")
|
||||
import_module("authentik.core.managed")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
"""Core managed objects"""
|
||||
from authentik.core.models import Source
|
||||
from authentik.managed.manager import EnsureExists, ObjectManager
|
||||
|
||||
|
||||
class CoreManager(ObjectManager):
|
||||
"""Core managed objects"""
|
||||
|
||||
def reconcile(self):
|
||||
return [
|
||||
EnsureExists(
|
||||
Source,
|
||||
"goauthentik.io/sources/inbuilt",
|
||||
name="authentik Built-in",
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2 on 2021-04-09 14:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('authentik_core', '0018_auto_20210330_1345'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='source',
|
||||
name='managed',
|
||||
field=models.TextField(default=None, help_text='Objects which are managed by authentik. These objects are created and updated automatically. This is flag only indicates that an object can be overwritten by migrations. You can still modify the objects via the API, but expect changes to be overwritten in a later update.', null=True, unique=True, verbose_name='Managed by authentik'),
|
||||
),
|
||||
]
|
|
@ -240,7 +240,7 @@ class Application(PolicyBindingModel):
|
|||
verbose_name_plural = _("Applications")
|
||||
|
||||
|
||||
class Source(SerializerModel, PolicyBindingModel):
|
||||
class Source(ManagedModel, SerializerModel, PolicyBindingModel):
|
||||
"""Base Authentication source, i.e. an OAuth Provider, SAML Remote or LDAP Server"""
|
||||
|
||||
name = models.TextField(help_text=_("Source's display Name."))
|
||||
|
|
|
@ -132,7 +132,6 @@ INSTALLED_APPS = [
|
|||
"django_prometheus",
|
||||
"channels",
|
||||
"dbbackup",
|
||||
"authentik.managed.apps.AuthentikManagedConfig",
|
||||
]
|
||||
|
||||
GUARDIAN_MONKEY_PATCH = False
|
||||
|
@ -482,6 +481,7 @@ if DEBUG:
|
|||
CELERY_TASK_ALWAYS_EAGER = True
|
||||
os.environ[ENV_GIT_HASH_KEY] = "dev"
|
||||
|
||||
INSTALLED_APPS.append("authentik.core.apps.AuthentikCoreConfig")
|
||||
INSTALLED_APPS.append("authentik.core")
|
||||
INSTALLED_APPS.append("authentik.managed")
|
||||
|
||||
j_print("Booting authentik", version=__version__)
|
||||
|
|
Reference in New Issue