authentik.enterprise.providers.google_workspace.models

Google workspace sync provider

  1"""Google workspace sync provider"""
  2
  3from typing import Any, Self
  4from uuid import uuid4
  5
  6from django.db import models
  7from django.db.models import QuerySet
  8from django.templatetags.static import static
  9from django.utils.translation import gettext_lazy as _
 10from dramatiq.actor import Actor
 11from google.oauth2.service_account import Credentials
 12from rest_framework.serializers import Serializer
 13
 14from authentik.core.models import (
 15    BackchannelProvider,
 16    Group,
 17    PropertyMapping,
 18    User,
 19    UserTypes,
 20)
 21from authentik.lib.models import InternallyManagedMixin, SerializerModel
 22from authentik.lib.sync.outgoing.base import BaseOutgoingSyncClient
 23from authentik.lib.sync.outgoing.models import OutgoingSyncDeleteAction, OutgoingSyncProvider
 24
 25
 26def default_scopes() -> list[str]:
 27    return [
 28        "https://www.googleapis.com/auth/admin.directory.user",
 29        "https://www.googleapis.com/auth/admin.directory.group",
 30        "https://www.googleapis.com/auth/admin.directory.group.member",
 31        "https://www.googleapis.com/auth/admin.directory.domain.readonly",
 32    ]
 33
 34
 35class GoogleWorkspaceProviderUser(InternallyManagedMixin, SerializerModel):
 36    """Mapping of a user and provider to a Google user ID"""
 37
 38    id = models.UUIDField(primary_key=True, editable=False, default=uuid4)
 39    google_id = models.TextField()
 40    user = models.ForeignKey(User, on_delete=models.CASCADE)
 41    provider = models.ForeignKey("GoogleWorkspaceProvider", on_delete=models.CASCADE)
 42    attributes = models.JSONField(default=dict)
 43
 44    @property
 45    def serializer(self) -> type[Serializer]:
 46        from authentik.enterprise.providers.google_workspace.api.users import (
 47            GoogleWorkspaceProviderUserSerializer,
 48        )
 49
 50        return GoogleWorkspaceProviderUserSerializer
 51
 52    class Meta:
 53        verbose_name = _("Google Workspace Provider User")
 54        verbose_name_plural = _("Google Workspace Provider Users")
 55        unique_together = (("google_id", "user", "provider"),)
 56
 57    def __str__(self) -> str:
 58        return f"Google Workspace Provider User {self.user_id} to {self.provider_id}"
 59
 60
 61class GoogleWorkspaceProviderGroup(InternallyManagedMixin, SerializerModel):
 62    """Mapping of a group and provider to a Google group ID"""
 63
 64    id = models.UUIDField(primary_key=True, editable=False, default=uuid4)
 65    google_id = models.TextField()
 66    group = models.ForeignKey(Group, on_delete=models.CASCADE)
 67    provider = models.ForeignKey("GoogleWorkspaceProvider", on_delete=models.CASCADE)
 68    attributes = models.JSONField(default=dict)
 69
 70    @property
 71    def serializer(self) -> type[Serializer]:
 72        from authentik.enterprise.providers.google_workspace.api.groups import (
 73            GoogleWorkspaceProviderGroupSerializer,
 74        )
 75
 76        return GoogleWorkspaceProviderGroupSerializer
 77
 78    class Meta:
 79        verbose_name = _("Google Workspace Provider Group")
 80        verbose_name_plural = _("Google Workspace Provider Groups")
 81        unique_together = (("google_id", "group", "provider"),)
 82
 83    def __str__(self) -> str:
 84        return f"Google Workspace Provider Group {self.group_id} to {self.provider_id}"
 85
 86
 87class GoogleWorkspaceProvider(OutgoingSyncProvider, BackchannelProvider):
 88    """Sync users from authentik into Google Workspace."""
 89
 90    delegated_subject = models.EmailField()
 91    credentials = models.JSONField()
 92    scopes = models.TextField(default=",".join(default_scopes()))
 93
 94    default_group_email_domain = models.TextField()
 95    exclude_users_service_account = models.BooleanField(default=False)
 96    user_delete_action = models.TextField(
 97        choices=OutgoingSyncDeleteAction.choices, default=OutgoingSyncDeleteAction.DELETE
 98    )
 99    group_delete_action = models.TextField(
100        choices=OutgoingSyncDeleteAction.choices, default=OutgoingSyncDeleteAction.DELETE
101    )
102
103    filter_group = models.ForeignKey(
104        "authentik_core.group", on_delete=models.SET_DEFAULT, default=None, null=True
105    )
106
107    property_mappings_group = models.ManyToManyField(
108        PropertyMapping,
109        default=None,
110        blank=True,
111        help_text=_("Property mappings used for group creation/updating."),
112    )
113
114    @property
115    def sync_actor(self) -> Actor:
116        from authentik.enterprise.providers.google_workspace.tasks import google_workspace_sync
117
118        return google_workspace_sync
119
120    def client_for_model(
121        self,
122        model: type[User | Group | GoogleWorkspaceProviderUser | GoogleWorkspaceProviderGroup],
123    ) -> BaseOutgoingSyncClient[User | Group, Any, Any, Self]:
124        if issubclass(model, User | GoogleWorkspaceProviderUser):
125            from authentik.enterprise.providers.google_workspace.clients.users import (
126                GoogleWorkspaceUserClient,
127            )
128
129            return GoogleWorkspaceUserClient(self)
130        if issubclass(model, Group | GoogleWorkspaceProviderGroup):
131            from authentik.enterprise.providers.google_workspace.clients.groups import (
132                GoogleWorkspaceGroupClient,
133            )
134
135            return GoogleWorkspaceGroupClient(self)
136        raise ValueError(f"Invalid model {model}")
137
138    def get_object_qs(self, type: type[User | Group], **kwargs) -> QuerySet[User | Group]:
139        if type == User:
140            # Get queryset of all users with consistent ordering
141            # according to the provider's settings
142            base = User.objects.all().exclude_anonymous().filter(**kwargs)
143            if self.exclude_users_service_account:
144                base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
145                    type=UserTypes.INTERNAL_SERVICE_ACCOUNT
146                )
147            if self.filter_group:
148                base = base.filter(groups__in=[self.filter_group])
149            return base.order_by("pk")
150        if type == Group:
151            # Get queryset of all groups with consistent ordering
152            return Group.objects.all().filter(**kwargs).order_by("pk")
153        raise ValueError(f"Invalid type {type}")
154
155    @classmethod
156    def get_object_mappings(cls, obj: User | Group) -> list[tuple[str, str]]:
157        if isinstance(obj, User):
158            return list(
159                obj.googleworkspaceprovideruser_set.values_list("provider__pk", "google_id")
160            )
161        if isinstance(obj, Group):
162            return list(
163                obj.googleworkspaceprovidergroup_set.values_list("provider__pk", "google_id")
164            )
165        raise ValueError(f"Invalid type {type(obj)}")
166
167    def google_credentials(self):
168        return {
169            "credentials": Credentials.from_service_account_info(
170                self.credentials, scopes=self.scopes.split(",")
171            ).with_subject(self.delegated_subject),
172        }
173
174    @property
175    def icon_url(self) -> str | None:
176        return static("authentik/sources/google.svg")
177
178    @property
179    def component(self) -> str:
180        return "ak-provider-google-workspace-form"
181
182    @property
183    def serializer(self) -> type[Serializer]:
184        from authentik.enterprise.providers.google_workspace.api.providers import (
185            GoogleWorkspaceProviderSerializer,
186        )
187
188        return GoogleWorkspaceProviderSerializer
189
190    def __str__(self):
191        return f"Google Workspace Provider {self.name}"
192
193    class Meta:
194        verbose_name = _("Google Workspace Provider")
195        verbose_name_plural = _("Google Workspace Providers")
196
197
198class GoogleWorkspaceProviderMapping(PropertyMapping):
199    """Map authentik data to outgoing Google requests"""
200
201    @property
202    def component(self) -> str:
203        return "ak-property-mapping-provider-google-workspace-form"
204
205    @property
206    def serializer(self) -> type[Serializer]:
207        from authentik.enterprise.providers.google_workspace.api.property_mappings import (
208            GoogleWorkspaceProviderMappingSerializer,
209        )
210
211        return GoogleWorkspaceProviderMappingSerializer
212
213    def __str__(self):
214        return f"Google Workspace Provider Mapping {self.name}"
215
216    class Meta:
217        verbose_name = _("Google Workspace Provider Mapping")
218        verbose_name_plural = _("Google Workspace Provider Mappings")
def default_scopes() -> list[str]:
27def default_scopes() -> list[str]:
28    return [
29        "https://www.googleapis.com/auth/admin.directory.user",
30        "https://www.googleapis.com/auth/admin.directory.group",
31        "https://www.googleapis.com/auth/admin.directory.group.member",
32        "https://www.googleapis.com/auth/admin.directory.domain.readonly",
33    ]
36class GoogleWorkspaceProviderUser(InternallyManagedMixin, SerializerModel):
37    """Mapping of a user and provider to a Google user ID"""
38
39    id = models.UUIDField(primary_key=True, editable=False, default=uuid4)
40    google_id = models.TextField()
41    user = models.ForeignKey(User, on_delete=models.CASCADE)
42    provider = models.ForeignKey("GoogleWorkspaceProvider", on_delete=models.CASCADE)
43    attributes = models.JSONField(default=dict)
44
45    @property
46    def serializer(self) -> type[Serializer]:
47        from authentik.enterprise.providers.google_workspace.api.users import (
48            GoogleWorkspaceProviderUserSerializer,
49        )
50
51        return GoogleWorkspaceProviderUserSerializer
52
53    class Meta:
54        verbose_name = _("Google Workspace Provider User")
55        verbose_name_plural = _("Google Workspace Provider Users")
56        unique_together = (("google_id", "user", "provider"),)
57
58    def __str__(self) -> str:
59        return f"Google Workspace Provider User {self.user_id} to {self.provider_id}"

