Skip to content

Instantly share code, notes, and snippets.

@fjudith
Created September 24, 2025 16:02
Show Gist options
  • Save fjudith/05dfac67443032adfe9fa3fee7a58118 to your computer and use it in GitHub Desktop.
Save fjudith/05dfac67443032adfe9fa3fee7a58118 to your computer and use it in GitHub Desktop.
Backstage: restrict view only to entity owner
import Alert from '@material-ui/lab/Alert';
import { RbacIcon } from '@backstage-community/plugin-rbac';
import { useEntity, useEntityOwnership } from '@backstage/plugin-catalog-react';
import { EntityKubernetesContent } from '@beneva/backstage-plugin-kubernetes';
// Composant qui vérifie la propriété de l'entité avant d'afficher le contenu Kubernetes
export const KubernetesContent = () => {
const { entity } = useEntity();
const { isOwnedEntity } = useEntityOwnership();
// Vérification si l'utilisateur est propriétaire de l'entité
if (!isOwnedEntity(entity)) {
return (
<Alert icon={<RbacIcon fontSize="inherit" />} severity="info">
Access restricted to entity owners.
</Alert>
);
}
// L'utilisateur est propriétaire et Kubernetes est disponible
return <EntityKubernetesContent />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment