diff --git a/authentik/lib/sync/outgoing/api.py b/authentik/lib/sync/outgoing/api.py index 448dc2aa22..1809424bd0 100644 --- a/authentik/lib/sync/outgoing/api.py +++ b/authentik/lib/sync/outgoing/api.py @@ -14,12 +14,6 @@ from authentik.rbac.filters import ObjectFilter from authentik.tasks.models import Task -class SyncStatusSerializer(PassiveSerializer): - """Provider sync status""" - - is_running = BooleanField(read_only=True) - - class SyncObjectSerializer(PassiveSerializer): """Sync object serializer""" diff --git a/authentik/sources/kerberos/api/source.py b/authentik/sources/kerberos/api/source.py index 49fc7c0bf6..3105804fb8 100644 --- a/authentik/sources/kerberos/api/source.py +++ b/authentik/sources/kerberos/api/source.py @@ -1,11 +1,7 @@ """Source API Views""" from django.core.cache import cache -from drf_spectacular.utils import extend_schema -from rest_framework.decorators import action from rest_framework.fields import BooleanField, SerializerMethodField -from rest_framework.request import Request -from rest_framework.response import Response from rest_framework.viewsets import ModelViewSet from authentik.core.api.sources import SourceSerializer @@ -50,12 +46,6 @@ class KerberosSourceSerializer(SourceSerializer): } -class KerberosSyncStatusSerializer(PassiveSerializer): - """Kerberos Source sync status""" - - is_running = BooleanField(read_only=True) - - class KerberosSourceViewSet(UsedByMixin, ModelViewSet): """Kerberos Source Viewset""" @@ -84,20 +74,3 @@ class KerberosSourceViewSet(UsedByMixin, ModelViewSet): "spnego_server_name", ] ordering = ["name"] - - @extend_schema(responses={200: KerberosSyncStatusSerializer()}) - @action( - methods=["GET"], - detail=True, - pagination_class=None, - url_path="sync/status", - filter_backends=[], - ) - def sync_status(self, request: Request, slug: str) -> Response: - """Get source's sync status""" - source: KerberosSource = self.get_object() - with source.sync_lock as lock_acquired: - status = { - "is_running": not lock_acquired, - } - return Response(KerberosSyncStatusSerializer(status).data) diff --git a/authentik/sources/ldap/api.py b/authentik/sources/ldap/api.py index 691317386d..bdacad1215 100644 --- a/authentik/sources/ldap/api.py +++ b/authentik/sources/ldap/api.py @@ -23,7 +23,6 @@ from authentik.core.api.sources import ( ) from authentik.core.api.used_by import UsedByMixin from authentik.crypto.models import CertificateKeyPair -from authentik.lib.sync.outgoing.api import SyncStatusSerializer from authentik.sources.ldap.models import ( GroupLDAPSourceConnection, LDAPSource, @@ -154,28 +153,6 @@ class LDAPSourceViewSet(UsedByMixin, ModelViewSet): search_fields = ["name", "slug"] ordering = ["name"] - @extend_schema( - responses={ - 200: SyncStatusSerializer(), - } - ) - @action( - methods=["GET"], - detail=True, - pagination_class=None, - url_path="sync/status", - filter_backends=[], - ) - def sync_status(self, request: Request, slug: str) -> Response: - """Get source's sync status""" - source: LDAPSource = self.get_object() - with source.sync_lock as lock_acquired: - status = { - # If we could not acquire the lock, it means a task is using it, and thus is running - "is_running": not lock_acquired, - } - return Response(SyncStatusSerializer(status).data) - @extend_schema( responses={ 200: inline_serializer( diff --git a/schema.yml b/schema.yml index 78e1741452..f2aa42036c 100644 --- a/schema.yml +++ b/schema.yml @@ -19451,40 +19451,6 @@ paths: schema: $ref: '#/components/schemas/GenericError' description: '' - /providers/google_workspace/{id}/sync/status/: - get: - operationId: providers_google_workspace_sync_status_retrieve - description: Get provider's sync status - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this Google Workspace Provider. - required: true - tags: - - providers - security: - - authentik: [] - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/SyncStatus' - description: '' - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/ValidationError' - description: '' - '403': - content: - application/json: - schema: - $ref: '#/components/schemas/GenericError' - description: '' /providers/google_workspace/{id}/used_by/: get: operationId: providers_google_workspace_used_by_list @@ -20492,40 +20458,6 @@ paths: schema: $ref: '#/components/schemas/GenericError' description: '' - /providers/microsoft_entra/{id}/sync/status/: - get: - operationId: providers_microsoft_entra_sync_status_retrieve - description: Get provider's sync status - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this Microsoft Entra Provider. - required: true - tags: - - providers - security: - - authentik: [] - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/SyncStatus' - description: '' - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/ValidationError' - description: '' - '403': - content: - application/json: - schema: - $ref: '#/components/schemas/GenericError' - description: '' /providers/microsoft_entra/{id}/used_by/: get: operationId: providers_microsoft_entra_used_by_list @@ -23025,40 +22957,6 @@ paths: schema: $ref: '#/components/schemas/GenericError' description: '' - /providers/scim/{id}/sync/status/: - get: - operationId: providers_scim_sync_status_retrieve - description: Get provider's sync status - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this SCIM Provider. - required: true - tags: - - providers - security: - - authentik: [] - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/SyncStatus' - description: '' - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/ValidationError' - description: '' - '403': - content: - application/json: - schema: - $ref: '#/components/schemas/GenericError' - description: '' /providers/scim/{id}/used_by/: get: operationId: providers_scim_used_by_list @@ -28147,40 +28045,6 @@ paths: schema: $ref: '#/components/schemas/GenericError' description: '' - /sources/kerberos/{slug}/sync/status/: - get: - operationId: sources_kerberos_sync_status_retrieve - description: Get source's sync status - parameters: - - in: path - name: slug - schema: - type: string - description: Internal source name, used in URLs. - required: true - tags: - - sources - security: - - authentik: [] - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/KerberosSyncStatus' - description: '' - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/ValidationError' - description: '' - '403': - content: - application/json: - schema: - $ref: '#/components/schemas/GenericError' - description: '' /sources/kerberos/{slug}/used_by/: get: operationId: sources_kerberos_used_by_list @@ -28597,40 +28461,6 @@ paths: schema: $ref: '#/components/schemas/GenericError' description: '' - /sources/ldap/{slug}/sync/status/: - get: - operationId: sources_ldap_sync_status_retrieve - description: Get source's sync status - parameters: - - in: path - name: slug - schema: - type: string - description: Internal source name, used in URLs. - required: true - tags: - - sources - security: - - authentik: [] - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/SyncStatus' - description: '' - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/ValidationError' - description: '' - '403': - content: - application/json: - schema: - $ref: '#/components/schemas/GenericError' - description: '' /sources/ldap/{slug}/used_by/: get: operationId: sources_ldap_used_by_list @@ -47577,15 +47407,6 @@ components: - name - realm - slug - KerberosSyncStatus: - type: object - description: Kerberos Source sync status - properties: - is_running: - type: boolean - readOnly: true - required: - - is_running KubernetesServiceConnection: type: object description: KubernetesServiceConnection Serializer @@ -60242,15 +60063,6 @@ components: readOnly: true required: - messages - SyncStatus: - type: object - description: Provider sync status - properties: - is_running: - type: boolean - readOnly: true - required: - - is_running SystemInfo: type: object description: Get system information. diff --git a/web/src/elements/sync/SyncStatusCard.stories.ts b/web/src/elements/sync/SyncStatusCard.stories.ts deleted file mode 100644 index acd00c3800..0000000000 --- a/web/src/elements/sync/SyncStatusCard.stories.ts +++ /dev/null @@ -1,157 +0,0 @@ -import type { Meta, StoryObj } from "@storybook/web-components"; - -import { html } from "lit"; - -import { LogLevelEnum, SyncStatus, SystemTaskStatusEnum } from "@goauthentik/api"; - -import "./SyncStatusCard"; - -const metadata: Meta = { - title: "Elements/", - component: "ak-sync-status-card", -}; - -export default metadata; - -export const Running: StoryObj = { - args: { - status: { - isRunning: true, - tasks: [], - } as SyncStatus, - }, - // @ts-ignore - render: ({ status }: SyncStatus) => { - return html`
- { - return status; - }} - > -
`; - }, -}; - -export const SingleTask: StoryObj = { - args: { - status: { - isRunning: false, - tasks: [ - { - uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b", - name: "Single task", - fullName: "foo:bar:baz", - status: SystemTaskStatusEnum.Successful, - messages: [ - { - logger: "foo", - event: "bar", - attributes: { - foo: "bar", - }, - timestamp: new Date(), - logLevel: LogLevelEnum.Info, - }, - ], - description: "foo", - startTimestamp: new Date(), - finishTimestamp: new Date(), - duration: 0, - }, - ], - } as SyncStatus, - }, - // @ts-ignore - render: ({ status }: SyncStatus) => { - return html`
- { - return status; - }} - > -
`; - }, -}; - -export const MultipleTasks: StoryObj = { - args: { - status: { - isRunning: false, - tasks: [ - { - uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b", - name: "Single task", - fullName: "foo:bar:baz", - status: SystemTaskStatusEnum.Successful, - messages: [ - { - logger: "foo", - event: "bar", - attributes: { - foo: "bar", - }, - timestamp: new Date(), - logLevel: LogLevelEnum.Info, - }, - ], - description: "foo", - startTimestamp: new Date(), - finishTimestamp: new Date(), - duration: 0, - }, - { - uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b", - name: "Single task", - fullName: "foo:bar:baz", - status: SystemTaskStatusEnum.Successful, - messages: [ - { - logger: "foo", - event: "bar", - attributes: { - foo: "bar", - }, - timestamp: new Date(), - logLevel: LogLevelEnum.Info, - }, - ], - description: "foo", - startTimestamp: new Date(), - finishTimestamp: new Date(), - duration: 0, - }, - { - uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b", - name: "Single task", - fullName: "foo:bar:baz", - status: SystemTaskStatusEnum.Successful, - messages: [ - { - logger: "foo", - event: "bar", - attributes: { - foo: "bar", - }, - timestamp: new Date(), - logLevel: LogLevelEnum.Info, - }, - ], - description: "foo", - startTimestamp: new Date(), - finishTimestamp: new Date(), - duration: 0, - }, - ], - } as SyncStatus, - }, - // @ts-ignore - render: ({ status }: SyncStatus) => { - return html`
- { - return status; - }} - > -
`; - }, -}; diff --git a/web/src/elements/sync/SyncStatusCard.ts b/web/src/elements/sync/SyncStatusCard.ts deleted file mode 100644 index f926738728..0000000000 --- a/web/src/elements/sync/SyncStatusCard.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { EVENT_REFRESH } from "@goauthentik/common/constants"; -import "@goauthentik/components/ak-status-label"; -import { AKElement } from "@goauthentik/elements/Base"; -import "@goauthentik/elements/EmptyState"; -import "@goauthentik/elements/buttons/ActionButton"; -import "@goauthentik/elements/events/LogViewer"; - -import { msg } from "@lit/localize"; -import { CSSResult, TemplateResult, html } from "lit"; -import { customElement, property, state } from "lit/decorators.js"; - -import PFButton from "@patternfly/patternfly/components/Button/button.css"; -import PFCard from "@patternfly/patternfly/components/Card/card.css"; -import PFTable from "@patternfly/patternfly/components/Table/table.css"; -import PFBase from "@patternfly/patternfly/patternfly-base.css"; - -import { SyncStatus } from "@goauthentik/api"; - -@customElement("ak-sync-status-card") -export class SyncStatusCard extends AKElement { - @state() - syncState?: SyncStatus; - - @state() - loading = false; - - @property({ attribute: false }) - fetch!: () => Promise; - - @property({ attribute: false }) - triggerSync!: () => Promise; - - static get styles(): CSSResult[] { - return [PFBase, PFButton, PFCard, PFTable]; - } - - firstUpdated() { - this.loading = true; - this.fetch().then((status) => { - this.syncState = status; - this.loading = false; - }); - } - - renderSyncStatus(): TemplateResult { - if (this.loading) { - return html``; - } - if (!this.syncState) { - return html`${msg("No sync status.")}`; - } - if (this.syncState.isRunning) { - return html`${msg("Sync currently running.")}`; - } - return html`${msg("No synchronization currently running.")}`; - } - - render(): TemplateResult { - return html`
-
-
- -
-
${msg("Sync status")}
-
-
${this.renderSyncStatus()}
- -
`; - } -} - -declare global { - interface HTMLElementTagNameMap { - "ak-sync-status-card": SyncStatusCard; - } -}