mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: only allow full admins to create 'token needed' webhooks
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
a2eb38fefc
commit
910d13ce62
1 changed files with 10 additions and 0 deletions
|
|
@ -26,8 +26,10 @@ use OCP\AppFramework\OCS\OCSException;
|
|||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||
use OCP\AppFramework\OCSController;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IRequest;
|
||||
use OCP\ISession;
|
||||
use OCP\IUserSession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -42,6 +44,8 @@ class WebhooksController extends OCSController {
|
|||
private WebhookListenerMapper $mapper,
|
||||
private ?string $userId,
|
||||
private ISession $session,
|
||||
private IUserSession $userSession,
|
||||
private IGroupManager $groupManager,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
|
@ -144,6 +148,12 @@ class WebhooksController extends OCSController {
|
|||
} catch (\ValueError $e) {
|
||||
throw new OCSBadRequestException('This auth method does not exist');
|
||||
}
|
||||
|
||||
$user = $this->userSession->getUser();
|
||||
if (!$user || !$this->groupManager->isAdmin($user->getUID())) {
|
||||
$tokenNeeded = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$webhookListener = $this->mapper->addWebhookListener(
|
||||
$appId,
|
||||
|
|
|
|||
Loading…
Reference in a new issue