-
Notifications
You must be signed in to change notification settings - Fork 12k
feat: add Webhook resource to PBAC system with permission enforcement #23614
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
Changes from all commits
34ef528
697d2b3
b9454db
15856b3
d0cb204
93e9cf3
6f40cec
75bf015
704abf0
aae40e1
becf8b5
6a13b0a
2d7a186
8f0771a
95b7c69
4ed0532
01d2546
7d72e1b
0a4f625
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 |
|---|---|---|
|
|
@@ -7,33 +7,27 @@ import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants"; | |
| import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl"; | ||
| import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
| import type { RouterOutputs } from "@calcom/trpc/react"; | ||
| import type { WebhooksByViewer } from "@calcom/trpc/server/routers/viewer/webhook/getByViewer.handler"; | ||
| import classNames from "@calcom/ui/classNames"; | ||
| import { Avatar } from "@calcom/ui/components/avatar"; | ||
| import { EmptyScreen } from "@calcom/ui/components/empty-screen"; | ||
|
|
||
| import { WebhookListItem, CreateNewWebhookButton } from "../components"; | ||
|
|
||
| type WebhooksByViewer = RouterOutputs["viewer"]["webhook"]["getByViewer"]; | ||
|
|
||
| type Props = { | ||
| data: RouterOutputs["viewer"]["webhook"]["getByViewer"]; | ||
| isAdmin: boolean; | ||
| data: WebhooksByViewer; | ||
| }; | ||
|
|
||
| const WebhooksView = ({ data, isAdmin }: Props) => { | ||
| const WebhooksView = ({ data }: Props) => { | ||
| return ( | ||
| <div> | ||
| <WebhooksList webhooksByViewer={data} isAdmin={isAdmin} /> | ||
| <WebhooksList webhooksByViewer={data} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const WebhooksList = ({ | ||
| webhooksByViewer, | ||
| isAdmin, | ||
| }: { | ||
| webhooksByViewer: WebhooksByViewer; | ||
| isAdmin: boolean; | ||
| }) => { | ||
| const WebhooksList = ({ webhooksByViewer }: { webhooksByViewer: WebhooksByViewer }) => { | ||
| const { t } = useLocale(); | ||
| const router = useRouter(); | ||
| const { profiles, webhookGroups } = webhooksByViewer; | ||
|
|
@@ -45,7 +39,7 @@ const WebhooksList = ({ | |
| <SettingsHeader | ||
| title={t("webhooks")} | ||
| description={t("add_webhook_description", { appName: APP_NAME })} | ||
| CTA={webhooksByViewer.webhookGroups.length > 0 ? <CreateNewWebhookButton isAdmin={isAdmin} /> : null} | ||
| CTA={webhooksByViewer.webhookGroups.length > 0 ? <CreateNewWebhookButton /> : null} | ||
| borderInShellHeader={false}> | ||
| {!!webhookGroups.length ? ( | ||
| <div className={classNames("mt-6")}> | ||
|
|
@@ -70,8 +64,11 @@ const WebhooksList = ({ | |
| <WebhookListItem | ||
| key={webhook.id} | ||
| webhook={webhook} | ||
| readOnly={group.metadata?.readOnly ?? false} | ||
| lastItem={group.webhooks.length === index + 1} | ||
| permissions={{ | ||
| canEditWebhook: group?.metadata?.canModify ?? false, | ||
| canDeleteWebhook: group?.metadata?.canDelete ?? false, | ||
| }} | ||
|
Comment on lines
+68
to
+71
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. 💡 Verification agent 🧩 Analysis chainMapping server metadata to UI permissions — ensure backend populates these UI derives canEdit/canDelete from group.metadata.canModify/canDelete. Please confirm list/get handlers set these via PBAC checks. Run: 🏁 Script executed: #!/bin/bash
rg -nP --type=ts -C3 'getByViewer\.handler|list\.handler' packages/trpc/server/routers/viewer/webhook
rg -nP --type=ts -C3 '\bmetadata\b.*(canModify|canDelete)' packages/trpc/server/routers/viewer/webhookLength of output: 2781 🏁 Script executed: #!/bin/bash
rg -n -C3 'metadata' packages/trpc/server/routers/viewer/webhook/*.handler.ts
rg -n -C3 'canModify|canDelete' packages/trpc/server/routers/viewer/webhook/*.handler.tsLength of output: 1731 🏁 Script executed: #!/bin/bash
ls -1 packages/trpc/server/routers/viewerLength of output: 350 🏁 Script executed: #!/bin/bash
sed -n '1,200p' packages/trpc/server/routers/viewer/webhook/list.handler.tsLength of output: 2417 Add canModify/canDelete metadata in list & getByViewer handlers 🤖 Prompt for AI Agents |
||
| onEditWebhook={() => | ||
| router.push(`${WEBAPP_URL}/settings/developer/webhooks/${webhook.id}`) | ||
| } | ||
|
|
@@ -88,7 +85,7 @@ const WebhooksList = ({ | |
| headline={t("create_your_first_webhook")} | ||
| description={t("create_your_first_webhook_description", { appName: APP_NAME })} | ||
| className="mt-6 rounded-b-lg" | ||
| buttonRaw={<CreateNewWebhookButton isAdmin={isAdmin} />} | ||
| buttonRaw={<CreateNewWebhookButton />} | ||
| border={true} | ||
| /> | ||
| )} | ||
|
|
||
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.
need to fix this (leaving a comment for visibility)