diff --git a/app/Domain/Integrations/Controllers/IntegrationController.php b/app/Domain/Integrations/Controllers/IntegrationController.php index 360aa8207..104f97046 100644 --- a/app/Domain/Integrations/Controllers/IntegrationController.php +++ b/app/Domain/Integrations/Controllers/IntegrationController.php @@ -4,7 +4,6 @@ namespace App\Domain\Integrations\Controllers; -use App\Auth0\Repositories\Auth0ClientRepository; use App\Domain\Auth\CurrentUser; use App\Domain\Contacts\ContactType; use App\Domain\Contacts\Repositories\ContactKeyVisibilityRepository; @@ -73,7 +72,6 @@ public function __construct( private readonly OrganizationRepository $organizationRepository, private readonly UdbOrganizerRepository $organizerRepository, private readonly CouponRepository $couponRepository, - private readonly Auth0ClientRepository $auth0ClientRepository, private readonly UiTiDv1ConsumerRepository $uitidV1ConsumerRepository, private readonly KeycloakClientRepository $keycloakClientRepository, private readonly KeyVisibilityUpgradeRepository $keyVisibilityUpgradeRepository, @@ -93,16 +91,14 @@ public function index(Request $request): Response $integrationIds = array_map(fn ($integration) => $integration->id, $integrationsData->collection->toArray()); - $auth0Clients = $this->auth0ClientRepository->getByIntegrationIds($integrationIds); $uitidV1Consumers = $this->uitidV1ConsumerRepository->getByIntegrationIds($integrationIds); $keycloakClients = $this->keycloakClientRepository->getByIntegrationIds($integrationIds); return Inertia::render('Integrations/Index', [ 'integrations' => $integrationsData->collection->map(fn (Integration $integration) => $integration->toArray()), 'credentials' => [ - 'auth0' => $auth0Clients, - 'uitidV1' => $uitidV1Consumers, - 'keycloak' => $keycloakClients, + 'legacyConsumers' => $uitidV1Consumers, + 'clients' => $keycloakClients, ], 'paginationInfo' => $integrationsData->paginationInfo, ]); diff --git a/app/Domain/Integrations/Integration.php b/app/Domain/Integrations/Integration.php index 1fef8c070..8c92de4f6 100644 --- a/app/Domain/Integrations/Integration.php +++ b/app/Domain/Integrations/Integration.php @@ -258,7 +258,7 @@ public function toArray(): array 'urls' => $this->urls, 'organization' => $this->organization, 'organizers' => $this->udbOrganizers, - 'authClients' => $this->auth0Clients, + 'authClients' => $this->keycloakClients, 'legacyAuthConsumers' => $this->uiTiDv1Consumers, 'keycloakClients' => $this->keycloakClients, 'subscription' => $this->subscription, diff --git a/resources/ts/Components/IntegrationCard.tsx b/resources/ts/Components/IntegrationCard.tsx index f8cd5fe32..f1b266b1f 100644 --- a/resources/ts/Components/IntegrationCard.tsx +++ b/resources/ts/Components/IntegrationCard.tsx @@ -24,11 +24,6 @@ import { usePolling } from "../hooks/usePolling"; import { ButtonSecondary } from "./ButtonSecondary"; import { IntegrationClientCredentials } from "./IntegrationClientCredential"; -type Props = Integration & - Credentials & { - onEdit: (id: string) => void; - }; - const productTypeToPath = { uitpas: "/uitpas/getting-started", "entry-api": "/uitdatabank/entry-api/introduction", @@ -59,6 +54,11 @@ export const OpenWidgetBuilderButton = ({ ); }; +type Props = Integration & + Credentials & { + onEdit: (id: string) => void; + }; + export const IntegrationCard = ({ id, name, @@ -68,8 +68,6 @@ export const IntegrationCard = ({ legacyProdConsumer, testClient, prodClient, - keycloakTestClient, - keycloakProdClient, keyVisibility, onEdit, }: Props) => { @@ -82,8 +80,6 @@ export const IntegrationCard = ({ legacyProdConsumer, testClient, prodClient, - keycloakTestClient, - keycloakProdClient, ].some(Boolean); usePolling(!hasAnyCredentials, { only: ["credentials"] }); @@ -105,7 +101,6 @@ export const IntegrationCard = ({
{ export const IntegrationClientCredentials = ({ client, - keycloakClient, status, type, isLive, }: Pick & { client: AuthClient | undefined; - keycloakClient?: KeycloakClient; isLive: boolean; }) => { const { t } = useTranslation(); - const { config } = usePageProps(); - const clientToShow = - config.keycloak.creationEnabled && keycloakClient ? keycloakClient : client; const clientWithLabels = [ { label: "details.credentials.client_id", - value: clientToShow?.clientId, + value: client?.clientId, }, { label: "details.credentials.client_secret", - value: clientToShow?.clientSecret, + value: client?.clientSecret, }, ]; diff --git a/resources/ts/Components/Integrations/Detail/Credentials.tsx b/resources/ts/Components/Integrations/Detail/Credentials.tsx index 42a9a8c63..31002a254 100644 --- a/resources/ts/Components/Integrations/Detail/Credentials.tsx +++ b/resources/ts/Components/Integrations/Detail/Credentials.tsx @@ -5,7 +5,6 @@ import { IntegrationType } from "../../../types/IntegrationType"; import { CredentialsWidgets } from "./CredentialsWidgets"; import type { AuthClient, - KeycloakClient, LegacyAuthConsumer, } from "../../../types/Credentials"; import type { Integration } from "../../../types/Integration"; @@ -14,9 +13,7 @@ import { useTranslation } from "react-i18next"; import { usePolling } from "../../../hooks/usePolling"; import { KeyVisibility } from "../../../types/KeyVisibility"; import { UiTiDv1Environment } from "../../../types/UiTiDv1Environment"; -import { Auth0Tenant } from "../../../types/Auth0Tenant"; import { KeycloakEnvironment } from "../../../types/KeycloakEnvironment"; -import { usePageProps } from "../../../hooks/usePageProps"; type Props = Integration & { email: string; @@ -28,8 +25,6 @@ export type Credentials = { prodClient?: AuthClient; legacyTestConsumer?: LegacyAuthConsumer; legacyProdConsumer?: LegacyAuthConsumer; - keycloakTestClient?: KeycloakClient; - keycloakProdClient?: KeycloakClient; }; export const Credentials = ({ @@ -42,30 +37,10 @@ export const Credentials = ({ keyVisibilityUpgrade, legacyAuthConsumers, authClients, - keycloakClients, oldCredentialsExpirationDate, }: Props) => { const { t } = useTranslation(); - const { config } = usePageProps(); - const hasCredentials = useMemo(() => { - if (keyVisibility === KeyVisibility.v1 && !keyVisibilityUpgrade) { - return legacyAuthConsumers.length > 0; - } - - const credentials: unknown[][] = [legacyAuthConsumers]; - - if (config.keycloak.enabled) { - credentials.push(keycloakClients); - } - - return credentials.every((it) => it.length > 0); - }, [ - config.keycloak.enabled, - keyVisibility, - keyVisibilityUpgrade, - keycloakClients, - legacyAuthConsumers, - ]); + const hasCredentials = legacyAuthConsumers.length > 0; const isV1Upgraded = keyVisibility === KeyVisibility.v1 && !!keyVisibilityUpgrade; @@ -79,19 +54,13 @@ export const Credentials = ({ (consumer) => consumer.environment === UiTiDv1Environment.Production ), testClient: authClients.find( - (client) => client.tenant === Auth0Tenant.Testing - ), - prodClient: authClients.find( - (client) => client.tenant === Auth0Tenant.Production - ), - keycloakTestClient: keycloakClients.find( (client) => client.environment === KeycloakEnvironment.Testing ), - keycloakProdClient: keycloakClients.find( + prodClient: authClients.find( (client) => client.environment === KeycloakEnvironment.Production ), }), - [legacyAuthConsumers, authClients, keycloakClients] + [legacyAuthConsumers, authClients] ); if (!hasCredentials) { diff --git a/resources/ts/Components/Integrations/Detail/CredentialsAuthClients.tsx b/resources/ts/Components/Integrations/Detail/CredentialsAuthClients.tsx index e01e6641c..4ec27a6ac 100644 --- a/resources/ts/Components/Integrations/Detail/CredentialsAuthClients.tsx +++ b/resources/ts/Components/Integrations/Detail/CredentialsAuthClients.tsx @@ -27,8 +27,6 @@ type Props = Pick< export const CredentialsAuthClients = ({ testClient, prodClient, - keycloakTestClient, - keycloakProdClient, id, status, email, @@ -84,7 +82,6 @@ export const CredentialsAuthClients = ({ { integrations.map((integration) => ({ ...integration, credentials: { - testClient: credentials.auth0.find( + testClient: credentials.clients.find( (client) => client.integrationId === integration.id && - client.tenant === Auth0Tenant.Testing + client.environment === KeycloakEnvironment.Testing ), - prodClient: credentials.auth0.find( + prodClient: credentials.clients.find( (client) => client.integrationId === integration.id && - client.tenant === Auth0Tenant.Production + client.environment === KeycloakEnvironment.Production ), - legacyTestConsumer: credentials.uitidV1.find( + legacyTestConsumer: credentials.legacyConsumers.find( (client) => client.integrationId === integration.id && client.environment === UiTiDv1Environment.Testing ), - legacyProdConsumer: credentials.uitidV1.find( + legacyProdConsumer: credentials.legacyConsumers.find( (client) => client.integrationId === integration.id && client.environment === UiTiDv1Environment.Production ), - keycloakTestClient: credentials.keycloak.find( - (client) => - client.integrationId === integration.id && - client.environment === KeycloakEnvironment.Testing - ), - keycloakProdClient: credentials.keycloak.find( - (client) => - client.integrationId === integration.id && - client.environment === KeycloakEnvironment.Production - ), }, })), - [integrations, credentials.auth0, credentials.uitidV1, credentials.keycloak] + [integrations, credentials.legacyConsumers, credentials.clients] ); const handleDeleteIntegration = () => { diff --git a/resources/ts/Pages/Integrations/New.tsx b/resources/ts/Pages/Integrations/New.tsx index 2067dfe8c..5b2b9e30c 100644 --- a/resources/ts/Pages/Integrations/New.tsx +++ b/resources/ts/Pages/Integrations/New.tsx @@ -1,5 +1,4 @@ -import type { FormEvent } from "react"; -import { useEffect } from "react"; +import { type FormEvent, useEffect } from "react"; import React, { useState } from "react"; import { useForm } from "@inertiajs/react"; import { Heading } from "../../Components/Heading"; diff --git a/resources/ts/types/Auth0Tenant.ts b/resources/ts/types/Auth0Tenant.ts deleted file mode 100644 index 711a121b8..000000000 --- a/resources/ts/types/Auth0Tenant.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Values } from "./Values"; - -export const Auth0Tenant = { - Acceptance: "acc", - Testing: "test", - Production: "prod", -} as const; - -export type Auth0Tenant = Values; diff --git a/resources/ts/types/Credentials.ts b/resources/ts/types/Credentials.ts index 1483b3d49..3f8947fb0 100644 --- a/resources/ts/types/Credentials.ts +++ b/resources/ts/types/Credentials.ts @@ -1,4 +1,3 @@ -import type { Auth0Tenant } from "./Auth0Tenant"; import type { KeycloakEnvironment } from "./KeycloakEnvironment"; import type { UiTiDv1Environment } from "./UiTiDv1Environment"; @@ -12,21 +11,14 @@ export type LegacyAuthConsumer = { integrationId: string; }; export type AuthClient = { - clientId: string; - clientSecret: string; - id: string; - integrationId: string; - tenant: Auth0Tenant; -}; -export type KeycloakClient = { clientId: string; clientSecret: string; environment: KeycloakEnvironment; id: string; integrationId: string; }; + export type Credentials = { - auth0: AuthClient[]; - uitidV1: LegacyAuthConsumer[]; - keycloak: KeycloakClient[]; + legacyConsumers: LegacyAuthConsumer[]; + clients: AuthClient[]; }; diff --git a/resources/ts/types/Integration.ts b/resources/ts/types/Integration.ts index 88d02e02a..268eef702 100644 --- a/resources/ts/types/Integration.ts +++ b/resources/ts/types/Integration.ts @@ -5,11 +5,7 @@ import type { Contact } from "./Contact"; import type { Organization } from "./Organization"; import type { Subscription } from "./Subscription"; import type { IntegrationUrl } from "./IntegrationUrl"; -import type { - AuthClient, - KeycloakClient, - LegacyAuthConsumer, -} from "./Credentials"; +import type { AuthClient, LegacyAuthConsumer } from "./Credentials"; import type { KeyVisibility } from "./KeyVisibility"; export type Coupon = { @@ -41,7 +37,6 @@ export type Integration = { urls: IntegrationUrl[]; authClients: AuthClient[]; legacyAuthConsumers: LegacyAuthConsumer[]; - keycloakClients: KeycloakClient[]; keyVisibility: KeyVisibility; keyVisibilityUpgrade: KeyVisibilityUpgrade | null; }; diff --git a/resources/ts/types/PageProps.ts b/resources/ts/types/PageProps.ts index c55a90161..e9808670b 100644 --- a/resources/ts/types/PageProps.ts +++ b/resources/ts/types/PageProps.ts @@ -11,10 +11,6 @@ type Config = { enabled: boolean; dsn: string; }; - keycloak: { - enabled: boolean; - creationEnabled: boolean; - }; }; export type PageProps = {