Allow FGA with view-clients to see client roles (#30834)

Signed-off-by: Stan Silvert <ssilvert@redhat.com>
This commit is contained in:
Stan Silvert 2024-07-01 08:50:30 -04:00 committed by GitHub
parent ea0f569bd0
commit fd8cb95595
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 9 deletions

View file

@ -23,7 +23,7 @@ export const ClientRoleRoute: AppRouteObject = {
element: <RealmRoleTabs />,
breadcrumb: (t) => t("roleDetails"),
handle: {
access: "view-clients",
access: "query-clients",
},
} satisfies AppRouteObject;

View file

@ -52,6 +52,7 @@ import { useParams } from "../utils/useParams";
import { UsersInRoleTab } from "./UsersInRoleTab";
import { RealmRoleRoute, RealmRoleTab, toRealmRole } from "./routes/RealmRole";
import { toRealmRoles } from "./routes/RealmRoles";
import { useAccess } from "../context/access/Access";
export default function RealmRoleTabs() {
const { adminClient } = useAdminClient();
@ -76,6 +77,12 @@ export default function RealmRoleTabs() {
const { addAlert, addError } = useAlerts();
const { hasAccess } = useAccess();
const canViewPermissionsTab = hasAccess(
"query-clients",
"manage-authorization",
);
const [open, setOpen] = useState(false);
const convert = (role: RoleRepresentation) => {
const { attributes, ...rest } = role;
@ -385,14 +392,15 @@ export default function RealmRoleTabs() {
<UsersInRoleTab data-cy="users-in-role-tab" />
</Tab>
)}
{isFeatureEnabled(Feature.AdminFineGrainedAuthz) && (
<Tab
title={<TabTitleText>{t("permissions")}</TabTitleText>}
{...permissionsTab}
>
<PermissionsTab id={id} type="roles" />
</Tab>
)}
{isFeatureEnabled(Feature.AdminFineGrainedAuthz) &&
canViewPermissionsTab && (
<Tab
title={<TabTitleText>{t("permissions")}</TabTitleText>}
{...permissionsTab}
>
<PermissionsTab id={id} type="roles" />
</Tab>
)}
</RoutableTabs>
</FormProvider>
</PageSection>