Skip to content

Commit d306a09

Browse files
authored
Merge pull request #60555 from nextcloud/backport/60543/stable33
[stable33] fix: only allow full admins to create 'token needed' webhooks
2 parents 8ce133e + e3b4ea6 commit d306a09

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

apps/webhook_listeners/lib/Controller/WebhooksController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
use OCP\AppFramework\OCS\OCSForbiddenException;
2727
use OCP\AppFramework\OCS\OCSNotFoundException;
2828
use OCP\AppFramework\OCSController;
29+
use OCP\IGroupManager;
2930
use OCP\IRequest;
3031
use OCP\ISession;
32+
use OCP\IUserSession;
3133
use Psr\Log\LoggerInterface;
3234

3335
/**
@@ -42,6 +44,8 @@ public function __construct(
4244
private WebhookListenerMapper $mapper,
4345
private ?string $userId,
4446
private ISession $session,
47+
private IUserSession $userSession,
48+
private IGroupManager $groupManager,
4549
) {
4650
parent::__construct($appName, $request);
4751
}
@@ -150,6 +154,12 @@ public function create(
150154
} catch (\ValueError $e) {
151155
throw new OCSBadRequestException('This auth method does not exist');
152156
}
157+
158+
$user = $this->userSession->getUser();
159+
if (!$user || !$this->groupManager->isAdmin($user->getUID())) {
160+
$tokenNeeded = null;
161+
}
162+
153163
try {
154164
$webhookListener = $this->mapper->addWebhookListener(
155165
$appId,

0 commit comments

Comments
 (0)