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();
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClients();
|
||||
cy.intercept("/auth/admin/realms/master/clients/*").as("fetchClient");
|
||||
listingPage.searchItem(clientId).goToItemDetails(clientId);
|
||||
cy.wait("@fetchClient");
|
||||
});
|
||||
|
||||
it("shows an explainer text for bearer only clients", () => {
|
||||
cy.findByTestId("bearer-only-explainer-label").trigger("mouseenter");
|
||||
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", () => {
|
||||
|
|
|
@ -337,6 +337,7 @@ export const ClientDetails = () => {
|
|||
title={<TabTitleText>{t("common:settings")}</TabTitleText>}
|
||||
>
|
||||
<ClientSettings
|
||||
client={client}
|
||||
save={() => save()}
|
||||
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 {
|
||||
FormGroup,
|
||||
|
@ -25,26 +26,16 @@ import { SamlSignature } from "./add/SamlSignature";
|
|||
import type { ClientForm } from "./ClientDetails";
|
||||
|
||||
type ClientSettingsProps = {
|
||||
client: ClientRepresentation;
|
||||
save: () => void;
|
||||
reset: () => void;
|
||||
};
|
||||
|
||||
const baseSections = [
|
||||
"generalSettings",
|
||||
"capabilityConfig",
|
||||
"accessSettings",
|
||||
"loginSettings",
|
||||
] as const;
|
||||
|
||||
const samlSections = [
|
||||
"generalSettings",
|
||||
"samlCapabilityConfig",
|
||||
"signatureAndEncryption",
|
||||
"accessSettings",
|
||||
"loginSettings",
|
||||
] as const;
|
||||
|
||||
export const ClientSettings = ({ save, reset }: ClientSettingsProps) => {
|
||||
export const ClientSettings = ({
|
||||
client,
|
||||
save,
|
||||
reset,
|
||||
}: ClientSettingsProps) => {
|
||||
const { register, control, watch } = useFormContext<ClientForm>();
|
||||
const { t } = useTranslation("clients");
|
||||
|
||||
|
@ -55,7 +46,18 @@ export const ClientSettings = ({ save, reset }: ClientSettingsProps) => {
|
|||
"attributes.display-on-consent-screen"
|
||||
);
|
||||
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 (
|
||||
<ScrollForm
|
||||
|
@ -65,7 +67,11 @@ export const ClientSettings = ({ save, reset }: ClientSettingsProps) => {
|
|||
<Form isHorizontal>
|
||||
<ClientDescription />
|
||||
</Form>
|
||||
{protocol === "saml" ? <SamlConfig /> : <CapabilityConfig />}
|
||||
{protocol === "saml" ? (
|
||||
<SamlConfig />
|
||||
) : (
|
||||
!client.bearerOnly && <CapabilityConfig />
|
||||
)}
|
||||
{protocol === "saml" && <SamlSignature />}
|
||||
<FormAccess isHorizontal role="manage-clients">
|
||||
<FormGroup
|
||||
|
|
|
@ -37,6 +37,7 @@ export const CapabilityConfig = ({
|
|||
role="manage-clients"
|
||||
unWrap={unWrap}
|
||||
className="keycloak__capability-config__form"
|
||||
data-testid="capability-config-form"
|
||||
>
|
||||
{protocol === "openid-connect" && (
|
||||
<>
|
||||
|
|
|
@ -31,29 +31,33 @@ export const ScrollForm: FunctionComponent<ScrollFormProps> = ({
|
|||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation("common");
|
||||
|
||||
const nodes = Children.toArray(children);
|
||||
|
||||
return (
|
||||
<Grid hasGutter {...rest}>
|
||||
<GridItem span={8}>
|
||||
{sections.map((cat, index) => (
|
||||
<Fragment key={cat}>
|
||||
{!borders && (
|
||||
<ScrollPanel scrollId={spacesToHyphens(cat)} title={cat}>
|
||||
{nodes[index]}
|
||||
</ScrollPanel>
|
||||
)}
|
||||
{borders && (
|
||||
<FormPanel
|
||||
scrollId={spacesToHyphens(cat)}
|
||||
title={cat}
|
||||
className="kc-form-panel__panel"
|
||||
>
|
||||
{nodes[index]}
|
||||
</FormPanel>
|
||||
)}
|
||||
</Fragment>
|
||||
))}
|
||||
{sections.map((cat, index) => {
|
||||
const scrollId = spacesToHyphens(cat.toLowerCase());
|
||||
|
||||
return (
|
||||
<Fragment key={cat}>
|
||||
{!borders && (
|
||||
<ScrollPanel scrollId={scrollId} title={cat}>
|
||||
{nodes[index]}
|
||||
</ScrollPanel>
|
||||
)}
|
||||
{borders && (
|
||||
<FormPanel
|
||||
scrollId={scrollId}
|
||||
title={cat}
|
||||
className="kc-form-panel__panel"
|
||||
>
|
||||
{nodes[index]}
|
||||
</FormPanel>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</GridItem>
|
||||
<GridItem span={4}>
|
||||
<PageSection className="kc-scroll-form--sticky">
|
||||
|
@ -65,12 +69,20 @@ export const ScrollForm: FunctionComponent<ScrollFormProps> = ({
|
|||
label={t("jumpToSection")}
|
||||
offset={100}
|
||||
>
|
||||
{sections.map((cat) => (
|
||||
// note that JumpLinks currently does not work with spaces in the href
|
||||
<JumpLinksItem key={cat} href={`#${spacesToHyphens(cat)}`}>
|
||||
{cat}
|
||||
</JumpLinksItem>
|
||||
))}
|
||||
{sections.map((cat) => {
|
||||
const scrollId = spacesToHyphens(cat.toLowerCase());
|
||||
|
||||
return (
|
||||
// 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>
|
||||
</PageSection>
|
||||
</GridItem>
|
||||
|
|
Loading…
Reference in a new issue