diff --git a/src/api/auth-identities.tsx b/src/api/auth-identities.tsx index 3ba6b52c6a..7bf72a5b39 100644 --- a/src/api/auth-identities.tsx +++ b/src/api/auth-identities.tsx @@ -51,23 +51,24 @@ export const updateIdentities = ( }); }; -export const deleteOIDCIdentity = (identity: LxdIdentity) => { +export const deleteIdentity = (identity: LxdIdentity) => { return new Promise((resolve, reject) => { - fetch(`/1.0/auth/identities/oidc/${identity.id}`, { - method: "DELETE", - }) + fetch( + `/1.0/auth/identities/${identity.authentication_method}/${identity.id}`, + { + method: "DELETE", + }, + ) .then(handleResponse) .then(resolve) .catch(reject); }); }; -export const deleteOIDCIdentities = ( - identities: LxdIdentity[], -): Promise => { +export const deleteIdentities = (identities: LxdIdentity[]): Promise => { return new Promise((resolve, reject) => { void Promise.allSettled( - identities.map((identity) => deleteOIDCIdentity(identity)), + identities.map((identity) => deleteIdentity(identity)), ) .then(handleSettledResult) .then(resolve) diff --git a/src/components/IdentityResource.tsx b/src/components/IdentityResource.tsx new file mode 100644 index 0000000000..f25007494a --- /dev/null +++ b/src/components/IdentityResource.tsx @@ -0,0 +1,22 @@ +import { FC } from "react"; +import { LxdIdentity } from "types/permissions"; +import ResourceLabel from "./ResourceLabel"; + +interface Props { + identity: LxdIdentity; + truncate?: boolean; +} + +const IdentityResource: FC = ({ identity, truncate }) => { + const identityIconType = + identity.authentication_method == "tls" ? "certificate" : "oidc-identity"; + + return ( + + ); +}; +export default IdentityResource; diff --git a/src/components/ResourceLabel.tsx b/src/components/ResourceLabel.tsx index 1d7a40f372..ca6cbccce8 100644 --- a/src/components/ResourceLabel.tsx +++ b/src/components/ResourceLabel.tsx @@ -1,16 +1,18 @@ import { FC } from "react"; import ResourceIcon, { ResourceIconType } from "./ResourceIcon"; +import classNames from "classnames"; interface Props { type: ResourceIconType; value: string; bold?: boolean; + truncate?: boolean; } -const ResourceLabel: FC = ({ type, value, bold }) => { +const ResourceLabel: FC = ({ type, value, bold, truncate = true }) => { const ValueWrapper = bold ? "strong" : "span"; return ( - + {value} diff --git a/src/pages/permissions/PermissionIdentities.tsx b/src/pages/permissions/PermissionIdentities.tsx index b07858ea8f..dc66e0698b 100644 --- a/src/pages/permissions/PermissionIdentities.tsx +++ b/src/pages/permissions/PermissionIdentities.tsx @@ -33,6 +33,8 @@ import Tag from "components/Tag"; import BulkDeleteIdentitiesBtn from "./actions/BulkDeleteIdentitiesBtn"; import DeleteIdentityBtn from "./actions/DeleteIdentityBtn"; import { useSupportedFeatures } from "context/useSupportedFeatures"; +import { isUnrestricted } from "util/helpers"; +import IdentityResource from "components/IdentityResource"; const PermissionIdentities: FC = () => { const notify = useNotify(); @@ -52,12 +54,10 @@ const PermissionIdentities: FC = () => { const { hasAccessManagementTLS } = useSupportedFeatures(); useEffect(() => { - const validIdentities = new Set( - identities.map((identity) => identity.name), - ); + const validIdentityIds = new Set(identities.map((identity) => identity.id)); const validSelections = selectedIdentityIds.filter((identity) => - validIdentities.has(identity), + validIdentityIds.has(identity), ); if (validSelections.length !== selectedIdentityIds.length) { @@ -114,9 +114,9 @@ const PermissionIdentities: FC = () => { const rows = filteredIdentities.map((identity) => { const isLoggedInIdentity = settings?.auth_user_name === identity.id; - const isTlsIdentity = identity.authentication_method === "tls"; + return { - name: isTlsIdentity ? "" : identity.id, + name: isUnrestricted(identity) ? "" : identity.id, key: identity.id, className: "u-row", columns: [ @@ -144,7 +144,7 @@ const PermissionIdentities: FC = () => { "aria-label": "Auth method", }, { - content: identity.type, + content: , role: "cell", "aria-label": "Type", className: "u-truncate", @@ -157,10 +157,11 @@ const PermissionIdentities: FC = () => { "aria-label": "Groups for this identity", }, { - content: !isTlsIdentity && ( + content: !isUnrestricted(identity) && ( <>