parent
d857ea8ec2
commit
139b809f72
3 changed files with 22 additions and 7 deletions
|
@ -194,11 +194,14 @@ export default function ClientDetails() {
|
||||||
const { profileInfo } = useServerInfo();
|
const { profileInfo } = useServerInfo();
|
||||||
|
|
||||||
const { hasAccess } = useAccess();
|
const { hasAccess } = useAccess();
|
||||||
|
const hasManageAuthorization = hasAccess("manage-authorization");
|
||||||
const permissionsEnabled =
|
const permissionsEnabled =
|
||||||
!profileInfo?.disabledFeatures?.includes("ADMIN_FINE_GRAINED_AUTHZ") &&
|
!profileInfo?.disabledFeatures?.includes("ADMIN_FINE_GRAINED_AUTHZ") &&
|
||||||
hasAccess("manage-authorization");
|
hasManageAuthorization;
|
||||||
const hasManageClients = hasAccess("manage-clients");
|
const hasManageClients = hasAccess("manage-clients");
|
||||||
|
const hasViewClients = hasAccess("view-clients");
|
||||||
const hasViewUsers = hasAccess("view-users");
|
const hasViewUsers = hasAccess("view-users");
|
||||||
|
const hasQueryUsers = hasAccess("query-users");
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
@ -452,7 +455,7 @@ export default function ClientDetails() {
|
||||||
)}
|
)}
|
||||||
{!client.publicClient &&
|
{!client.publicClient &&
|
||||||
!isRealmClient(client) &&
|
!isRealmClient(client) &&
|
||||||
(hasManageClients || client.access?.configure) && (
|
(hasViewClients || client.access?.configure) && (
|
||||||
<Tab
|
<Tab
|
||||||
id="credentials"
|
id="credentials"
|
||||||
title={<TabTitleText>{t("credentials")}</TabTitleText>}
|
title={<TabTitleText>{t("credentials")}</TabTitleText>}
|
||||||
|
@ -488,7 +491,7 @@ export default function ClientDetails() {
|
||||||
isReadOnly={!(hasManageClients || client.access?.configure)}
|
isReadOnly={!(hasManageClients || client.access?.configure)}
|
||||||
/>
|
/>
|
||||||
</Tab>
|
</Tab>
|
||||||
{!isRealmClient(client) && !client.bearerOnly && (
|
{!isRealmClient(client) && !client.bearerOnly && hasQueryUsers && (
|
||||||
<Tab
|
<Tab
|
||||||
id="clientScopes"
|
id="clientScopes"
|
||||||
data-testid="clientScopesTab"
|
data-testid="clientScopesTab"
|
||||||
|
@ -527,7 +530,7 @@ export default function ClientDetails() {
|
||||||
</RoutableTabs>
|
</RoutableTabs>
|
||||||
</Tab>
|
</Tab>
|
||||||
)}
|
)}
|
||||||
{client!.authorizationServicesEnabled && (
|
{client!.authorizationServicesEnabled && hasManageAuthorization && (
|
||||||
<Tab
|
<Tab
|
||||||
id="authorization"
|
id="authorization"
|
||||||
data-testid="authorizationTab"
|
data-testid="authorizationTab"
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"
|
||||||
import { useAdminClient } from "../../context/auth/AdminClient";
|
import { useAdminClient } from "../../context/auth/AdminClient";
|
||||||
import { useAlerts } from "../../components/alert/Alerts";
|
import { useAlerts } from "../../components/alert/Alerts";
|
||||||
import useFormatDate from "../../utils/useFormatDate";
|
import useFormatDate from "../../utils/useFormatDate";
|
||||||
|
import { useAccess } from "../../context/access/Access";
|
||||||
|
|
||||||
export type ClientSecretProps = {
|
export type ClientSecretProps = {
|
||||||
client: ClientRepresentation;
|
client: ClientRepresentation;
|
||||||
|
@ -24,14 +25,22 @@ export type ClientSecretProps = {
|
||||||
toggle: () => void;
|
toggle: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SecretInputProps = Omit<ClientSecretProps, "client"> & {
|
type SecretInputProps = ClientSecretProps & {
|
||||||
id: string;
|
id: string;
|
||||||
buttonLabel: string;
|
buttonLabel: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SecretInput = ({ id, buttonLabel, secret, toggle }: SecretInputProps) => {
|
const SecretInput = ({
|
||||||
|
id,
|
||||||
|
buttonLabel,
|
||||||
|
client,
|
||||||
|
secret,
|
||||||
|
toggle,
|
||||||
|
}: SecretInputProps) => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const form = useFormContext<ClientRepresentation>();
|
const form = useFormContext<ClientRepresentation>();
|
||||||
|
const { hasAccess } = useAccess();
|
||||||
|
const isManager = hasAccess("manage-clients") || client.access?.configure;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Split hasGutter>
|
<Split hasGutter>
|
||||||
|
@ -49,7 +58,7 @@ const SecretInput = ({ id, buttonLabel, secret, toggle }: SecretInputProps) => {
|
||||||
<SplitItem>
|
<SplitItem>
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
isDisabled={form.formState.isDirty}
|
isDisabled={form.formState.isDirty || !isManager}
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
>
|
>
|
||||||
{t(buttonLabel)}
|
{t(buttonLabel)}
|
||||||
|
@ -117,6 +126,7 @@ export const ClientSecret = ({ client, secret, toggle }: ClientSecretProps) => {
|
||||||
>
|
>
|
||||||
<SecretInput
|
<SecretInput
|
||||||
id="kc-client-secret"
|
id="kc-client-secret"
|
||||||
|
client={client}
|
||||||
secret={secret}
|
secret={secret}
|
||||||
toggle={toggle}
|
toggle={toggle}
|
||||||
buttonLabel="regenerate"
|
buttonLabel="regenerate"
|
||||||
|
@ -130,6 +140,7 @@ export const ClientSecret = ({ client, secret, toggle }: ClientSecretProps) => {
|
||||||
<FormGroup label={t("secretRotated")} fieldId="secretRotated">
|
<FormGroup label={t("secretRotated")} fieldId="secretRotated">
|
||||||
<SecretInput
|
<SecretInput
|
||||||
id="secretRotated"
|
id="secretRotated"
|
||||||
|
client={client}
|
||||||
secret={secretRotated}
|
secret={secretRotated}
|
||||||
toggle={toggleInvalidateConfirm}
|
toggle={toggleInvalidateConfirm}
|
||||||
buttonLabel="invalidateSecret"
|
buttonLabel="invalidateSecret"
|
||||||
|
|
|
@ -140,6 +140,7 @@ export const Credentials = ({ client, save, refresh }: CredentialsProps) => {
|
||||||
isHorizontal
|
isHorizontal
|
||||||
className="pf-u-mt-md"
|
className="pf-u-mt-md"
|
||||||
role="manage-clients"
|
role="manage-clients"
|
||||||
|
fineGrainedAccess={client.access?.configure}
|
||||||
>
|
>
|
||||||
<ClientSecretConfirm />
|
<ClientSecretConfirm />
|
||||||
<AccessTokenConfirm />
|
<AccessTokenConfirm />
|
||||||
|
|
Loading…
Reference in a new issue