Hide capability config for bearer-only clients (#1279)
This commit is contained in:
parent
8917744c04
commit
10d7c35b81
5 changed files with 71 additions and 44 deletions
|
@ -279,13 +279,20 @@ describe("Clients test", () => {
|
||||||
keycloakBefore();
|
keycloakBefore();
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
sidebarPage.goToClients();
|
sidebarPage.goToClients();
|
||||||
|
cy.intercept("/auth/admin/realms/master/clients/*").as("fetchClient");
|
||||||
listingPage.searchItem(clientId).goToItemDetails(clientId);
|
listingPage.searchItem(clientId).goToItemDetails(clientId);
|
||||||
|
cy.wait("@fetchClient");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows an explainer text for bearer only clients", () => {
|
it("shows an explainer text for bearer only clients", () => {
|
||||||
cy.findByTestId("bearer-only-explainer-label").trigger("mouseenter");
|
cy.findByTestId("bearer-only-explainer-label").trigger("mouseenter");
|
||||||
cy.findByTestId("bearer-only-explainer-tooltip").should("exist");
|
cy.findByTestId("bearer-only-explainer-tooltip").should("exist");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("hides the capability config section", () => {
|
||||||
|
cy.findByTestId("capability-config-form").should("not.exist");
|
||||||
|
cy.findByTestId("jump-link-capability-config").should("not.exist");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("SAML test", () => {
|
describe("SAML test", () => {
|
||||||
|
|
|
@ -337,6 +337,7 @@ export const ClientDetails = () => {
|
||||||
title={<TabTitleText>{t("common:settings")}</TabTitleText>}
|
title={<TabTitleText>{t("common:settings")}</TabTitleText>}
|
||||||
>
|
>
|
||||||
<ClientSettings
|
<ClientSettings
|
||||||
|
client={client}
|
||||||
save={() => save()}
|
save={() => save()}
|
||||||
reset={() => setupForm(client)}
|
reset={() => setupForm(client)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { useState } from "react";
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
||||||
|
import React, { useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
FormGroup,
|
FormGroup,
|
||||||
|
@ -25,26 +26,16 @@ import { SamlSignature } from "./add/SamlSignature";
|
||||||
import type { ClientForm } from "./ClientDetails";
|
import type { ClientForm } from "./ClientDetails";
|
||||||
|
|
||||||
type ClientSettingsProps = {
|
type ClientSettingsProps = {
|
||||||
|
client: ClientRepresentation;
|
||||||
save: () => void;
|
save: () => void;
|
||||||
reset: () => void;
|
reset: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseSections = [
|
export const ClientSettings = ({
|
||||||
"generalSettings",
|
client,
|
||||||
"capabilityConfig",
|
save,
|
||||||
"accessSettings",
|
reset,
|
||||||
"loginSettings",
|
}: ClientSettingsProps) => {
|
||||||
] as const;
|
|
||||||
|
|
||||||
const samlSections = [
|
|
||||||
"generalSettings",
|
|
||||||
"samlCapabilityConfig",
|
|
||||||
"signatureAndEncryption",
|
|
||||||
"accessSettings",
|
|
||||||
"loginSettings",
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const ClientSettings = ({ save, reset }: ClientSettingsProps) => {
|
|
||||||
const { register, control, watch } = useFormContext<ClientForm>();
|
const { register, control, watch } = useFormContext<ClientForm>();
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
|
|
||||||
|
@ -55,7 +46,18 @@ export const ClientSettings = ({ save, reset }: ClientSettingsProps) => {
|
||||||
"attributes.display-on-consent-screen"
|
"attributes.display-on-consent-screen"
|
||||||
);
|
);
|
||||||
const protocol = watch("protocol");
|
const protocol = watch("protocol");
|
||||||
const sections = protocol === "saml" ? samlSections : baseSections;
|
|
||||||
|
const sections = useMemo(() => {
|
||||||
|
let result = ["generalSettings"];
|
||||||
|
|
||||||
|
if (protocol === "saml") {
|
||||||
|
result = [...result, "samlCapabilityConfig", "signatureAndEncryption"];
|
||||||
|
} else if (!client.bearerOnly) {
|
||||||
|
result = [...result, "capabilityConfig"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...result, "accessSettings", "loginSettings"];
|
||||||
|
}, [protocol, client]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollForm
|
<ScrollForm
|
||||||
|
@ -65,7 +67,11 @@ export const ClientSettings = ({ save, reset }: ClientSettingsProps) => {
|
||||||
<Form isHorizontal>
|
<Form isHorizontal>
|
||||||
<ClientDescription />
|
<ClientDescription />
|
||||||
</Form>
|
</Form>
|
||||||
{protocol === "saml" ? <SamlConfig /> : <CapabilityConfig />}
|
{protocol === "saml" ? (
|
||||||
|
<SamlConfig />
|
||||||
|
) : (
|
||||||
|
!client.bearerOnly && <CapabilityConfig />
|
||||||
|
)}
|
||||||
{protocol === "saml" && <SamlSignature />}
|
{protocol === "saml" && <SamlSignature />}
|
||||||
<FormAccess isHorizontal role="manage-clients">
|
<FormAccess isHorizontal role="manage-clients">
|
||||||
<FormGroup
|
<FormGroup
|
||||||
|
|
|
@ -37,6 +37,7 @@ export const CapabilityConfig = ({
|
||||||
role="manage-clients"
|
role="manage-clients"
|
||||||
unWrap={unWrap}
|
unWrap={unWrap}
|
||||||
className="keycloak__capability-config__form"
|
className="keycloak__capability-config__form"
|
||||||
|
data-testid="capability-config-form"
|
||||||
>
|
>
|
||||||
{protocol === "openid-connect" && (
|
{protocol === "openid-connect" && (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -31,29 +31,33 @@ export const ScrollForm: FunctionComponent<ScrollFormProps> = ({
|
||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation("common");
|
const { t } = useTranslation("common");
|
||||||
|
|
||||||
const nodes = Children.toArray(children);
|
const nodes = Children.toArray(children);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid hasGutter {...rest}>
|
<Grid hasGutter {...rest}>
|
||||||
<GridItem span={8}>
|
<GridItem span={8}>
|
||||||
{sections.map((cat, index) => (
|
{sections.map((cat, index) => {
|
||||||
<Fragment key={cat}>
|
const scrollId = spacesToHyphens(cat.toLowerCase());
|
||||||
{!borders && (
|
|
||||||
<ScrollPanel scrollId={spacesToHyphens(cat)} title={cat}>
|
return (
|
||||||
{nodes[index]}
|
<Fragment key={cat}>
|
||||||
</ScrollPanel>
|
{!borders && (
|
||||||
)}
|
<ScrollPanel scrollId={scrollId} title={cat}>
|
||||||
{borders && (
|
{nodes[index]}
|
||||||
<FormPanel
|
</ScrollPanel>
|
||||||
scrollId={spacesToHyphens(cat)}
|
)}
|
||||||
title={cat}
|
{borders && (
|
||||||
className="kc-form-panel__panel"
|
<FormPanel
|
||||||
>
|
scrollId={scrollId}
|
||||||
{nodes[index]}
|
title={cat}
|
||||||
</FormPanel>
|
className="kc-form-panel__panel"
|
||||||
)}
|
>
|
||||||
</Fragment>
|
{nodes[index]}
|
||||||
))}
|
</FormPanel>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem span={4}>
|
<GridItem span={4}>
|
||||||
<PageSection className="kc-scroll-form--sticky">
|
<PageSection className="kc-scroll-form--sticky">
|
||||||
|
@ -65,12 +69,20 @@ export const ScrollForm: FunctionComponent<ScrollFormProps> = ({
|
||||||
label={t("jumpToSection")}
|
label={t("jumpToSection")}
|
||||||
offset={100}
|
offset={100}
|
||||||
>
|
>
|
||||||
{sections.map((cat) => (
|
{sections.map((cat) => {
|
||||||
// note that JumpLinks currently does not work with spaces in the href
|
const scrollId = spacesToHyphens(cat.toLowerCase());
|
||||||
<JumpLinksItem key={cat} href={`#${spacesToHyphens(cat)}`}>
|
|
||||||
{cat}
|
return (
|
||||||
</JumpLinksItem>
|
// note that JumpLinks currently does not work with spaces in the href
|
||||||
))}
|
<JumpLinksItem
|
||||||
|
key={cat}
|
||||||
|
href={`#${scrollId}`}
|
||||||
|
data-testid={`jump-link-${scrollId}`}
|
||||||
|
>
|
||||||
|
{cat}
|
||||||
|
</JumpLinksItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</JumpLinks>
|
</JumpLinks>
|
||||||
</PageSection>
|
</PageSection>
|
||||||
</GridItem>
|
</GridItem>
|
||||||
|
|
Loading…
Reference in a new issue