-
Notifications
You must be signed in to change notification settings - Fork 13.9k
chore: UserAutoComplete for incoming integrations form #41260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
6f3c0f4
1509cd9
8fa0f56
10e91e2
b7dfdc6
49294b3
8d1f590
996f632
7501165
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,8 @@ import { | |
| FieldRow, | ||
| FieldHint, | ||
| } from '@rocket.chat/fuselage'; | ||
| import { useAbsoluteUrl } from '@rocket.chat/ui-contexts'; | ||
| import { UserAutoComplete } from '@rocket.chat/ui-client'; | ||
| import { useAbsoluteUrl, useGetPermission } from '@rocket.chat/ui-contexts'; | ||
| import DOMPurify from 'dompurify'; | ||
| import { useId, useMemo } from 'react'; | ||
| import { Controller, useFormContext } from 'react-hook-form'; | ||
|
|
@@ -33,6 +34,7 @@ export type IncomingWebhookFormProps = { webhookData?: Serialized<IIncomingInteg | |
| const IncomingWebhookForm = ({ webhookData }: IncomingWebhookFormProps) => { | ||
| const { t } = useTranslation(); | ||
| const absoluteUrl = useAbsoluteUrl(); | ||
| const permission = useGetPermission('message-impersonate'); | ||
|
|
||
| const { | ||
| control, | ||
|
|
@@ -202,10 +204,10 @@ const IncomingWebhookForm = ({ webhookData }: IncomingWebhookFormProps) => { | |
| control={control} | ||
| rules={{ required: t('Required_field', { field: t('Post_as') }) }} | ||
| render={({ field }) => ( | ||
| <TextInput | ||
| <UserAutoComplete | ||
| id={usernameField} | ||
| {...field} | ||
| endAddon={<Icon name='user' size='x20' />} | ||
| conditions={permission?.roles ? { roles: { $in: permission.roles } } : undefined} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Users granted only incoming-integration management get a 400 from Prompt for AI agents |
||
| aria-describedby={`${usernameField}-hint-1 ${usernameField}-hint-2 ${usernameField}-error`} | ||
| aria-required={true} | ||
| aria-invalid={Boolean(errors?.username)} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { IPermission } from '@rocket.chat/core-typings'; | ||
| import { useContext } from 'react'; | ||
|
|
||
| import { AuthorizationContext } from '../AuthorizationContext'; | ||
|
|
||
| export const useGetPermission = (permission: string): IPermission | undefined => { | ||
| const { getPermission } = useContext(AuthorizationContext); | ||
|
|
||
| return getPermission(permission); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Fail closed when the permission lookup is unavailable.
When
permissionisundefined,conditionsis alsoundefined;UserAutoCompletethen sends an empty conditions object and returns an unrestricted user list. That defeats themessage-impersonatefilter and can expose/select users who should not be eligible. Use an empty role set or gate the field until permission metadata is available, and keep server-side authorization authoritative.🤖 Prompt for AI Agents