Skip to content

Commit b1f3538

Browse files
committed
fix: add delete permissions and user the libraryId to retrieve the mapping of roles and permissions
1 parent 3c7acfe commit b1f3538

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/authz-module/libraries-manager/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const libraryResourceTypes: ResourceMetadata[] = [
1818

1919
export const libraryPermissions: PermissionMetadata[] = [
2020
{ key: 'view_library', resource: 'library', description: 'View content, search, filter, and sort within the library.' },
21+
{ key: 'delete_library', resource: 'library', description: 'Allows the user to delete the library and all its contents.' },
2122
{ key: 'manage_library_tags', resource: 'library', description: 'Add or remove tags from content.' },
2223

2324
{ key: 'edit_library_content', resource: 'library_content', description: 'Edit content in draft mode' },

src/authz-module/libraries-manager/context.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import { PermissionMetadata, ResourceMetadata, Role } from 'types';
99
import { libraryPermissions, libraryResourceTypes, libraryRolesMetadata } from './constants';
1010

1111
const LIBRARY_TEAM_PERMISSIONS = ['view_library_team', 'manage_library_team'];
12-
// Note: This value can change in the future
13-
const LIBRARY_AUTHZ_SCOPE = '*';
12+
1413

1514
export type AppContextType = {
1615
authenticatedUser: {
@@ -51,7 +50,7 @@ export const LibraryAuthZProvider: React.FC<AuthZProviderProps> = ({ children }:
5150
throw new Error('NoAccess');
5251
}
5352

54-
const { data: libraryRoles } = usePermissionsByRole(LIBRARY_AUTHZ_SCOPE);
53+
const { data: libraryRoles } = usePermissionsByRole(libraryId);
5554
const roles = libraryRoles.map(role => ({
5655
...role,
5756
...libraryRolesMetadata.find(r => r.role === role.role),

0 commit comments

Comments
 (0)