authentik.sources.kerberos.api.source

Source API Views

 1"""Source API Views"""
 2
 3from django.core.cache import cache
 4from rest_framework.fields import SerializerMethodField
 5from rest_framework.viewsets import ModelViewSet
 6
 7from authentik.core.api.sources import SourceSerializer
 8from authentik.core.api.used_by import UsedByMixin
 9from authentik.lib.sync.api import SyncStatusMixin
10from authentik.sources.kerberos.models import KerberosSource
11from authentik.sources.kerberos.tasks import CACHE_KEY_STATUS, kerberos_sync
12
13
14class KerberosSourceSerializer(SourceSerializer):
15    """Kerberos Source Serializer"""
16
17    connectivity = SerializerMethodField()
18
19    def get_connectivity(self, source: KerberosSource) -> dict[str, str] | None:
20        """Get cached source connectivity"""
21        return cache.get(CACHE_KEY_STATUS + source.slug, None)
22
23    class Meta:
24        model = KerberosSource
25        fields = SourceSerializer.Meta.fields + [
26            "group_matching_mode",
27            "realm",
28            "krb5_conf",
29            "kadmin_type",
30            "sync_users",
31            "sync_users_password",
32            "sync_principal",
33            "sync_password",
34            "sync_keytab",
35            "sync_ccache",
36            "connectivity",
37            "spnego_server_name",
38            "spnego_keytab",
39            "spnego_ccache",
40            "password_login_update_internal_password",
41            "sync_outgoing_trigger_mode",
42        ]
43        extra_kwargs = {
44            "sync_password": {"write_only": True},
45            "sync_keytab": {"write_only": True},
46            "sync_ccache": {"write_only": True},
47            "spnego_keytab": {"write_only": True},
48            "spnego_ccache": {"write_only": True},
49        }
50
51
52class KerberosSourceViewSet(SyncStatusMixin, UsedByMixin, ModelViewSet):
53    """Kerberos Source Viewset"""
54
55    queryset = KerberosSource.objects.all()
56    serializer_class = KerberosSourceSerializer
57    lookup_field = "slug"
58    filterset_fields = [
59        "pbm_uuid",
60        "name",
61        "slug",
62        "enabled",
63        "realm",
64        "kadmin_type",
65        "sync_users",
66        "sync_users_password",
67        "sync_principal",
68        "spnego_server_name",
69        "password_login_update_internal_password",
70    ]
71    search_fields = [
72        "name",
73        "slug",
74        "realm",
75        "krb5_conf",
76        "sync_principal",
77        "spnego_server_name",
78    ]
79    ordering = ["name"]
80    sync_task = kerberos_sync
class KerberosSourceSerializer(authentik.core.api.sources.SourceSerializer):
15class KerberosSourceSerializer(SourceSerializer):
16    """Kerberos Source Serializer"""
17
18    connectivity = SerializerMethodField()
19
20    def get_connectivity(self, source: KerberosSource) -> dict[str, str] | None:
21        """Get cached source connectivity"""
22        return cache.get(CACHE_KEY_STATUS + source.slug, None)
23
24    class Meta:
25        model = KerberosSource
26        fields = SourceSerializer.Meta.fields + [
27            "group_matching_mode",
28            "realm",
29            "krb5_conf",
30            "kadmin_type",
31            "sync_users",
32            "sync_users_password",
33            "sync_principal",
34            "sync_password",
35            "sync_keytab",
36            "sync_ccache",
37            "connectivity",
38            "spnego_server_name",
39            "spnego_keytab",
40            "spnego_ccache",
41            "password_login_update_internal_password",
42            "sync_outgoing_trigger_mode",
43        ]
44        extra_kwargs = {
45            "sync_password": {"write_only": True},
46            "sync_keytab": {"write_only": True},
47            "sync_ccache": {"write_only": True},
48            "spnego_keytab": {"write_only": True},
49            "spnego_ccache": {"write_only": True},
50        }

Kerberos Source Serializer

connectivity
def get_connectivity( self, source: authentik.sources.kerberos.models.KerberosSource) -> dict[str, str] | None:
20    def get_connectivity(self, source: KerberosSource) -> dict[str, str] | None:
21        """Get cached source connectivity"""
22        return cache.get(CACHE_KEY_STATUS + source.slug, None)

Get cached source connectivity

class KerberosSourceSerializer.Meta:
24    class Meta:
25        model = KerberosSource
26        fields = SourceSerializer.Meta.fields + [
27            "group_matching_mode",
28            "realm",
29            "krb5_conf",
30            "kadmin_type",
31            "sync_users",
32            "sync_users_password",
33            "sync_principal",
34            "sync_password",
35            "sync_keytab",
36            "sync_ccache",
37            "connectivity",
38            "spnego_server_name",
39            "spnego_keytab",
40            "spnego_ccache",
41            "password_login_update_internal_password",
42            "sync_outgoing_trigger_mode",
43        ]
44        extra_kwargs = {
45            "sync_password": {"write_only": True},
46            "sync_keytab": {"write_only": True},
47            "sync_ccache": {"write_only": True},
48            "spnego_keytab": {"write_only": True},
49            "spnego_ccache": {"write_only": True},
50        }
fields = ['pk', 'name', 'slug', 'enabled', 'promoted', 'authentication_flow', 'enrollment_flow', 'user_property_mappings', 'group_property_mappings', 'component', 'verbose_name', 'verbose_name_plural', 'meta_model_name', 'policy_engine_mode', 'user_matching_mode', 'managed', 'user_path_template', 'icon', 'icon_url', 'icon_themed_urls', 'group_matching_mode', 'realm', 'krb5_conf', 'kadmin_type', 'sync_users', 'sync_users_password', 'sync_principal', 'sync_password', 'sync_keytab', 'sync_ccache', 'connectivity', 'spnego_server_name', 'spnego_keytab', 'spnego_ccache', 'password_login_update_internal_password', 'sync_outgoing_trigger_mode']
extra_kwargs = {'sync_password': {'write_only': True}, 'sync_keytab': {'write_only': True}, 'sync_ccache': {'write_only': True}, 'spnego_keytab': {'write_only': True}, 'spnego_ccache': {'write_only': True}}
class KerberosSourceViewSet(authentik.lib.sync.api.SyncStatusMixin, authentik.core.api.used_by.UsedByMixin, rest_framework.viewsets.ModelViewSet):
53class KerberosSourceViewSet(SyncStatusMixin, UsedByMixin, ModelViewSet):
54    """Kerberos Source Viewset"""
55
56    queryset = KerberosSource.objects.all()
57    serializer_class = KerberosSourceSerializer
58    lookup_field = "slug"
59    filterset_fields = [
60        "pbm_uuid",
61        "name",
62        "slug",
63        "enabled",
64        "realm",
65        "kadmin_type",
66        "sync_users",
67        "sync_users_password",
68        "sync_principal",
69        "spnego_server_name",
70        "password_login_update_internal_password",
71    ]
72    search_fields = [
73        "name",
74        "slug",
75        "realm",
76        "krb5_conf",
77        "sync_principal",
78        "spnego_server_name",
79    ]
80    ordering = ["name"]
81    sync_task = kerberos_sync

Kerberos Source Viewset

queryset = <InheritanceQuerySet []>
serializer_class = <class 'KerberosSourceSerializer'>
lookup_field = 'slug'
filterset_fields = ['pbm_uuid', 'name', 'slug', 'enabled', 'realm', 'kadmin_type', 'sync_users', 'sync_users_password', 'sync_principal', 'spnego_server_name', 'password_login_update_internal_password']
search_fields = ['name', 'slug', 'realm', 'krb5_conf', 'sync_principal', 'spnego_server_name']
ordering = ['name']
sync_task = Actor(<function kerberos_sync>, queue_name='default', actor_name='authentik.sources.kerberos.tasks.kerberos_sync')
name = None
description = None
suffix = None
detail = None
basename = None