Non-admin agents could delete an account's Linear, Notion, or Shopify integration through the dedicated integration endpoints, which — unlike the generic hooks endpoint — never checked the caller's role. This restores the intended admin-only boundary for removing an integration. ## Closes - https://linear.app/chatwoot/issue/CW-7383 - https://linear.app/chatwoot/issue/CW-7384 - https://linear.app/chatwoot/issue/CW-7189 ## How to reproduce As a non-admin **agent**, `DELETE /api/v1/accounts/:id/integrations/{linear,notion,shopify}` returned `200` and removed the account-wide integration. After this change it returns `401` and the integration is preserved; administrators can still remove it. ## What changed - Route integration-hook deletion through `HookPolicy` (admin-only) via a shared `Integrations::BaseController`, matching the generic hooks controller. Co-authored-by: Vishnu Narayanan <iamwishnu@gmail.com>
10 lines
344 B
Ruby
10 lines
344 B
Ruby
class Api::V1::Accounts::Integrations::BaseController < Api::V1::Accounts::BaseController
|
|
private
|
|
|
|
# Managing an integration hook (create/update/destroy) is admin-only, enforced via HookPolicy.
|
|
# Subclasses opt in per action with `before_action :check_authorization, only: [...]`.
|
|
def check_authorization
|
|
authorize(:hook)
|
|
end
|
|
end
|