@ -1,7 +1,5 @@
 | 
			
		||||
"""v1 blueprints tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from dataclasses import asdict, dataclass, field
 | 
			
		||||
from hashlib import sha512
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
@ -12,6 +10,7 @@ from dacite.core import from_dict
 | 
			
		||||
from django.db import DatabaseError, InternalError, ProgrammingError
 | 
			
		||||
from django.utils.text import slugify
 | 
			
		||||
from django.utils.timezone import now
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask, CurrentTaskNotFound
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from dramatiq.middleware import Middleware
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,9 @@
 | 
			
		||||
"""authentik core tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from datetime import datetime, timedelta
 | 
			
		||||
 | 
			
		||||
from django.utils.timezone import now
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,12 @@
 | 
			
		||||
"""Crypto tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from glob import glob
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
from cryptography.hazmat.backends import default_backend
 | 
			
		||||
from cryptography.hazmat.primitives.serialization import load_pem_private_key
 | 
			
		||||
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 dramatiq.actor import actor
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
from django.db.models.aggregates import Count
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from structlog import get_logger
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from authentik.enterprise.policies.unique_password.models import (
 | 
			
		||||
    UniquePasswordPolicy,
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,6 @@ from authentik.core.api.used_by import UsedByMixin
 | 
			
		||||
from authentik.enterprise.api import EnterpriseRequiredMixin
 | 
			
		||||
from authentik.enterprise.providers.google_workspace.models import GoogleWorkspaceProvider
 | 
			
		||||
from authentik.enterprise.providers.google_workspace.tasks import (
 | 
			
		||||
    google_workspace_sync,
 | 
			
		||||
    google_workspace_sync_objects,
 | 
			
		||||
)
 | 
			
		||||
from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
"""Google Provider tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
 | 
			
		||||
from authentik.enterprise.providers.google_workspace.models import GoogleWorkspaceProvider
 | 
			
		||||
from authentik.lib.sync.outgoing.tasks import SyncTasks
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
sync_tasks = SyncTasks(GoogleWorkspaceProvider)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,6 @@ from authentik.core.api.used_by import UsedByMixin
 | 
			
		||||
from authentik.enterprise.api import EnterpriseRequiredMixin
 | 
			
		||||
from authentik.enterprise.providers.microsoft_entra.models import MicrosoftEntraProvider
 | 
			
		||||
from authentik.enterprise.providers.microsoft_entra.tasks import (
 | 
			
		||||
    microsoft_entra_sync,
 | 
			
		||||
    microsoft_entra_sync_objects,
 | 
			
		||||
)
 | 
			
		||||
from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
"""Microsoft Entra Provider tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
 | 
			
		||||
from authentik.enterprise.providers.microsoft_entra.models import MicrosoftEntraProvider
 | 
			
		||||
from authentik.lib.sync.outgoing.tasks import SyncTasks
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
sync_tasks = SyncTasks(MicrosoftEntraProvider)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
from typing import Any
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from uuid import UUID
 | 
			
		||||
 | 
			
		||||
from django.http import HttpRequest
 | 
			
		||||
from django.utils.timezone import now
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from requests.exceptions import RequestException
 | 
			
		||||
@ -17,7 +17,6 @@ from authentik.enterprise.providers.ssf.models import (
 | 
			
		||||
    Stream,
 | 
			
		||||
    StreamEvent,
 | 
			
		||||
)
 | 
			
		||||
from authentik.events.logs import LogEvent
 | 
			
		||||
from authentik.lib.utils.http import get_http_session
 | 
			
		||||
from authentik.lib.utils.time import timedelta_from_string
 | 
			
		||||
from authentik.policies.engine import PolicyEngine
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,6 @@
 | 
			
		||||
"""Enterprise tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
 | 
			
		||||
from authentik.enterprise.license import LicenseKey
 | 
			
		||||
 | 
			
		||||
@ -12,7 +12,7 @@ from rest_framework.request import Request
 | 
			
		||||
 | 
			
		||||
from authentik.core.models import AuthenticatedSession, User
 | 
			
		||||
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.planner import PLAN_CONTEXT_OUTPOST, PLAN_CONTEXT_SOURCE, FlowPlan
 | 
			
		||||
from authentik.flows.views.executor import SESSION_KEY_PLAN
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,8 @@
 | 
			
		||||
 | 
			
		||||
from uuid import UUID
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.db.models.query_utils import Q
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from guardian.shortcuts import get_anonymous_user
 | 
			
		||||
 | 
			
		||||
@ -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.base import BaseOutgoingSyncClient
 | 
			
		||||
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.models import ScheduledModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
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 dramatiq.actor import Actor
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,5 @@
 | 
			
		||||
"""outpost tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from hashlib import sha256
 | 
			
		||||
from os import R_OK, access
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
@ -14,6 +12,7 @@ from channels.layers import get_channel_layer
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.db.models.base import Model
 | 
			
		||||
from django.utils.text import slugify
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from docker.constants import DEFAULT_UNIX_SOCKET
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
 | 
			
		||||
@ -2,12 +2,12 @@
 | 
			
		||||
 | 
			
		||||
from asgiref.sync import async_to_sync
 | 
			
		||||
from channels.layers import get_channel_layer
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
 | 
			
		||||
from authentik.outposts.consumer import OUTPOST_GROUP
 | 
			
		||||
from authentik.outposts.models import Outpost, OutpostType
 | 
			
		||||
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."))
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ from authentik.core.api.providers import ProviderSerializer
 | 
			
		||||
from authentik.core.api.used_by import UsedByMixin
 | 
			
		||||
from authentik.lib.sync.outgoing.api import OutgoingSyncProviderStatusMixin
 | 
			
		||||
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):
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
"""SCIM Provider tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
 | 
			
		||||
from authentik.lib.sync.outgoing.tasks import SyncTasks
 | 
			
		||||
from authentik.providers.scim.models import SCIMProvider
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
sync_tasks = SyncTasks(SCIMProvider)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,11 @@
 | 
			
		||||
"""Source API Views"""
 | 
			
		||||
 | 
			
		||||
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 authentik.core.api.sources import SourceSerializer
 | 
			
		||||
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.tasks import CACHE_KEY_STATUS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
"""authentik kerberos source signals"""
 | 
			
		||||
 | 
			
		||||
from django.db.models.signals import post_save
 | 
			
		||||
from django.dispatch import receiver
 | 
			
		||||
from kadmin.exceptions import PyKAdminException
 | 
			
		||||
from rest_framework.serializers import ValidationError
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,11 @@
 | 
			
		||||
"""Kerberos Sync tasks"""
 | 
			
		||||
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from authentik.lib.config import CONFIG
 | 
			
		||||
from authentik.lib.sync.outgoing.exceptions import StopSync
 | 
			
		||||
from authentik.lib.utils.errors import exception_to_string
 | 
			
		||||
 | 
			
		||||
@ -3,13 +3,13 @@
 | 
			
		||||
from uuid import uuid4
 | 
			
		||||
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from dramatiq.composition import group
 | 
			
		||||
from dramatiq.message import Message
 | 
			
		||||
from ldap3.core.exceptions import LDAPException
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from authentik.lib.config import CONFIG
 | 
			
		||||
from authentik.lib.sync.outgoing.exceptions import StopSync
 | 
			
		||||
 | 
			
		||||
@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
from json import dumps
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from requests import RequestException
 | 
			
		||||
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.sources.oauth.models import OAuthSource
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
"""Plex tasks"""
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
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.plex import PlexAuth
 | 
			
		||||
from authentik.tasks.models import Task
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@actor(description=_("Check the validity of a Plex source."))
 | 
			
		||||
 | 
			
		||||
@ -6,10 +6,10 @@ from pathlib import Path
 | 
			
		||||
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.db.transaction import atomic
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django_dramatiq_postgres.middleware import CurrentTask
 | 
			
		||||
from dramatiq.actor import actor
 | 
			
		||||
from fido2.mds3 import filter_revoked, parse_blob
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from authentik.stages.authenticator_webauthn.models import (
 | 
			
		||||
    UNKNOWN_DEVICE_TYPE_AAGUID,
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,6 @@ from authentik.core.api.utils import ModelSerializer
 | 
			
		||||
from authentik.rbac.decorators import permission_required
 | 
			
		||||
from authentik.tasks.schedules.models import Schedule
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
LOGGER = get_logger()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,5 @@
 | 
			
		||||
from time import sleep
 | 
			
		||||
 | 
			
		||||
import pglock
 | 
			
		||||
from django_dramatiq_postgres.conf import Conf
 | 
			
		||||
from django_dramatiq_postgres.scheduler import Scheduler as SchedulerBase
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,10 @@
 | 
			
		||||
import contextvars
 | 
			
		||||
from threading import Event
 | 
			
		||||
from typing import Any, override
 | 
			
		||||
from typing import Any
 | 
			
		||||
 | 
			
		||||
from django.core.exceptions import ImproperlyConfigured
 | 
			
		||||
from django.db import (
 | 
			
		||||
    close_old_connections,
 | 
			
		||||
    connections,
 | 
			
		||||
)
 | 
			
		||||
from django.utils.module_loading import import_string
 | 
			
		||||
from dramatiq.actor import Actor
 | 
			
		||||
from dramatiq.broker import Broker
 | 
			
		||||
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.models import TaskBase
 | 
			
		||||
from django_dramatiq_postgres.scheduler import Scheduler
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DbConnectionMiddleware(Middleware):
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
from threading import Event, Thread
 | 
			
		||||
from time import sleep
 | 
			
		||||
 | 
			
		||||
import pglock
 | 
			
		||||
from django.db import router, transaction
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user