Skip to content

Commit ae8afc5

Browse files
committed
fix(webhook-listeners): revert admin check and document delegation behaviour
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
1 parent 7826ce0 commit ae8afc5

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

‎apps/webhook_listeners/lib/Controller/WebhooksController.php‎

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

3533
/**
@@ -44,8 +42,6 @@ public function __construct(
4442
private WebhookListenerMapper $mapper,
4543
private ?string $userId,
4644
private ISession $session,
47-
private IUserSession $userSession,
48-
private IGroupManager $groupManager,
4945
) {
5046
parent::__construct($appName, $request);
5147
}
@@ -154,12 +150,6 @@ public function create(
154150
} catch (\ValueError $e) {
155151
throw new OCSBadRequestException('This auth method does not exist');
156152
}
157-
158-
$user = $this->userSession->getUser();
159-
if (!$user || !$this->groupManager->isAdmin($user->getUID())) {
160-
$tokenNeeded = null;
161-
}
162-
163153
try {
164154
$webhookListener = $this->mapper->addWebhookListener(
165155
$appId,

‎apps/webhook_listeners/lib/Service/TokenService.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function __construct(
6363
* ]
6464
* Created auth tokens are valid for 1 hour.
6565
*
66+
* With this, admin tokens can be created. Therefore, the admin delegation for webhooks is considered a full admin role. This is by design.
67+
*
6668
* @param WebhookListener $webhookListener
6769
* @param ?string $triggerUserId the user that triggered the webhook call
6870
* @return array{

‎apps/webhook_listeners/lib/Settings/Admin.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* Empty settings class, used only for admin delegation for now as there is no UI
18+
* ATTENTION this admin delegation can create tokens with full admin rights and is therefore considered as a full admin role
19+
*
1820
*/
1921
class Admin implements IDelegatedSettings {
2022
/**
@@ -38,7 +40,7 @@ public function getPriority(): int {
3840
#[\Override]
3941
public function getName(): ?string {
4042
/* Use section name alone */
41-
return null;
43+
return 'Attention: can create tokens with full admin rights';
4244
}
4345

4446
#[\Override]

0 commit comments

Comments
 (0)