1515use OCP \Files \ForbiddenException ;
1616use OCP \Files \IRootFolder ;
1717use OCP \Files \Storage \IStorage ;
18+ use OCP \IRequest ;
1819use OCP \IUserSession ;
1920use OCP \Server ;
2021
@@ -24,6 +25,7 @@ class SecureViewWrapper extends Wrapper {
2425 private IRootFolder $ rootFolder ;
2526 private IUserSession $ userSession ;
2627 private SecureViewService $ secureViewService ;
28+ private IRequest $ request ;
2729
2830 private string $ mountPoint ;
2931
@@ -35,6 +37,7 @@ public function __construct(array $parameters) {
3537 $ this ->rootFolder = Server::get (IRootFolder::class);
3638 $ this ->userSession = Server::get (IUserSession::class);
3739 $ this ->secureViewService = Server::get (SecureViewService::class);
40+ $ this ->request = Server::get (IRequest::class);
3841
3942 $ this ->mountPoint = $ parameters ['mountPoint ' ];
4043 }
@@ -85,7 +88,12 @@ public function rename(string $source, string $target): bool {
8588 * @throws ForbiddenException
8689 */
8790 private function checkFileAccess (string $ path ): void {
88- if (!$ this ->wopiMiddleware ->isWOPIRequest () && $ this ->secureViewService ->shouldSecure ($ path , $ this , false )) {
91+ // Only block direct client-facing downloads (GET requests). Server-side operations
92+ // such as template creation and background jobs are non-GET or have no HTTP context
93+ // and must not be blocked even when secure view applies.
94+ if (!$ this ->wopiMiddleware ->isWOPIRequest ()
95+ && $ this ->request ->getMethod () === 'GET '
96+ && $ this ->secureViewService ->shouldSecure ($ path , $ this , false )) {
8997 throw new ForbiddenException ('Download blocked due the secure view policy ' , false );
9098 }
9199 }
0 commit comments