We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
OAuth sources seem to be linked to every account
**Describe the bug**
Opening user settings then going to "Connected services" seem to show everyone's connections instead of just the current authenticated user

**To Reproduce**
Steps to reproduce the behavior:
1. Login using existing user (User A)
2. Go to account settings -> connected services to see no connected services
3. In another browser go to login page and login using OAuth (User B)
4. User A now goes to connected services to see that they have the same OAuth connected
5. Logging out of User A and logging in with OAuth will login as User B
6. Disconnecting OAuth from User A will not disconnect it from User B, but will appear to have

**Expected behavior**
OAuth management page (connected services) should only show oauth relations that the current user has.

**Screenshots**
![image](https://user-images.githubusercontent.com/46821216/221099352-afae0130-f9f0-4d77-bcfb-857236850dbe.png)
![image](https://user-images.githubusercontent.com/46821216/221099369-f3b71bd6-f6e4-4adb-a6dd-26dd4f5ad6c2.png)

![image](https://user-images.githubusercontent.com/46821216/221099395-b6620aa2-d59a-4fdf-acfb-3f370aa62d57.png)
![image](https://user-images.githubusercontent.com/46821216/221099406-ab2b0747-42a1-4527-b270-11f0b408c36a.png)

**Logs**
Admin Interface -> Event Logs:
- Model Created from grant2 (User B)
- Source Linked from grant2 (User B)
- Model Deleted from grant (User A)

**Version and Deployment (please complete the following information):**
 - authentik version: 2023.2.2
 - Deployment: docker-compose

**Additional context**
Add any other context about the problem here.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `authentik/core/api/sources.py`
Content:
```
1 """Source API Views"""
2 from typing import Iterable
3 
4 from django_filters.rest_framework import DjangoFilterBackend
5 from drf_spectacular.utils import OpenApiResponse, extend_schema
6 from rest_framework import mixins
7 from rest_framework.decorators import action
8 from rest_framework.filters import OrderingFilter, SearchFilter
9 from rest_framework.parsers import MultiPartParser
10 from rest_framework.request import Request
11 from rest_framework.response import Response
12 from rest_framework.serializers import ModelSerializer, ReadOnlyField, SerializerMethodField
13 from rest_framework.viewsets import GenericViewSet
14 from structlog.stdlib import get_logger
15 
16 from authentik.api.authorization import OwnerFilter, OwnerSuperuserPermissions
17 from authentik.api.decorators import permission_required
18 from authentik.core.api.used_by import UsedByMixin
19 from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
20 from authentik.core.models import Source, UserSourceConnection
21 from authentik.core.types import UserSettingSerializer
22 from authentik.lib.utils.file import (
23     FilePathSerializer,
24     FileUploadSerializer,
25     set_file,
26     set_file_url,
27 )
28 from authentik.lib.utils.reflection import all_subclasses
29 from authentik.policies.engine import PolicyEngine
30 
31 LOGGER = get_logger()
32 
33 
34 class SourceSerializer(ModelSerializer, MetaNameSerializer):
35     """Source Serializer"""
36 
37     managed = ReadOnlyField()
38     component = SerializerMethodField()
39     icon = ReadOnlyField(source="get_icon")
40 
41     def get_component(self, obj: Source) -> str:
42         """Get object component so that we know how to edit the object"""
43         # pyright: reportGeneralTypeIssues=false
44         if obj.__class__ == Source:
45             return ""
46         return obj.component
47 
48     class Meta:
49         model = Source
50         fields = [
51             "pk",
52             "name",
53             "slug",
54             "enabled",
55             "authentication_flow",
56             "enrollment_flow",
57             "component",
58             "verbose_name",
59             "verbose_name_plural",
60             "meta_model_name",
61             "policy_engine_mode",
62             "user_matching_mode",
63             "managed",
64             "user_path_template",
65             "icon",
66         ]
67 
68 
69 class SourceViewSet(
70     mixins.RetrieveModelMixin,
71     mixins.DestroyModelMixin,
72     UsedByMixin,
73     mixins.ListModelMixin,
74     GenericViewSet,
75 ):
76     """Source Viewset"""
77 
78     queryset = Source.objects.none()
79     serializer_class = SourceSerializer
80     lookup_field = "slug"
81     search_fields = ["slug", "name"]
82     filterset_fields = ["slug", "name", "managed"]
83 
84     def get_queryset(self):  # pragma: no cover
85         return Source.objects.select_subclasses()
86 
87     @permission_required("authentik_core.change_source")
88     @extend_schema(
89         request={
90             "multipart/form-data": FileUploadSerializer,
91         },
92         responses={
93             200: OpenApiResponse(description="Success"),
94             400: OpenApiResponse(description="Bad request"),
95         },
96     )
97     @action(
98         detail=True,
99         pagination_class=None,
100         filter_backends=[],
101         methods=["POST"],
102         parser_classes=(MultiPartParser,),
103     )
104     def set_icon(self, request: Request, slug: str):
105         """Set source icon"""
106         source: Source = self.get_object()
107         return set_file(request, source, "icon")
108 
109     @permission_required("authentik_core.change_source")
110     @extend_schema(
111         request=FilePathSerializer,
112         responses={
113             200: OpenApiResponse(description="Success"),
114             400: OpenApiResponse(description="Bad request"),
115         },
116     )
117     @action(
118         detail=True,
119         pagination_class=None,
120         filter_backends=[],
121         methods=["POST"],
122     )
123     def set_icon_url(self, request: Request, slug: str):
124         """Set source icon (as URL)"""
125         source: Source = self.get_object()
126         return set_file_url(request, source, "icon")
127 
128     @extend_schema(responses={200: TypeCreateSerializer(many=True)})
129     @action(detail=False, pagination_class=None, filter_backends=[])
130     def types(self, request: Request) -> Response:
131         """Get all creatable source types"""
132         data = []
133         for subclass in all_subclasses(self.queryset.model):
134             subclass: Source
135             component = ""
136             if len(subclass.__subclasses__()) > 0:
137                 continue
138             if subclass._meta.abstract:
139                 component = subclass.__bases__[0]().component
140             else:
141                 component = subclass().component
142             # pyright: reportGeneralTypeIssues=false
143             data.append(
144                 {
145                     "name": subclass._meta.verbose_name,
146                     "description": subclass.__doc__,
147                     "component": component,
148                     "model_name": subclass._meta.model_name,
149                 }
150             )
151         return Response(TypeCreateSerializer(data, many=True).data)
152 
153     @extend_schema(responses={200: UserSettingSerializer(many=True)})
154     @action(detail=False, pagination_class=None, filter_backends=[])
155     def user_settings(self, request: Request) -> Response:
156         """Get all sources the user can configure"""
157         _all_sources: Iterable[Source] = (
158             Source.objects.filter(enabled=True).select_subclasses().order_by("name")
159         )
160         matching_sources: list[UserSettingSerializer] = []
161         for source in _all_sources:
162             user_settings = source.ui_user_settings()
163             if not user_settings:
164                 continue
165             policy_engine = PolicyEngine(source, request.user, request)
166             policy_engine.build()
167             if not policy_engine.passing:
168                 continue
169             source_settings = source.ui_user_settings()
170             source_settings.initial_data["object_uid"] = source.slug
171             if not source_settings.is_valid():
172                 LOGGER.warning(source_settings.errors)
173             matching_sources.append(source_settings.validated_data)
174         return Response(matching_sources)
175 
176 
177 class UserSourceConnectionSerializer(SourceSerializer):
178     """OAuth Source Serializer"""
179 
180     source = SourceSerializer(read_only=True)
181 
182     class Meta:
183         model = UserSourceConnection
184         fields = [
185             "pk",
186             "user",
187             "source",
188             "created",
189         ]
190         extra_kwargs = {
191             "user": {"read_only": True},
192             "created": {"read_only": True},
193         }
194 
195 
196 class UserSourceConnectionViewSet(
197     mixins.RetrieveModelMixin,
198     mixins.UpdateModelMixin,
199     mixins.DestroyModelMixin,
200     UsedByMixin,
201     mixins.ListModelMixin,
202     GenericViewSet,
203 ):
204     """User-source connection Viewset"""
205 
206     queryset = UserSourceConnection.objects.all()
207     serializer_class = UserSourceConnectionSerializer
208     permission_classes = [OwnerSuperuserPermissions]
209     filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter]
210     ordering = ["pk"]
211
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py
--- a/authentik/core/api/sources.py
+++ b/authentik/core/api/sources.py
@@ -206,5 +206,6 @@
     queryset = UserSourceConnection.objects.all()
     serializer_class = UserSourceConnectionSerializer
     permission_classes = [OwnerSuperuserPermissions]
+    filterset_fields = ["user"]
     filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter]
     ordering = ["pk"]

{"golden_diff": "diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py\n--- a/authentik/core/api/sources.py\n+++ b/authentik/core/api/sources.py\n@@ -206,5 +206,6 @@\n     queryset = UserSourceConnection.objects.all()\n     serializer_class = UserSourceConnectionSerializer\n     permission_classes = [OwnerSuperuserPermissions]\n+    filterset_fields = [\"user\"]\n     filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter]\n     ordering = [\"pk\"]\n", "issue": "OAuth sources seem to be linked to every account\n**Describe the bug**\r\nOpening user settings then going to \"Connected services\" seem to show everyone's connections instead of just the current authenticated user\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Login using existing user (User A)\r\n2. Go to account settings -> connected services to see no connected services\r\n3. In another browser go to login page and login using OAuth (User B)\r\n4. User A now goes to connected services to see that they have the same OAuth connected\r\n5. Logging out of User A and logging in with OAuth will login as User B\r\n6. Disconnecting OAuth from User A will not disconnect it from User B, but will appear to have\r\n\r\n**Expected behavior**\r\nOAuth management page (connected services) should only show oauth relations that the current user has.\r\n\r\n**Screenshots**\r\n![image](https://user-images.githubusercontent.com/46821216/221099352-afae0130-f9f0-4d77-bcfb-857236850dbe.png)\r\n![image](https://user-images.githubusercontent.com/46821216/221099369-f3b71bd6-f6e4-4adb-a6dd-26dd4f5ad6c2.png)\r\n\r\n![image](https://user-images.githubusercontent.com/46821216/221099395-b6620aa2-d59a-4fdf-acfb-3f370aa62d57.png)\r\n![image](https://user-images.githubusercontent.com/46821216/221099406-ab2b0747-42a1-4527-b270-11f0b408c36a.png)\r\n\r\n**Logs**\r\nAdmin Interface -> Event Logs:\r\n- Model Created from grant2 (User B)\r\n- Source Linked from grant2 (User B)\r\n- Model Deleted from grant (User A)\r\n\r\n**Version and Deployment (please complete the following information):**\r\n - authentik version: 2023.2.2\r\n - Deployment: docker-compose\r\n\r\n**Additional context**\r\nAdd any other context about the problem here.\r\n\n", "before_files": [{"content": "\"\"\"Source API Views\"\"\"\nfrom typing import Iterable\n\nfrom django_filters.rest_framework import DjangoFilterBackend\nfrom drf_spectacular.utils import OpenApiResponse, extend_schema\nfrom rest_framework import mixins\nfrom rest_framework.decorators import action\nfrom rest_framework.filters import OrderingFilter, SearchFilter\nfrom rest_framework.parsers import MultiPartParser\nfrom rest_framework.request import Request\nfrom rest_framework.response import Response\nfrom rest_framework.serializers import ModelSerializer, ReadOnlyField, SerializerMethodField\nfrom rest_framework.viewsets import GenericViewSet\nfrom structlog.stdlib import get_logger\n\nfrom authentik.api.authorization import OwnerFilter, OwnerSuperuserPermissions\nfrom authentik.api.decorators import permission_required\nfrom authentik.core.api.used_by import UsedByMixin\nfrom authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer\nfrom authentik.core.models import Source, UserSourceConnection\nfrom authentik.core.types import UserSettingSerializer\nfrom authentik.lib.utils.file import (\n    FilePathSerializer,\n    FileUploadSerializer,\n    set_file,\n    set_file_url,\n)\nfrom authentik.lib.utils.reflection import all_subclasses\nfrom authentik.policies.engine import PolicyEngine\n\nLOGGER = get_logger()\n\n\nclass SourceSerializer(ModelSerializer, MetaNameSerializer):\n    \"\"\"Source Serializer\"\"\"\n\n    managed = ReadOnlyField()\n    component = SerializerMethodField()\n    icon = ReadOnlyField(source=\"get_icon\")\n\n    def get_component(self, obj: Source) -> str:\n        \"\"\"Get object component so that we know how to edit the object\"\"\"\n        # pyright: reportGeneralTypeIssues=false\n        if obj.__class__ == Source:\n            return \"\"\n        return obj.component\n\n    class Meta:\n        model = Source\n        fields = [\n            \"pk\",\n            \"name\",\n            \"slug\",\n            \"enabled\",\n            \"authentication_flow\",\n            \"enrollment_flow\",\n            \"component\",\n            \"verbose_name\",\n            \"verbose_name_plural\",\n            \"meta_model_name\",\n            \"policy_engine_mode\",\n            \"user_matching_mode\",\n            \"managed\",\n            \"user_path_template\",\n            \"icon\",\n        ]\n\n\nclass SourceViewSet(\n    mixins.RetrieveModelMixin,\n    mixins.DestroyModelMixin,\n    UsedByMixin,\n    mixins.ListModelMixin,\n    GenericViewSet,\n):\n    \"\"\"Source Viewset\"\"\"\n\n    queryset = Source.objects.none()\n    serializer_class = SourceSerializer\n    lookup_field = \"slug\"\n    search_fields = [\"slug\", \"name\"]\n    filterset_fields = [\"slug\", \"name\", \"managed\"]\n\n    def get_queryset(self):  # pragma: no cover\n        return Source.objects.select_subclasses()\n\n    @permission_required(\"authentik_core.change_source\")\n    @extend_schema(\n        request={\n            \"multipart/form-data\": FileUploadSerializer,\n        },\n        responses={\n            200: OpenApiResponse(description=\"Success\"),\n            400: OpenApiResponse(description=\"Bad request\"),\n        },\n    )\n    @action(\n        detail=True,\n        pagination_class=None,\n        filter_backends=[],\n        methods=[\"POST\"],\n        parser_classes=(MultiPartParser,),\n    )\n    def set_icon(self, request: Request, slug: str):\n        \"\"\"Set source icon\"\"\"\n        source: Source = self.get_object()\n        return set_file(request, source, \"icon\")\n\n    @permission_required(\"authentik_core.change_source\")\n    @extend_schema(\n        request=FilePathSerializer,\n        responses={\n            200: OpenApiResponse(description=\"Success\"),\n            400: OpenApiResponse(description=\"Bad request\"),\n        },\n    )\n    @action(\n        detail=True,\n        pagination_class=None,\n        filter_backends=[],\n        methods=[\"POST\"],\n    )\n    def set_icon_url(self, request: Request, slug: str):\n        \"\"\"Set source icon (as URL)\"\"\"\n        source: Source = self.get_object()\n        return set_file_url(request, source, \"icon\")\n\n    @extend_schema(responses={200: TypeCreateSerializer(many=True)})\n    @action(detail=False, pagination_class=None, filter_backends=[])\n    def types(self, request: Request) -> Response:\n        \"\"\"Get all creatable source types\"\"\"\n        data = []\n        for subclass in all_subclasses(self.queryset.model):\n            subclass: Source\n            component = \"\"\n            if len(subclass.__subclasses__()) > 0:\n                continue\n            if subclass._meta.abstract:\n                component = subclass.__bases__[0]().component\n            else:\n                component = subclass().component\n            # pyright: reportGeneralTypeIssues=false\n            data.append(\n                {\n                    \"name\": subclass._meta.verbose_name,\n                    \"description\": subclass.__doc__,\n                    \"component\": component,\n                    \"model_name\": subclass._meta.model_name,\n                }\n            )\n        return Response(TypeCreateSerializer(data, many=True).data)\n\n    @extend_schema(responses={200: UserSettingSerializer(many=True)})\n    @action(detail=False, pagination_class=None, filter_backends=[])\n    def user_settings(self, request: Request) -> Response:\n        \"\"\"Get all sources the user can configure\"\"\"\n        _all_sources: Iterable[Source] = (\n            Source.objects.filter(enabled=True).select_subclasses().order_by(\"name\")\n        )\n        matching_sources: list[UserSettingSerializer] = []\n        for source in _all_sources:\n            user_settings = source.ui_user_settings()\n            if not user_settings:\n                continue\n            policy_engine = PolicyEngine(source, request.user, request)\n            policy_engine.build()\n            if not policy_engine.passing:\n                continue\n            source_settings = source.ui_user_settings()\n            source_settings.initial_data[\"object_uid\"] = source.slug\n            if not source_settings.is_valid():\n                LOGGER.warning(source_settings.errors)\n            matching_sources.append(source_settings.validated_data)\n        return Response(matching_sources)\n\n\nclass UserSourceConnectionSerializer(SourceSerializer):\n    \"\"\"OAuth Source Serializer\"\"\"\n\n    source = SourceSerializer(read_only=True)\n\n    class Meta:\n        model = UserSourceConnection\n        fields = [\n            \"pk\",\n            \"user\",\n            \"source\",\n            \"created\",\n        ]\n        extra_kwargs = {\n            \"user\": {\"read_only\": True},\n            \"created\": {\"read_only\": True},\n        }\n\n\nclass UserSourceConnectionViewSet(\n    mixins.RetrieveModelMixin,\n    mixins.UpdateModelMixin,\n    mixins.DestroyModelMixin,\n    UsedByMixin,\n    mixins.ListModelMixin,\n    GenericViewSet,\n):\n    \"\"\"User-source connection Viewset\"\"\"\n\n    queryset = UserSourceConnection.objects.all()\n    serializer_class = UserSourceConnectionSerializer\n    permission_classes = [OwnerSuperuserPermissions]\n    filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter]\n    ordering = [\"pk\"]\n", "path": "authentik/core/api/sources.py"}], "after_files": [{"content": "\"\"\"Source API Views\"\"\"\nfrom typing import Iterable\n\nfrom django_filters.rest_framework import DjangoFilterBackend\nfrom drf_spectacular.utils import OpenApiResponse, extend_schema\nfrom rest_framework import mixins\nfrom rest_framework.decorators import action\nfrom rest_framework.filters import OrderingFilter, SearchFilter\nfrom rest_framework.parsers import MultiPartParser\nfrom rest_framework.request import Request\nfrom rest_framework.response import Response\nfrom rest_framework.serializers import ModelSerializer, ReadOnlyField, SerializerMethodField\nfrom rest_framework.viewsets import GenericViewSet\nfrom structlog.stdlib import get_logger\n\nfrom authentik.api.authorization import OwnerFilter, OwnerSuperuserPermissions\nfrom authentik.api.decorators import permission_required\nfrom authentik.core.api.used_by import UsedByMixin\nfrom authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer\nfrom authentik.core.models import Source, UserSourceConnection\nfrom authentik.core.types import UserSettingSerializer\nfrom authentik.lib.utils.file import (\n    FilePathSerializer,\n    FileUploadSerializer,\n    set_file,\n    set_file_url,\n)\nfrom authentik.lib.utils.reflection import all_subclasses\nfrom authentik.policies.engine import PolicyEngine\n\nLOGGER = get_logger()\n\n\nclass SourceSerializer(ModelSerializer, MetaNameSerializer):\n    \"\"\"Source Serializer\"\"\"\n\n    managed = ReadOnlyField()\n    component = SerializerMethodField()\n    icon = ReadOnlyField(source=\"get_icon\")\n\n    def get_component(self, obj: Source) -> str:\n        \"\"\"Get object component so that we know how to edit the object\"\"\"\n        # pyright: reportGeneralTypeIssues=false\n        if obj.__class__ == Source:\n            return \"\"\n        return obj.component\n\n    class Meta:\n        model = Source\n        fields = [\n            \"pk\",\n            \"name\",\n            \"slug\",\n            \"enabled\",\n            \"authentication_flow\",\n            \"enrollment_flow\",\n            \"component\",\n            \"verbose_name\",\n            \"verbose_name_plural\",\n            \"meta_model_name\",\n            \"policy_engine_mode\",\n            \"user_matching_mode\",\n            \"managed\",\n            \"user_path_template\",\n            \"icon\",\n        ]\n\n\nclass SourceViewSet(\n    mixins.RetrieveModelMixin,\n    mixins.DestroyModelMixin,\n    UsedByMixin,\n    mixins.ListModelMixin,\n    GenericViewSet,\n):\n    \"\"\"Source Viewset\"\"\"\n\n    queryset = Source.objects.none()\n    serializer_class = SourceSerializer\n    lookup_field = \"slug\"\n    search_fields = [\"slug\", \"name\"]\n    filterset_fields = [\"slug\", \"name\", \"managed\"]\n\n    def get_queryset(self):  # pragma: no cover\n        return Source.objects.select_subclasses()\n\n    @permission_required(\"authentik_core.change_source\")\n    @extend_schema(\n        request={\n            \"multipart/form-data\": FileUploadSerializer,\n        },\n        responses={\n            200: OpenApiResponse(description=\"Success\"),\n            400: OpenApiResponse(description=\"Bad request\"),\n        },\n    )\n    @action(\n        detail=True,\n        pagination_class=None,\n        filter_backends=[],\n        methods=[\"POST\"],\n        parser_classes=(MultiPartParser,),\n    )\n    def set_icon(self, request: Request, slug: str):\n        \"\"\"Set source icon\"\"\"\n        source: Source = self.get_object()\n        return set_file(request, source, \"icon\")\n\n    @permission_required(\"authentik_core.change_source\")\n    @extend_schema(\n        request=FilePathSerializer,\n        responses={\n            200: OpenApiResponse(description=\"Success\"),\n            400: OpenApiResponse(description=\"Bad request\"),\n        },\n    )\n    @action(\n        detail=True,\n        pagination_class=None,\n        filter_backends=[],\n        methods=[\"POST\"],\n    )\n    def set_icon_url(self, request: Request, slug: str):\n        \"\"\"Set source icon (as URL)\"\"\"\n        source: Source = self.get_object()\n        return set_file_url(request, source, \"icon\")\n\n    @extend_schema(responses={200: TypeCreateSerializer(many=True)})\n    @action(detail=False, pagination_class=None, filter_backends=[])\n    def types(self, request: Request) -> Response:\n        \"\"\"Get all creatable source types\"\"\"\n        data = []\n        for subclass in all_subclasses(self.queryset.model):\n            subclass: Source\n            component = \"\"\n            if len(subclass.__subclasses__()) > 0:\n                continue\n            if subclass._meta.abstract:\n                component = subclass.__bases__[0]().component\n            else:\n                component = subclass().component\n            # pyright: reportGeneralTypeIssues=false\n            data.append(\n                {\n                    \"name\": subclass._meta.verbose_name,\n                    \"description\": subclass.__doc__,\n                    \"component\": component,\n                    \"model_name\": subclass._meta.model_name,\n                }\n            )\n        return Response(TypeCreateSerializer(data, many=True).data)\n\n    @extend_schema(responses={200: UserSettingSerializer(many=True)})\n    @action(detail=False, pagination_class=None, filter_backends=[])\n    def user_settings(self, request: Request) -> Response:\n        \"\"\"Get all sources the user can configure\"\"\"\n        _all_sources: Iterable[Source] = (\n            Source.objects.filter(enabled=True).select_subclasses().order_by(\"name\")\n        )\n        matching_sources: list[UserSettingSerializer] = []\n        for source in _all_sources:\n            user_settings = source.ui_user_settings()\n            if not user_settings:\n                continue\n            policy_engine = PolicyEngine(source, request.user, request)\n            policy_engine.build()\n            if not policy_engine.passing:\n                continue\n            source_settings = source.ui_user_settings()\n            source_settings.initial_data[\"object_uid\"] = source.slug\n            if not source_settings.is_valid():\n                LOGGER.warning(source_settings.errors)\n            matching_sources.append(source_settings.validated_data)\n        return Response(matching_sources)\n\n\nclass UserSourceConnectionSerializer(SourceSerializer):\n    \"\"\"OAuth Source Serializer\"\"\"\n\n    source = SourceSerializer(read_only=True)\n\n    class Meta:\n        model = UserSourceConnection\n        fields = [\n            \"pk\",\n            \"user\",\n            \"source\",\n            \"created\",\n        ]\n        extra_kwargs = {\n            \"user\": {\"read_only\": True},\n            \"created\": {\"read_only\": True},\n        }\n\n\nclass UserSourceConnectionViewSet(\n    mixins.RetrieveModelMixin,\n    mixins.UpdateModelMixin,\n    mixins.DestroyModelMixin,\n    UsedByMixin,\n    mixins.ListModelMixin,\n    GenericViewSet,\n):\n    \"\"\"User-source connection Viewset\"\"\"\n\n    queryset = UserSourceConnection.objects.all()\n    serializer_class = UserSourceConnectionSerializer\n    permission_classes = [OwnerSuperuserPermissions]\n    filterset_fields = [\"user\"]\n    filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter]\n    ordering = [\"pk\"]\n", "path": "authentik/core/api/sources.py"}]}