Skip to content
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

Fix webhook execution permissions in cron context #18562

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions front/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
exit(1);
}

// Session needed initialized, but shouldn't be saved
session_abort();
// Cron should not be limited by entity
$_SESSION['glpiactive_entity'] = 0;
$_SESSION['glpiactiveentities'] = getSonsOf('glpi_entities', 0);

if (!isCommandLine()) {
//The advantage of using background-image is that cron is called in a separate
//request and thus does not slow down output of the main page as it would if called
Expand Down
2 changes: 1 addition & 1 deletion src/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ private function getAPIResponse(string $path): ?array
$router->registerAuthMiddleware(new \Glpi\Api\HL\Middleware\InternalAuthMiddleware());
$path = rtrim($path, '/');
$request = new Request('GET', $path);
$response = $router->handleRequest($request);
$response = Session::callAsSystem(static fn () => $router->handleRequest($request));
if ($response->getStatusCode() === 200) {
$body = (string)$response->getBody();
try {
Expand Down
Loading