From 3a3907ab15de2f7c7497deb9f1b3a9ece23dd301 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 27 Jun 2023 14:00:32 +0200 Subject: [PATCH] changed to use `ConfiguredProvider` instead (#21097) fixes: #15344 --- .../locales/en/identity-providers-help.json | 24 +- .../public/locales/en/identity-providers.json | 19 -- .../add/AddIdentityProvider.tsx | 16 +- .../identity-providers/add/DetailSettings.tsx | 17 +- .../component/ExtendedFieldsForm.tsx | 299 ------------------ .../provider/IdentityProviderFactory.java | 12 +- .../FacebookIdentityProviderFactory.java | 14 + .../github/GitHubIdentityProviderFactory.java | 13 + .../google/GoogleIdentityProviderFactory.java | 27 ++ .../LinkedInIdentityProviderFactory.java | 49 +-- .../OpenshiftV3IdentityProviderFactory.java | 7 + .../OpenshiftV4IdentityProviderConfig.java | 12 + .../OpenshiftV4IdentityProviderFactory.java | 8 + .../paypal/PayPalIdentityProviderFactory.java | 14 + .../StackoverflowIdentityProviderFactory.java | 52 +-- 15 files changed, 199 insertions(+), 384 deletions(-) delete mode 100644 js/apps/admin-ui/src/identity-providers/component/ExtendedFieldsForm.tsx diff --git a/js/apps/admin-ui/public/locales/en/identity-providers-help.json b/js/apps/admin-ui/public/locales/en/identity-providers-help.json index 4d194b89cf..035f4a102c 100644 --- a/js/apps/admin-ui/public/locales/en/identity-providers-help.json +++ b/js/apps/admin-ui/public/locales/en/identity-providers-help.json @@ -95,27 +95,5 @@ "attributeValue": "Value the attribute must have. If the attribute is a list, then the value must be contained in the list.", "attributes": "Name and (regex) value of the attributes to search for in token. The configured name of an attribute is searched in SAML attribute name and attribute friendly name fields. Every given attribute description must be met to set the role. If the attribute is an array, then the value must be contained in the array. If an attribute can be found several times, then one match is sufficient.", "regexAttributeValues": "If enabled attribute values are interpreted as regular expressions.", - "role": "Role to grant to user if all attributes are present. Click 'Select Role' button to browse roles, or just type it in the textbox. To reference a client role the syntax is clientname.clientrole, i.e. myclient.myrole", - "baseUrl": "Override the default Base URL for this identity provider.", - "apiUrl": "Override the default API URL for this identity provider.", - "facebook": { - "fetchedFields": "Provide additional fields which would be fetched using the profile request. This will be appended to the default set of 'id,name,email,first_name,last_name'." - }, - "google": { - "hostedDomain": "Set 'hd' query parameter when logging in with Google. Google will list accounts only for this domain. Keycloak validates that the returned identity token has a claim for this domain. When '*' is entered, any hosted account can be used. Comma ',' separated list of domains is supported.", - "userIp": "Set 'userIp' query parameter when invoking on Google's User Info service. This will use the user's ip address. Useful if Google is throttling access to the User Info service.", - "offlineAccess": "Set 'access_type' query parameter to 'offline' when redirecting to google authorization endpoint, to get a refresh token back. Useful if planning to use Token Exchange to retrieve Google token to access Google APIs when the user is not at the browser." - }, - "openshift": { - "baseUrl": "Base Url to OpenShift Online API" - }, - "paypal": { - "sandbox": "Target PayPal's sandbox environment" - }, - "stackoverflow": { - "key": "The Key obtained from Stack Overflow client registration." - }, - "linkedin": { - "profileProjection": "Projection parameter for profile request. Leave empty for default projection." - } + "role": "Role to grant to user if all attributes are present. Click 'Select Role' button to browse roles, or just type it in the textbox. To reference a client role the syntax is clientname.clientrole, i.e. myclient.myrole" } diff --git a/js/apps/admin-ui/public/locales/en/identity-providers.json b/js/apps/admin-ui/public/locales/en/identity-providers.json index e14fde52d0..b453f715c2 100644 --- a/js/apps/admin-ui/public/locales/en/identity-providers.json +++ b/js/apps/admin-ui/public/locales/en/identity-providers.json @@ -178,24 +178,5 @@ "local": "LOCAL", "brokerId": "BROKER_ID", "brokerUsername": "BROKER_USERNAME" - }, - "baseUrl": "Base URL", - "apiUrl": "API URL", - "facebook": { - "fetchedFields": "Additional user's profile fields" - }, - "google": { - "hostedDomain": "Hosted Domain", - "userIp": "Use userIp Param", - "offlineAccess": "Request refresh token" - }, - "paypal": { - "sandbox": "Target Sandbox" - }, - "stackoverflow": { - "key": "Key" - }, - "linkedin": { - "profileProjection": "Profile Projection" } } diff --git a/js/apps/admin-ui/src/identity-providers/add/AddIdentityProvider.tsx b/js/apps/admin-ui/src/identity-providers/add/AddIdentityProvider.tsx index 4526beff0f..f14e305b8d 100644 --- a/js/apps/admin-ui/src/identity-providers/add/AddIdentityProvider.tsx +++ b/js/apps/admin-ui/src/identity-providers/add/AddIdentityProvider.tsx @@ -5,17 +5,19 @@ import { Button, PageSection, } from "@patternfly/react-core"; +import { useMemo } from "react"; import { FormProvider, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { Link, useNavigate } from "react-router-dom"; import { adminClient } from "../../admin-client"; import { useAlerts } from "../../components/alert/Alerts"; +import { DynamicComponents } from "../../components/dynamic/DynamicComponents"; import { FormAccess } from "../../components/form/FormAccess"; import { ViewHeader } from "../../components/view-header/ViewHeader"; import { useRealm } from "../../context/realm-context/RealmContext"; +import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { toUpperCase } from "../../util"; import { useParams } from "../../utils/useParams"; -import { ExtendedFieldsForm } from "../component/ExtendedFieldsForm"; import { toIdentityProvider } from "../routes/IdentityProvider"; import type { IdentityProviderCreateParams } from "../routes/IdentityProviderCreate"; import { toIdentityProviders } from "../routes/IdentityProviders"; @@ -25,6 +27,14 @@ export default function AddIdentityProvider() { const { t } = useTranslation("identity-providers"); const { providerId } = useParams(); const form = useForm(); + const serverInfo = useServerInfo(); + const providerInfo = useMemo( + () => + serverInfo.componentTypes?.[ + "org.keycloak.broker.social.SocialIdentityProvider" + ]?.find((p) => p.id === providerId), + [serverInfo, providerId] + ); const { handleSubmit, formState: { isDirty }, @@ -70,7 +80,9 @@ export default function AddIdentityProvider() { > - + {providerInfo && ( + + )}