Mapping of a user and provider to a Google user ID

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def google_id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

provider

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def attributes(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

serializer: type[rest_framework.serializers.Serializer]
45    @property
46    def serializer(self) -> type[Serializer]:
47        from authentik.enterprise.providers.google_workspace.api.users import (
48            GoogleWorkspaceProviderUserSerializer,
49        )
50
51        return GoogleWorkspaceProviderUserSerializer

Get serializer for this model

user_id
provider_id
def objects(unknown):

The type of the None singleton.

class GoogleWorkspaceProviderUser.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class GoogleWorkspaceProviderUser.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

class GoogleWorkspaceProviderGroup(authentik.lib.models.InternallyManagedMixin, authentik.lib.models.SerializerModel):
62class GoogleWorkspaceProviderGroup(InternallyManagedMixin, SerializerModel):
63    """Mapping of a group and provider to a Google group ID"""
64
65    id = models.UUIDField(primary_key=True, editable=False, default=uuid4)
66    google_id = models.TextField()
67    group = models.ForeignKey(Group, on_delete=models.CASCADE)
68    provider = models.ForeignKey("GoogleWorkspaceProvider", on_delete=models.CASCADE)
69    attributes = models.JSONField(default=dict)
70
71    @property
72    def serializer(self) -> type[Serializer]:
73        from authentik.enterprise.providers.google_workspace.api.groups import (
74            GoogleWorkspaceProviderGroupSerializer,
75        )
76
77        return GoogleWorkspaceProviderGroupSerializer
78
79    class Meta:
80        verbose_name = _("Google Workspace Provider Group")
81        verbose_name_plural = _("Google Workspace Provider Groups")
82        unique_together = (("google_id", "group", "provider"),)
83
84    def __str__(self) -> str:
85        return f"Google Workspace Provider Group {self.group_id} to {self.provider_id}"

Mapping of a group and provider to a Google group ID

def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def google_id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

group

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

provider

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

def attributes(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

serializer: type[rest_framework.serializers.Serializer]
71    @property
72    def serializer(self) -> type[Serializer]:
73        from authentik.enterprise.providers.google_workspace.api.groups import (
74            GoogleWorkspaceProviderGroupSerializer,
75        )
76
77        return GoogleWorkspaceProviderGroupSerializer

Get serializer for this model

group_id
provider_id
def objects(unknown):

The type of the None singleton.

class GoogleWorkspaceProviderGroup.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class GoogleWorkspaceProviderGroup.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

 88class GoogleWorkspaceProvider(OutgoingSyncProvider, BackchannelProvider):
 89    """Sync users from authentik into Google Workspace."""
 90
 91    delegated_subject = models.EmailField()
 92    credentials = models.JSONField()
 93    scopes = models.TextField(default=",".join(default_scopes()))
 94
 95    default_group_email_domain = models.TextField()
 96    exclude_users_service_account = models.BooleanField(default=False)
 97    user_delete_action = models.TextField(
 98        choices=OutgoingSyncDeleteAction.choices, default=OutgoingSyncDeleteAction.DELETE
 99    )
100    group_delete_action = models.TextField(
101        choices=OutgoingSyncDeleteAction.choices, default=OutgoingSyncDeleteAction.DELETE
102    )
103
104    filter_group = models.ForeignKey(
105        "authentik_core.group", on_delete=models.SET_DEFAULT, default=None, null=True
106    )
107
108    property_mappings_group = models.ManyToManyField(
109        PropertyMapping,
110        default=None,
111        blank=True,
112        help_text=_("Property mappings used for group creation/updating."),
113    )
114
115    @property
116    def sync_actor(self) -> Actor:
117        from authentik.enterprise.providers.google_workspace.tasks import google_workspace_sync
118
119        return google_workspace_sync
120
121    def client_for_model(
122        self,
123        model: type[User | Group | GoogleWorkspaceProviderUser | GoogleWorkspaceProviderGroup],
124    ) -> BaseOutgoingSyncClient[User | Group, Any, Any, Self]:
125        if issubclass(model, User | GoogleWorkspaceProviderUser):
126            from authentik.enterprise.providers.google_workspace.clients.users import (
127                GoogleWorkspaceUserClient,
128            )
129
130            return GoogleWorkspaceUserClient(self)
131        if issubclass(model, Group | GoogleWorkspaceProviderGroup):
132            from authentik.enterprise.providers.google_workspace.clients.groups import (
133                GoogleWorkspaceGroupClient,
134            )
135
136            return GoogleWorkspaceGroupClient(self)
137        raise ValueError(f"Invalid model {model}")
138
139    def get_object_qs(self, type: type[User | Group], **kwargs) -> QuerySet[User | Group]:
140        if type == User:
141            # Get queryset of all users with consistent ordering
142            # according to the provider's settings
143            base = User.objects.all().exclude_anonymous().filter(**kwargs)
144            if self.exclude_users_service_account:
145                base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
146                    type=UserTypes.INTERNAL_SERVICE_ACCOUNT
147                )
148            if self.filter_group:
149                base = base.filter(groups__in=[self.filter_group])
150            return base.order_by("pk")
151        if type == Group:
152            # Get queryset of all groups with consistent ordering
153            return Group.objects.all().filter(**kwargs).order_by("pk")
154        raise ValueError(f"Invalid type {type}")
155
156    @classmethod
157    def get_object_mappings(cls, obj: User | Group) -> list[tuple[str, str]]:
158        if isinstance(obj, User):
159            return list(
160                obj.googleworkspaceprovideruser_set.values_list("provider__pk", "google_id")
161            )
162        if isinstance(obj, Group):
163            return list(
164                obj.googleworkspaceprovidergroup_set.values_list("provider__pk", "google_id")
165            )
166        raise ValueError(f"Invalid type {type(obj)}")
167
168    def google_credentials(self):
169        return {
170            "credentials": Credentials.from_service_account_info(
171                self.credentials, scopes=self.scopes.split(",")
172            ).with_subject(self.delegated_subject),
173        }
174
175    @property
176    def icon_url(self) -> str | None:
177        return static("authentik/sources/google.svg")
178
179    @property
180    def component(self) -> str:
181        return "ak-provider-google-workspace-form"
182
183    @property
184    def serializer(self) -> type[Serializer]:
185        from authentik.enterprise.providers.google_workspace.api.providers import (
186            GoogleWorkspaceProviderSerializer,
187        )
188
189        return GoogleWorkspaceProviderSerializer
190
191    def __str__(self):
192        return f"Google Workspace Provider {self.name}"
193
194    class Meta:
195        verbose_name = _("Google Workspace Provider")
196        verbose_name_plural = _("Google Workspace Providers")

Sync users from authentik into Google Workspace.

def delegated_subject(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def credentials(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def scopes(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def default_group_email_domain(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def exclude_users_service_account(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def user_delete_action(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def group_delete_action(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

filter_group

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

property_mappings_group

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example::

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

sync_actor: dramatiq.actor.Actor
115    @property
116    def sync_actor(self) -> Actor:
117        from authentik.enterprise.providers.google_workspace.tasks import google_workspace_sync
118
119        return google_workspace_sync
121    def client_for_model(
122        self,
123        model: type[User | Group | GoogleWorkspaceProviderUser | GoogleWorkspaceProviderGroup],
124    ) -> BaseOutgoingSyncClient[User | Group, Any, Any, Self]:
125        if issubclass(model, User | GoogleWorkspaceProviderUser):
126            from authentik.enterprise.providers.google_workspace.clients.users import (
127                GoogleWorkspaceUserClient,
128            )
129
130            return GoogleWorkspaceUserClient(self)
131        if issubclass(model, Group | GoogleWorkspaceProviderGroup):
132            from authentik.enterprise.providers.google_workspace.clients.groups import (
133                GoogleWorkspaceGroupClient,
134            )
135
136            return GoogleWorkspaceGroupClient(self)
137        raise ValueError(f"Invalid model {model}")
def get_object_qs( self, type: type[authentik.core.models.User | authentik.core.models.Group], **kwargs) -> django.db.models.query.QuerySet:
139    def get_object_qs(self, type: type[User | Group], **kwargs) -> QuerySet[User | Group]:
140        if type == User:
141            # Get queryset of all users with consistent ordering
142            # according to the provider's settings
143            base = User.objects.all().exclude_anonymous().filter(**kwargs)
144            if self.exclude_users_service_account:
145                base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
146                    type=UserTypes.INTERNAL_SERVICE_ACCOUNT
147                )
148            if self.filter_group:
149                base = base.filter(groups__in=[self.filter_group])
150            return base.order_by("pk")
151        if type == Group:
152            # Get queryset of all groups with consistent ordering
153            return Group.objects.all().filter(**kwargs).order_by("pk")
154        raise ValueError(f"Invalid type {type}")
@classmethod
def get_object_mappings( cls, obj: authentik.core.models.User | authentik.core.models.Group) -> list[tuple[str, str]]:
156    @classmethod
157    def get_object_mappings(cls, obj: User | Group) -> list[tuple[str, str]]:
158        if isinstance(obj, User):
159            return list(
160                obj.googleworkspaceprovideruser_set.values_list("provider__pk", "google_id")
161            )
162        if isinstance(obj, Group):
163            return list(
164                obj.googleworkspaceprovidergroup_set.values_list("provider__pk", "google_id")
165            )
166        raise ValueError(f"Invalid type {type(obj)}")

Get a list of mapping between User/Group and ProviderUser/Group: [("provider_pk", "obj_pk")]

def google_credentials(self):
168    def google_credentials(self):
169        return {
170            "credentials": Credentials.from_service_account_info(
171                self.credentials, scopes=self.scopes.split(",")
172            ).with_subject(self.delegated_subject),
173        }
icon_url: str | None
175    @property
176    def icon_url(self) -> str | None:
177        return static("authentik/sources/google.svg")
component: str
179    @property
180    def component(self) -> str:
181        return "ak-provider-google-workspace-form"

Return component used to edit this object

serializer: type[rest_framework.serializers.Serializer]
183    @property
184    def serializer(self) -> type[Serializer]:
185        from authentik.enterprise.providers.google_workspace.api.providers import (
186            GoogleWorkspaceProviderSerializer,
187        )
188
189        return GoogleWorkspaceProviderSerializer

Get serializer for this model

def sync_page_size(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def sync_page_timeout(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def dry_run(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

schedules

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example::

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

tasks

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example::

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

def get_user_delete_action_display(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_group_delete_action_display(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

filter_group_id
provider_ptr_id
provider_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example::

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

googleworkspaceprovideruser_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

googleworkspaceprovidergroup_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example::

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class GoogleWorkspaceProvider.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class GoogleWorkspaceProvider.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

class GoogleWorkspaceProviderMapping(authentik.core.models.PropertyMapping):
199class GoogleWorkspaceProviderMapping(PropertyMapping):
200    """Map authentik data to outgoing Google requests"""
201
202    @property
203    def component(self) -> str:
204        return "ak-property-mapping-provider-google-workspace-form"
205
206    @property
207    def serializer(self) -> type[Serializer]:
208        from authentik.enterprise.providers.google_workspace.api.property_mappings import (
209            GoogleWorkspaceProviderMappingSerializer,
210        )
211
212        return GoogleWorkspaceProviderMappingSerializer
213
214    def __str__(self):
215        return f"Google Workspace Provider Mapping {self.name}"
216
217    class Meta:
218        verbose_name = _("Google Workspace Provider Mapping")
219        verbose_name_plural = _("Google Workspace Provider Mappings")

Map authentik data to outgoing Google requests

component: str
202    @property
203    def component(self) -> str:
204        return "ak-property-mapping-provider-google-workspace-form"

Return component used to edit this object

serializer: type[rest_framework.serializers.Serializer]
206    @property
207    def serializer(self) -> type[Serializer]:
208        from authentik.enterprise.providers.google_workspace.api.property_mappings import (
209            GoogleWorkspaceProviderMappingSerializer,
210        )
211
212        return GoogleWorkspaceProviderMappingSerializer

Get serializer for this model

propertymapping_ptr_id
propertymapping_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example::

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

class GoogleWorkspaceProviderMapping.DoesNotExist(authentik.core.models.PropertyMapping.DoesNotExist):

The requested object does not exist

class GoogleWorkspaceProviderMapping.MultipleObjectsReturned(authentik.core.models.PropertyMapping.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.