Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2025-06-25 14:54:56 +02:00
parent 13b5aa604b
commit d132db475e
29 changed files with 20 additions and 41 deletions

View File

@ -1,7 +1,5 @@
"""v1 blueprints tasks""" """v1 blueprints tasks"""
from django.utils.translation import gettext_lazy as _
from dataclasses import asdict, dataclass, field from dataclasses import asdict, dataclass, field
from hashlib import sha512 from hashlib import sha512
from pathlib import Path from pathlib import Path
@ -12,6 +10,7 @@ from dacite.core import from_dict
from django.db import DatabaseError, InternalError, ProgrammingError from django.db import DatabaseError, InternalError, ProgrammingError
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask, CurrentTaskNotFound from django_dramatiq_postgres.middleware import CurrentTask, CurrentTaskNotFound
from dramatiq.actor import actor from dramatiq.actor import actor
from dramatiq.middleware import Middleware from dramatiq.middleware import Middleware

View File

@ -1,10 +1,9 @@
"""authentik core tasks""" """authentik core tasks"""
from django.utils.translation import gettext_lazy as _
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from structlog.stdlib import get_logger from structlog.stdlib import get_logger

View File

@ -1,13 +1,12 @@
"""Crypto tasks""" """Crypto tasks"""
from django.utils.translation import gettext_lazy as _
from glob import glob from glob import glob
from pathlib import Path from pathlib import Path
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.serialization import load_pem_private_key from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography.x509.base import load_pem_x509_certificate from cryptography.x509.base import load_pem_x509_certificate
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from structlog.stdlib import get_logger from structlog.stdlib import get_logger

View File

@ -1,8 +1,8 @@
from django.db.models.aggregates import Count from django.db.models.aggregates import Count
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from structlog import get_logger from structlog import get_logger
from django.utils.translation import gettext_lazy as _
from authentik.enterprise.policies.unique_password.models import ( from authentik.enterprise.policies.unique_password.models import (
UniquePasswordPolicy, UniquePasswordPolicy,

View File

@ -7,7 +7,6 @@ from authentik.core.api.used_by import UsedByMixin
from authentik.enterprise.api import EnterpriseRequiredMixin from authentik.enterprise.api import EnterpriseRequiredMixin
from authentik.enterprise.providers.google_workspace.models import GoogleWorkspaceProvider from authentik.enterprise.providers.google_workspace.models import GoogleWorkspaceProvider
from authentik.enterprise.providers.google_workspace.tasks import ( from authentik.enterprise.providers.google_workspace.tasks import (
google_workspace_sync,
google_workspace_sync_objects, google_workspace_sync_objects,
) )
from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin

View File

@ -1,10 +1,10 @@
"""Google Provider tasks""" """Google Provider tasks"""
from django.utils.translation import gettext_lazy as _
from dramatiq.actor import actor from dramatiq.actor import actor
from authentik.enterprise.providers.google_workspace.models import GoogleWorkspaceProvider from authentik.enterprise.providers.google_workspace.models import GoogleWorkspaceProvider
from authentik.lib.sync.outgoing.tasks import SyncTasks from authentik.lib.sync.outgoing.tasks import SyncTasks
from django.utils.translation import gettext_lazy as _
sync_tasks = SyncTasks(GoogleWorkspaceProvider) sync_tasks = SyncTasks(GoogleWorkspaceProvider)

View File

@ -7,7 +7,6 @@ from authentik.core.api.used_by import UsedByMixin
from authentik.enterprise.api import EnterpriseRequiredMixin from authentik.enterprise.api import EnterpriseRequiredMixin
from authentik.enterprise.providers.microsoft_entra.models import MicrosoftEntraProvider from authentik.enterprise.providers.microsoft_entra.models import MicrosoftEntraProvider
from authentik.enterprise.providers.microsoft_entra.tasks import ( from authentik.enterprise.providers.microsoft_entra.tasks import (
microsoft_entra_sync,
microsoft_entra_sync_objects, microsoft_entra_sync_objects,
) )
from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin

View File

@ -1,10 +1,10 @@
"""Microsoft Entra Provider tasks""" """Microsoft Entra Provider tasks"""
from django.utils.translation import gettext_lazy as _
from dramatiq.actor import actor from dramatiq.actor import actor
from authentik.enterprise.providers.microsoft_entra.models import MicrosoftEntraProvider from authentik.enterprise.providers.microsoft_entra.models import MicrosoftEntraProvider
from authentik.lib.sync.outgoing.tasks import SyncTasks from authentik.lib.sync.outgoing.tasks import SyncTasks
from django.utils.translation import gettext_lazy as _
sync_tasks = SyncTasks(MicrosoftEntraProvider) sync_tasks = SyncTasks(MicrosoftEntraProvider)

View File

@ -1,9 +1,9 @@
from typing import Any from typing import Any
from django.utils.translation import gettext_lazy as _
from uuid import UUID from uuid import UUID
from django.http import HttpRequest from django.http import HttpRequest
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from requests.exceptions import RequestException from requests.exceptions import RequestException
@ -17,7 +17,6 @@ from authentik.enterprise.providers.ssf.models import (
Stream, Stream,
StreamEvent, StreamEvent,
) )
from authentik.events.logs import LogEvent
from authentik.lib.utils.http import get_http_session from authentik.lib.utils.http import get_http_session
from authentik.lib.utils.time import timedelta_from_string from authentik.lib.utils.time import timedelta_from_string
from authentik.policies.engine import PolicyEngine from authentik.policies.engine import PolicyEngine

View File

@ -1,7 +1,6 @@
"""Enterprise tasks""" """Enterprise tasks"""
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from dramatiq.actor import actor from dramatiq.actor import actor
from authentik.enterprise.license import LicenseKey from authentik.enterprise.license import LicenseKey

View File

@ -12,7 +12,7 @@ from rest_framework.request import Request
from authentik.core.models import AuthenticatedSession, User from authentik.core.models import AuthenticatedSession, User
from authentik.core.signals import login_failed, password_changed from authentik.core.signals import login_failed, password_changed
from authentik.events.models import Event, EventAction, NotificationRule from authentik.events.models import Event, EventAction
from authentik.flows.models import Stage from authentik.flows.models import Stage
from authentik.flows.planner import PLAN_CONTEXT_OUTPOST, PLAN_CONTEXT_SOURCE, FlowPlan from authentik.flows.planner import PLAN_CONTEXT_OUTPOST, PLAN_CONTEXT_SOURCE, FlowPlan
from authentik.flows.views.executor import SESSION_KEY_PLAN from authentik.flows.views.executor import SESSION_KEY_PLAN

View File

@ -2,8 +2,8 @@
from uuid import UUID from uuid import UUID
from django.utils.translation import gettext_lazy as _
from django.db.models.query_utils import Q from django.db.models.query_utils import Q
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from guardian.shortcuts import get_anonymous_user from guardian.shortcuts import get_anonymous_user

View File

@ -11,7 +11,6 @@ from authentik.core.models import Group, User
from authentik.lib.sync.outgoing import PAGE_SIZE, PAGE_TIMEOUT_MS from authentik.lib.sync.outgoing import PAGE_SIZE, PAGE_TIMEOUT_MS
from authentik.lib.sync.outgoing.base import BaseOutgoingSyncClient from authentik.lib.sync.outgoing.base import BaseOutgoingSyncClient
from authentik.lib.utils.time import fqdn_rand from authentik.lib.utils.time import fqdn_rand
from authentik.tasks.models import TasksModel
from authentik.tasks.schedules.lib import ScheduleSpec from authentik.tasks.schedules.lib import ScheduleSpec
from authentik.tasks.schedules.models import ScheduledModel from authentik.tasks.schedules.models import ScheduledModel

View File

@ -1,5 +1,4 @@
from django.db.models import Model from django.db.models import Model
from django.db.models.query import Q
from django.db.models.signals import m2m_changed, post_save, pre_delete from django.db.models.signals import m2m_changed, post_save, pre_delete
from dramatiq.actor import Actor from dramatiq.actor import Actor

View File

@ -1,7 +1,5 @@
"""outpost tasks""" """outpost tasks"""
from django.utils.translation import gettext_lazy as _
from hashlib import sha256 from hashlib import sha256
from os import R_OK, access from os import R_OK, access
from pathlib import Path from pathlib import Path
@ -14,6 +12,7 @@ from channels.layers import get_channel_layer
from django.core.cache import cache from django.core.cache import cache
from django.db.models.base import Model from django.db.models.base import Model
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from docker.constants import DEFAULT_UNIX_SOCKET from docker.constants import DEFAULT_UNIX_SOCKET
from dramatiq.actor import actor from dramatiq.actor import actor

View File

@ -2,12 +2,12 @@
from asgiref.sync import async_to_sync from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer from channels.layers import get_channel_layer
from django.utils.translation import gettext_lazy as _
from dramatiq.actor import actor from dramatiq.actor import actor
from authentik.outposts.consumer import OUTPOST_GROUP from authentik.outposts.consumer import OUTPOST_GROUP
from authentik.outposts.models import Outpost, OutpostType from authentik.outposts.models import Outpost, OutpostType
from authentik.providers.oauth2.id_token import hash_session_key from authentik.providers.oauth2.id_token import hash_session_key
from django.utils.translation import gettext_lazy as _
@actor(description=_("Terminate session on Proxy outpost.")) @actor(description=_("Terminate session on Proxy outpost."))

View File

@ -6,7 +6,7 @@ from authentik.core.api.providers import ProviderSerializer
from authentik.core.api.used_by import UsedByMixin from authentik.core.api.used_by import UsedByMixin
from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin
from authentik.providers.scim.models import SCIMProvider from authentik.providers.scim.models import SCIMProvider
from authentik.providers.scim.tasks import scim_sync, scim_sync_objects from authentik.providers.scim.tasks import scim_sync_objects
class SCIMProviderSerializer(ProviderSerializer): class SCIMProviderSerializer(ProviderSerializer):

View File

@ -1,10 +1,10 @@
"""SCIM Provider tasks""" """SCIM Provider tasks"""
from django.utils.translation import gettext_lazy as _
from dramatiq.actor import actor from dramatiq.actor import actor
from authentik.lib.sync.outgoing.tasks import SyncTasks from authentik.lib.sync.outgoing.tasks import SyncTasks
from authentik.providers.scim.models import SCIMProvider from authentik.providers.scim.models import SCIMProvider
from django.utils.translation import gettext_lazy as _
sync_tasks = SyncTasks(SCIMProvider) sync_tasks = SyncTasks(SCIMProvider)

View File

@ -1,12 +1,11 @@
"""Source API Views""" """Source API Views"""
from django.core.cache import cache from django.core.cache import cache
from rest_framework.fields import BooleanField, SerializerMethodField from rest_framework.fields import SerializerMethodField
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ModelViewSet
from authentik.core.api.sources import SourceSerializer from authentik.core.api.sources import SourceSerializer
from authentik.core.api.used_by import UsedByMixin from authentik.core.api.used_by import UsedByMixin
from authentik.core.api.utils import PassiveSerializer
from authentik.sources.kerberos.models import KerberosSource from authentik.sources.kerberos.models import KerberosSource
from authentik.sources.kerberos.tasks import CACHE_KEY_STATUS from authentik.sources.kerberos.tasks import CACHE_KEY_STATUS

View File

@ -1,6 +1,5 @@
"""authentik kerberos source signals""" """authentik kerberos source signals"""
from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from kadmin.exceptions import PyKAdminException from kadmin.exceptions import PyKAdminException
from rest_framework.serializers import ValidationError from rest_framework.serializers import ValidationError

View File

@ -1,11 +1,11 @@
"""Kerberos Sync tasks""" """Kerberos Sync tasks"""
from django.core.cache import cache from django.core.cache import cache
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
from django.utils.translation import gettext_lazy as _
from authentik.lib.config import CONFIG from authentik.lib.config import CONFIG
from authentik.lib.sync.outgoing.exceptions import StopSync from authentik.lib.sync.outgoing.exceptions import StopSync
from authentik.lib.utils.errors import exception_to_string from authentik.lib.utils.errors import exception_to_string

View File

@ -3,13 +3,13 @@
from uuid import uuid4 from uuid import uuid4
from django.core.cache import cache from django.core.cache import cache
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from dramatiq.composition import group from dramatiq.composition import group
from dramatiq.message import Message from dramatiq.message import Message
from ldap3.core.exceptions import LDAPException from ldap3.core.exceptions import LDAPException
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
from django.utils.translation import gettext_lazy as _
from authentik.lib.config import CONFIG from authentik.lib.config import CONFIG
from authentik.lib.sync.outgoing.exceptions import StopSync from authentik.lib.sync.outgoing.exceptions import StopSync

View File

@ -2,11 +2,11 @@
from json import dumps from json import dumps
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from requests import RequestException from requests import RequestException
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
from django.utils.translation import gettext_lazy as _
from authentik.lib.utils.http import get_http_session from authentik.lib.utils.http import get_http_session
from authentik.sources.oauth.models import OAuthSource from authentik.sources.oauth.models import OAuthSource

View File

@ -1,5 +1,6 @@
"""Plex tasks""" """Plex tasks"""
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from requests import RequestException from requests import RequestException
@ -9,7 +10,6 @@ from authentik.lib.utils.errors import exception_to_string
from authentik.sources.plex.models import PlexSource from authentik.sources.plex.models import PlexSource
from authentik.sources.plex.plex import PlexAuth from authentik.sources.plex.plex import PlexAuth
from authentik.tasks.models import Task from authentik.tasks.models import Task
from django.utils.translation import gettext_lazy as _
@actor(description=_("Check the validity of a Plex source.")) @actor(description=_("Check the validity of a Plex source."))

View File

@ -6,10 +6,10 @@ from pathlib import Path
from django.core.cache import cache from django.core.cache import cache
from django.db.transaction import atomic from django.db.transaction import atomic
from django.utils.translation import gettext_lazy as _
from django_dramatiq_postgres.middleware import CurrentTask from django_dramatiq_postgres.middleware import CurrentTask
from dramatiq.actor import actor from dramatiq.actor import actor
from fido2.mds3 import filter_revoked, parse_blob from fido2.mds3 import filter_revoked, parse_blob
from django.utils.translation import gettext_lazy as _
from authentik.stages.authenticator_webauthn.models import ( from authentik.stages.authenticator_webauthn.models import (
UNKNOWN_DEVICE_TYPE_AAGUID, UNKNOWN_DEVICE_TYPE_AAGUID,

View File

@ -22,7 +22,6 @@ from authentik.core.api.utils import ModelSerializer
from authentik.rbac.decorators import permission_required from authentik.rbac.decorators import permission_required
from authentik.tasks.schedules.models import Schedule from authentik.tasks.schedules.models import Schedule
LOGGER = get_logger() LOGGER = get_logger()

View File

@ -1,7 +1,5 @@
from time import sleep
import pglock import pglock
from django_dramatiq_postgres.conf import Conf
from django_dramatiq_postgres.scheduler import Scheduler as SchedulerBase from django_dramatiq_postgres.scheduler import Scheduler as SchedulerBase
from structlog.stdlib import get_logger from structlog.stdlib import get_logger

View File

@ -1,13 +1,10 @@
import contextvars import contextvars
from threading import Event from typing import Any
from typing import Any, override
from django.core.exceptions import ImproperlyConfigured
from django.db import ( from django.db import (
close_old_connections, close_old_connections,
connections, connections,
) )
from django.utils.module_loading import import_string
from dramatiq.actor import Actor from dramatiq.actor import Actor
from dramatiq.broker import Broker from dramatiq.broker import Broker
from dramatiq.logging import get_logger from dramatiq.logging import get_logger
@ -16,7 +13,6 @@ from dramatiq.middleware.middleware import Middleware
from django_dramatiq_postgres.conf import Conf from django_dramatiq_postgres.conf import Conf
from django_dramatiq_postgres.models import TaskBase from django_dramatiq_postgres.models import TaskBase
from django_dramatiq_postgres.scheduler import Scheduler
class DbConnectionMiddleware(Middleware): class DbConnectionMiddleware(Middleware):

View File

@ -1,5 +1,3 @@
from threading import Event, Thread
from time import sleep
import pglock import pglock
from django.db import router, transaction from django.db import router, transaction