mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
feat: Add role-level permissions for agent sharing people picker
- Add PEOPLE_PICKER permission type with VIEW_USERS and VIEW_GROUPS permissions - Create custom middleware for query-aware permission validation - Implement permission-based type filtering in PeoplePicker component - Hide people picker UI when user lacks permissions, show only public toggle - Support granular access: users-only, groups-only, or mixed search modes
This commit is contained in:
parent
b03341517d
commit
73fb4181fe
11 changed files with 220 additions and 32 deletions
72
api/server/middleware/checkPeoplePickerAccess.js
Normal file
72
api/server/middleware/checkPeoplePickerAccess.js
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
const { PermissionTypes, Permissions } = require('librechat-data-provider');
|
||||||
|
const { getRoleByName } = require('~/models/Role');
|
||||||
|
const { logger } = require('~/config');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Middleware to check if user has permission to access people picker functionality
|
||||||
|
* Checks specific permission based on the 'type' query parameter:
|
||||||
|
* - type=user: requires VIEW_USERS permission
|
||||||
|
* - type=group: requires VIEW_GROUPS permission
|
||||||
|
* - no type (mixed search): requires either VIEW_USERS OR VIEW_GROUPS
|
||||||
|
*/
|
||||||
|
const checkPeoplePickerAccess = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const user = req.user;
|
||||||
|
if (!user || !user.role) {
|
||||||
|
return res.status(401).json({
|
||||||
|
error: 'Unauthorized',
|
||||||
|
message: 'Authentication required',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const role = await getRoleByName(user.role);
|
||||||
|
if (!role || !role.permissions) {
|
||||||
|
return res.status(403).json({
|
||||||
|
error: 'Forbidden',
|
||||||
|
message: 'No permissions configured for user role',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { type } = req.query;
|
||||||
|
const peoplePickerPerms = role.permissions[PermissionTypes.PEOPLE_PICKER] || {};
|
||||||
|
const canViewUsers = peoplePickerPerms[Permissions.VIEW_USERS] === true;
|
||||||
|
const canViewGroups = peoplePickerPerms[Permissions.VIEW_GROUPS] === true;
|
||||||
|
|
||||||
|
if (type === 'user') {
|
||||||
|
if (!canViewUsers) {
|
||||||
|
return res.status(403).json({
|
||||||
|
error: 'Forbidden',
|
||||||
|
message: 'Insufficient permissions to search for users',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (type === 'group') {
|
||||||
|
if (!canViewGroups) {
|
||||||
|
return res.status(403).json({
|
||||||
|
error: 'Forbidden',
|
||||||
|
message: 'Insufficient permissions to search for groups',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!canViewUsers || !canViewGroups) {
|
||||||
|
return res.status(403).json({
|
||||||
|
error: 'Forbidden',
|
||||||
|
message: 'Insufficient permissions to search for both users and groups',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
`[checkPeoplePickerAccess][${req.user?.id}] checkPeoplePickerAccess error for req.query.type = ${req.query.type}`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
return res.status(500).json({
|
||||||
|
error: 'Internal Server Error',
|
||||||
|
message: 'Failed to check permissions',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
checkPeoplePickerAccess,
|
||||||
|
};
|
||||||
|
|
@ -8,6 +8,7 @@ const {
|
||||||
searchPrincipals,
|
searchPrincipals,
|
||||||
} = require('~/server/controllers/PermissionsController');
|
} = require('~/server/controllers/PermissionsController');
|
||||||
const { requireJwtAuth, checkBan, uaParser, canAccessResource } = require('~/server/middleware');
|
const { requireJwtAuth, checkBan, uaParser, canAccessResource } = require('~/server/middleware');
|
||||||
|
const { checkPeoplePickerAccess } = require('~/server/middleware/checkPeoplePickerAccess');
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|
@ -25,7 +26,7 @@ router.use(uaParser);
|
||||||
* GET /api/permissions/search-principals
|
* GET /api/permissions/search-principals
|
||||||
* Search for users and groups to grant permissions
|
* Search for users and groups to grant permissions
|
||||||
*/
|
*/
|
||||||
router.get('/search-principals', searchPrincipals);
|
router.get('/search-principals', checkPeoplePickerAccess, searchPrincipals);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/permissions/{resourceType}/roles
|
* GET /api/permissions/{resourceType}/roles
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,16 @@ async function loadDefaultInterface(config, configDefaults, roleName = SystemRol
|
||||||
runCode: interfaceConfig?.runCode ?? defaults.runCode,
|
runCode: interfaceConfig?.runCode ?? defaults.runCode,
|
||||||
webSearch: interfaceConfig?.webSearch ?? defaults.webSearch,
|
webSearch: interfaceConfig?.webSearch ?? defaults.webSearch,
|
||||||
customWelcome: interfaceConfig?.customWelcome ?? defaults.customWelcome,
|
customWelcome: interfaceConfig?.customWelcome ?? defaults.customWelcome,
|
||||||
|
peoplePicker: {
|
||||||
|
admin: {
|
||||||
|
users: interfaceConfig?.peoplePicker?.admin?.users ?? defaults.peoplePicker.admin.users,
|
||||||
|
groups: interfaceConfig?.peoplePicker?.admin?.groups ?? defaults.peoplePicker.admin.groups,
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
users: interfaceConfig?.peoplePicker?.user?.users ?? defaults.peoplePicker.user.users,
|
||||||
|
groups: interfaceConfig?.peoplePicker?.user?.groups ?? defaults.peoplePicker.user.groups,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await updateAccessPermissions(roleName, {
|
await updateAccessPermissions(roleName, {
|
||||||
|
|
@ -65,6 +75,10 @@ async function loadDefaultInterface(config, configDefaults, roleName = SystemRol
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_USERS]: loadedInterface.peoplePicker.user?.users,
|
||||||
|
[Permissions.VIEW_GROUPS]: loadedInterface.peoplePicker.user?.groups,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
await updateAccessPermissions(SystemRoles.ADMIN, {
|
await updateAccessPermissions(SystemRoles.ADMIN, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: loadedInterface.prompts },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: loadedInterface.prompts },
|
||||||
|
|
@ -78,6 +92,10 @@ async function loadDefaultInterface(config, configDefaults, roleName = SystemRol
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_USERS]: loadedInterface.peoplePicker.admin?.users,
|
||||||
|
[Permissions.VIEW_GROUPS]: loadedInterface.peoplePicker.admin?.groups,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useMemo } from 'react';
|
||||||
import { Share2Icon, Users, Loader, Shield, Link, CopyCheck } from 'lucide-react';
|
import { Share2Icon, Users, Loader, Shield, Link, CopyCheck } from 'lucide-react';
|
||||||
import { ACCESS_ROLE_IDS } from 'librechat-data-provider';
|
import { ACCESS_ROLE_IDS, PermissionTypes, Permissions } from 'librechat-data-provider';
|
||||||
import type { TPrincipal } from 'librechat-data-provider';
|
import type { TPrincipal } from 'librechat-data-provider';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from '~/components/ui';
|
} from '~/components/ui';
|
||||||
import { cn, removeFocusOutlines } from '~/utils';
|
import { cn, removeFocusOutlines } from '~/utils';
|
||||||
import { useToastContext } from '~/Providers';
|
import { useToastContext } from '~/Providers';
|
||||||
import { useLocalize, useCopyToClipboard } from '~/hooks';
|
import { useLocalize, useCopyToClipboard, useHasAccess } from '~/hooks';
|
||||||
import {
|
import {
|
||||||
useGetResourcePermissionsQuery,
|
useGetResourcePermissionsQuery,
|
||||||
useUpdateResourcePermissionsMutation,
|
useUpdateResourcePermissionsMutation,
|
||||||
|
|
@ -39,6 +39,29 @@ export default function GrantAccessDialog({
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { showToast } = useToastContext();
|
const { showToast } = useToastContext();
|
||||||
|
|
||||||
|
// Check if user has permission to access people picker
|
||||||
|
const canViewUsers = useHasAccess({
|
||||||
|
permissionType: PermissionTypes.PEOPLE_PICKER,
|
||||||
|
permission: Permissions.VIEW_USERS,
|
||||||
|
});
|
||||||
|
const canViewGroups = useHasAccess({
|
||||||
|
permissionType: PermissionTypes.PEOPLE_PICKER,
|
||||||
|
permission: Permissions.VIEW_GROUPS,
|
||||||
|
});
|
||||||
|
const hasPeoplePickerAccess = canViewUsers || canViewGroups;
|
||||||
|
|
||||||
|
// Determine type filter based on permissions
|
||||||
|
const peoplePickerTypeFilter = useMemo(() => {
|
||||||
|
if (canViewUsers && canViewGroups) {
|
||||||
|
return null; // Both types allowed
|
||||||
|
} else if (canViewUsers) {
|
||||||
|
return 'user' as const;
|
||||||
|
} else if (canViewGroups) {
|
||||||
|
return 'group' as const;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}, [canViewUsers, canViewGroups]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: permissionsData,
|
data: permissionsData,
|
||||||
// isLoading: isLoadingPermissions,
|
// isLoading: isLoadingPermissions,
|
||||||
|
|
@ -178,9 +201,12 @@ export default function GrantAccessDialog({
|
||||||
</OGDialogTitle>
|
</OGDialogTitle>
|
||||||
|
|
||||||
<div className="space-y-6 p-2">
|
<div className="space-y-6 p-2">
|
||||||
|
{hasPeoplePickerAccess && (
|
||||||
|
<>
|
||||||
<PeoplePicker
|
<PeoplePicker
|
||||||
onSelectionChange={setNewShares}
|
onSelectionChange={setNewShares}
|
||||||
placeholder={localize('com_ui_search_people_placeholder')}
|
placeholder={localize('com_ui_search_people_placeholder')}
|
||||||
|
typeFilter={peoplePickerTypeFilter}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
|
|
@ -198,6 +224,8 @@ export default function GrantAccessDialog({
|
||||||
onRoleChange={setDefaultPermissionId}
|
onRoleChange={setDefaultPermissionId}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<PublicSharingToggle
|
<PublicSharingToggle
|
||||||
isPublic={isPublic}
|
isPublic={isPublic}
|
||||||
publicRole={publicRole}
|
publicRole={publicRole}
|
||||||
|
|
@ -207,11 +235,13 @@ export default function GrantAccessDialog({
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-between border-t pt-4">
|
<div className="flex justify-between border-t pt-4">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
|
{hasPeoplePickerAccess && (
|
||||||
<ManagePermissionsDialog
|
<ManagePermissionsDialog
|
||||||
agentDbId={agentDbId}
|
agentDbId={agentDbId}
|
||||||
agentName={agentName}
|
agentName={agentName}
|
||||||
resourceType={resourceType}
|
resourceType={resourceType}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
{agentId && (
|
{agentId && (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,14 @@ interface PeoplePickerProps {
|
||||||
onSelectionChange: (principals: TPrincipal[]) => void;
|
onSelectionChange: (principals: TPrincipal[]) => void;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
typeFilter?: 'user' | 'group' | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PeoplePicker({
|
export default function PeoplePicker({
|
||||||
onSelectionChange,
|
onSelectionChange,
|
||||||
placeholder,
|
placeholder,
|
||||||
className = '',
|
className = '',
|
||||||
|
typeFilter = null,
|
||||||
}: PeoplePickerProps) {
|
}: PeoplePickerProps) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
|
|
@ -26,8 +28,9 @@ export default function PeoplePicker({
|
||||||
() => ({
|
() => ({
|
||||||
q: searchQuery,
|
q: searchQuery,
|
||||||
limit: 30,
|
limit: 30,
|
||||||
|
...(typeFilter && { type: typeFilter }),
|
||||||
}),
|
}),
|
||||||
[searchQuery],
|
[searchQuery, typeFilter],
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ export const generateCheckAccess = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[${permissionType}] Forbidden: "${req.originalUrl}" - Insufficient permissions for User ${req.user?.id}: ${permissions.join(', ')}`,
|
`[${permissionType}] Forbidden: "${req.originalUrl}" - Insufficient permissions for User ${(req.user as IUser)?.id}: ${permissions.join(', ')}`,
|
||||||
);
|
);
|
||||||
return res.status(403).json({ message: 'Forbidden: Insufficient permissions' });
|
return res.status(403).json({ message: 'Forbidden: Insufficient permissions' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ const mcpServersSchema = z.object({
|
||||||
|
|
||||||
export type TMcpServersConfig = z.infer<typeof mcpServersSchema>;
|
export type TMcpServersConfig = z.infer<typeof mcpServersSchema>;
|
||||||
|
|
||||||
export const intefaceSchema = z
|
export const interfaceSchema = z
|
||||||
.object({
|
.object({
|
||||||
privacyPolicy: z
|
privacyPolicy: z
|
||||||
.object({
|
.object({
|
||||||
|
|
@ -513,6 +513,22 @@ export const intefaceSchema = z
|
||||||
temporaryChatRetention: z.number().min(1).max(8760).optional(),
|
temporaryChatRetention: z.number().min(1).max(8760).optional(),
|
||||||
runCode: z.boolean().optional(),
|
runCode: z.boolean().optional(),
|
||||||
webSearch: z.boolean().optional(),
|
webSearch: z.boolean().optional(),
|
||||||
|
peoplePicker: z
|
||||||
|
.object({
|
||||||
|
admin: z
|
||||||
|
.object({
|
||||||
|
users: z.boolean().optional(),
|
||||||
|
groups: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
user: z
|
||||||
|
.object({
|
||||||
|
users: z.boolean().optional(),
|
||||||
|
groups: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
})
|
})
|
||||||
.default({
|
.default({
|
||||||
endpointsMenu: true,
|
endpointsMenu: true,
|
||||||
|
|
@ -528,9 +544,19 @@ export const intefaceSchema = z
|
||||||
temporaryChat: true,
|
temporaryChat: true,
|
||||||
runCode: true,
|
runCode: true,
|
||||||
webSearch: true,
|
webSearch: true,
|
||||||
|
peoplePicker: {
|
||||||
|
admin: {
|
||||||
|
users: true,
|
||||||
|
groups: true,
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
users: false,
|
||||||
|
groups: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TInterfaceConfig = z.infer<typeof intefaceSchema>;
|
export type TInterfaceConfig = z.infer<typeof interfaceSchema>;
|
||||||
export type TBalanceConfig = z.infer<typeof balanceSchema>;
|
export type TBalanceConfig = z.infer<typeof balanceSchema>;
|
||||||
|
|
||||||
export const turnstileOptionsSchema = z
|
export const turnstileOptionsSchema = z
|
||||||
|
|
@ -748,7 +774,7 @@ export const configSchema = z.object({
|
||||||
includedTools: z.array(z.string()).optional(),
|
includedTools: z.array(z.string()).optional(),
|
||||||
filteredTools: z.array(z.string()).optional(),
|
filteredTools: z.array(z.string()).optional(),
|
||||||
mcpServers: MCPServersSchema.optional(),
|
mcpServers: MCPServersSchema.optional(),
|
||||||
interface: intefaceSchema,
|
interface: interfaceSchema,
|
||||||
turnstile: turnstileSchema.optional(),
|
turnstile: turnstileSchema.optional(),
|
||||||
fileStrategy: fileSourceSchema.default(FileSources.local),
|
fileStrategy: fileSourceSchema.default(FileSources.local),
|
||||||
actions: z
|
actions: z
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ export enum PermissionTypes {
|
||||||
* Type for using the "Web Search" feature
|
* Type for using the "Web Search" feature
|
||||||
*/
|
*/
|
||||||
WEB_SEARCH = 'WEB_SEARCH',
|
WEB_SEARCH = 'WEB_SEARCH',
|
||||||
|
/**
|
||||||
|
* Type for People Picker Permissions
|
||||||
|
*/
|
||||||
|
PEOPLE_PICKER = 'PEOPLE_PICKER',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,6 +55,8 @@ export enum Permissions {
|
||||||
SHARE = 'SHARE',
|
SHARE = 'SHARE',
|
||||||
/** Can disable if desired */
|
/** Can disable if desired */
|
||||||
OPT_OUT = 'OPT_OUT',
|
OPT_OUT = 'OPT_OUT',
|
||||||
|
VIEW_USERS = 'VIEW_USERS',
|
||||||
|
VIEW_GROUPS = 'VIEW_GROUPS',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const promptPermissionsSchema = z.object({
|
export const promptPermissionsSchema = z.object({
|
||||||
|
|
@ -103,6 +109,12 @@ export const webSearchPermissionsSchema = z.object({
|
||||||
});
|
});
|
||||||
export type TWebSearchPermissions = z.infer<typeof webSearchPermissionsSchema>;
|
export type TWebSearchPermissions = z.infer<typeof webSearchPermissionsSchema>;
|
||||||
|
|
||||||
|
export const peoplePickerPermissionsSchema = z.object({
|
||||||
|
[Permissions.VIEW_USERS]: z.boolean().default(true),
|
||||||
|
[Permissions.VIEW_GROUPS]: z.boolean().default(true),
|
||||||
|
});
|
||||||
|
export type TPeoplePickerPermissions = z.infer<typeof peoplePickerPermissionsSchema>;
|
||||||
|
|
||||||
// Define a single permissions schema that holds all permission types.
|
// Define a single permissions schema that holds all permission types.
|
||||||
export const permissionsSchema = z.object({
|
export const permissionsSchema = z.object({
|
||||||
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
||||||
|
|
@ -113,4 +125,5 @@ export const permissionsSchema = z.object({
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: temporaryChatPermissionsSchema,
|
[PermissionTypes.TEMPORARY_CHAT]: temporaryChatPermissionsSchema,
|
||||||
[PermissionTypes.RUN_CODE]: runCodePermissionsSchema,
|
[PermissionTypes.RUN_CODE]: runCodePermissionsSchema,
|
||||||
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema,
|
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema,
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: peoplePickerPermissionsSchema,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
bookmarkPermissionsSchema,
|
bookmarkPermissionsSchema,
|
||||||
multiConvoPermissionsSchema,
|
multiConvoPermissionsSchema,
|
||||||
temporaryChatPermissionsSchema,
|
temporaryChatPermissionsSchema,
|
||||||
|
peoplePickerPermissionsSchema,
|
||||||
} from './permissions';
|
} from './permissions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,6 +75,10 @@ const defaultRolesSchema = z.object({
|
||||||
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema.extend({
|
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema.extend({
|
||||||
[Permissions.USE]: z.boolean().default(true),
|
[Permissions.USE]: z.boolean().default(true),
|
||||||
}),
|
}),
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: peoplePickerPermissionsSchema.extend({
|
||||||
|
[Permissions.VIEW_USERS]: z.boolean().default(true),
|
||||||
|
[Permissions.VIEW_GROUPS]: z.boolean().default(true),
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
[SystemRoles.USER]: roleSchema.extend({
|
[SystemRoles.USER]: roleSchema.extend({
|
||||||
|
|
@ -118,6 +123,10 @@ export const roleDefaults = defaultRolesSchema.parse({
|
||||||
[PermissionTypes.WEB_SEARCH]: {
|
[PermissionTypes.WEB_SEARCH]: {
|
||||||
[Permissions.USE]: true,
|
[Permissions.USE]: true,
|
||||||
},
|
},
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_USERS]: true,
|
||||||
|
[Permissions.VIEW_GROUPS]: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[SystemRoles.USER]: {
|
[SystemRoles.USER]: {
|
||||||
|
|
@ -131,6 +140,10 @@ export const roleDefaults = defaultRolesSchema.parse({
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: {},
|
[PermissionTypes.TEMPORARY_CHAT]: {},
|
||||||
[PermissionTypes.RUN_CODE]: {},
|
[PermissionTypes.RUN_CODE]: {},
|
||||||
[PermissionTypes.WEB_SEARCH]: {},
|
[PermissionTypes.WEB_SEARCH]: {},
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_USERS]: false,
|
||||||
|
[Permissions.VIEW_GROUPS]: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ const rolePermissionsSchema = new Schema(
|
||||||
[PermissionTypes.WEB_SEARCH]: {
|
[PermissionTypes.WEB_SEARCH]: {
|
||||||
[Permissions.USE]: { type: Boolean, default: true },
|
[Permissions.USE]: { type: Boolean, default: true },
|
||||||
},
|
},
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_USERS]: { type: Boolean, default: false },
|
||||||
|
[Permissions.VIEW_GROUPS]: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ _id: false },
|
{ _id: false },
|
||||||
);
|
);
|
||||||
|
|
@ -67,6 +71,10 @@ const roleSchema: Schema<IRole> = new Schema({
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_USERS]: false,
|
||||||
|
[Permissions.VIEW_GROUPS]: false,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,9 @@ export interface IRole extends Document {
|
||||||
[PermissionTypes.WEB_SEARCH]?: {
|
[PermissionTypes.WEB_SEARCH]?: {
|
||||||
[Permissions.USE]?: boolean;
|
[Permissions.USE]?: boolean;
|
||||||
};
|
};
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]?: {
|
||||||
|
[Permissions.VIEW_USERS]?: boolean;
|
||||||
|
[Permissions.VIEW_GROUPS]?: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue