diff --git a/src/authz-module/data/api.ts b/src/authz-module/data/api.ts index 53a786f..fd570d6 100644 --- a/src/authz-module/data/api.ts +++ b/src/authz-module/data/api.ts @@ -9,7 +9,7 @@ export interface GetTeamMembersResponse { } export type PermissionsByRole = { - key: string; + role: string; permissions: string[]; userCount: number; }; diff --git a/src/authz-module/data/hooks.test.tsx b/src/authz-module/data/hooks.test.tsx index dfeb3f5..7d1cdcc 100644 --- a/src/authz-module/data/hooks.test.tsx +++ b/src/authz-module/data/hooks.test.tsx @@ -127,8 +127,8 @@ describe('useLibrary', () => { describe('usePermissionsByRole', () => { it('fetches roles for a given scope', async () => { const mockRoles = [ - { key: 'admin', permissions: ['perm1'], userCount: 1 }, - { key: 'user', permissions: ['perm2'], userCount: 2 }, + { role: 'admin', permissions: ['perm1'], userCount: 1 }, + { role: 'user', permissions: ['perm2'], userCount: 2 }, ]; getAuthenticatedHttpClient.mockReturnValue({ diff --git a/src/authz-module/libraries-manager/constants.ts b/src/authz-module/libraries-manager/constants.ts index d6e3fbc..a247829 100644 --- a/src/authz-module/libraries-manager/constants.ts +++ b/src/authz-module/libraries-manager/constants.ts @@ -3,10 +3,10 @@ import { PermissionMetadata, ResourceMetadata, RoleMetadata } from 'types'; // Note: this information will eventually come from the backend API // but for the MVP we decided to manage it in the frontend export const libraryRolesMetadata: RoleMetadata[] = [ - { key: 'library_admin', name: 'Library Admin', description: 'The Library Admin has full control over the library, including managing users, modifying content, and handling publishing workflows. They ensure content is properly maintained and accessible as needed.' }, - { key: 'library_author', name: 'Library Author', description: 'The Library Author is responsible for creating, editing, and publishing content within a library. They can manage tags and collections but cannot delete libraries or manage users.' }, - { key: 'library_collaborator', name: 'Library Collaborator', description: 'The Library Collaborator can create and edit content within a library but cannot publish it. They support the authoring process while leaving final publishing to Authors or Admins.' }, - { key: 'library_user', name: 'Library User', description: 'The Library User can view and reuse content but cannot edit or delete any resource.' }, + { role: 'library_admin', name: 'Library Admin', description: 'The Library Admin has full control over the library, including managing users, modifying content, and handling publishing workflows. They ensure content is properly maintained and accessible as needed.' }, + { role: 'library_author', name: 'Library Author', description: 'The Library Author is responsible for creating, editing, and publishing content within a library. They can manage tags and collections but cannot delete libraries or manage users.' }, + { role: 'library_collaborator', name: 'Library Collaborator', description: 'The Library Collaborator can create and edit content within a library but cannot publish it. They support the authoring process while leaving final publishing to Authors or Admins.' }, + { role: 'library_user', name: 'Library User', description: 'The Library User can view and reuse content but cannot edit or delete any resource.' }, ]; export const libraryResourceTypes: ResourceMetadata[] = [ diff --git a/src/authz-module/libraries-manager/context.test.tsx b/src/authz-module/libraries-manager/context.test.tsx index bacfbc5..9755c70 100644 --- a/src/authz-module/libraries-manager/context.test.tsx +++ b/src/authz-module/libraries-manager/context.test.tsx @@ -16,7 +16,7 @@ jest.mock('@src/authz-module/data/hooks', () => ({ usePermissionsByRole: jest.fn().mockReturnValue({ data: [ { - key: 'library_author', + role: 'library_author', permissions: [ 'view_library_team', 'edit_library', diff --git a/src/authz-module/libraries-manager/context.tsx b/src/authz-module/libraries-manager/context.tsx index 67d9c05..5c8e2c7 100644 --- a/src/authz-module/libraries-manager/context.tsx +++ b/src/authz-module/libraries-manager/context.tsx @@ -51,7 +51,10 @@ export const LibraryAuthZProvider: React.FC = ({ children }: } const { data: libraryRoles } = usePermissionsByRole(LIBRARY_AUTHZ_SCOPE); - const roles = libraryRoles.map(role => ({ ...role, ...libraryRolesMetadata.find(r => r.key === role.key) } as Role)); + const roles = libraryRoles.map(role => ({ + ...role, + ...libraryRolesMetadata.find(r => r.role === role.role), + } as Role)); const value = useMemo((): LibraryAuthZContextType => ({ username: authenticatedUser.username, diff --git a/src/types.ts b/src/types.ts index ef8f126..3a7ebdd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,5 @@ export interface PermissionValidationRequest { action: string; - object?: string; scope?: string; } @@ -11,6 +10,7 @@ export interface PermissionValidationResponse extends PermissionValidationReques // Libraries AuthZ types export interface TeamMember { username: string; + fullName: string; email: string; roles: string[]; } @@ -23,7 +23,7 @@ export interface LibraryMetadata { } export interface RoleMetadata { - key: string; + role: string; name: string; description: string; }