Skip to content

Commit

Permalink
fix: Proper 401 response for invalid tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Nov 29, 2024
1 parent 471b021 commit d96be3d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Middleware/WOPIMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IConfig;
use OCP\IRequest;
Expand Down Expand Up @@ -78,7 +79,11 @@ public function beforeController($controller, $methodName) {

public function afterException($controller, $methodName, \Exception $exception): Response {
if ($exception instanceof NotPermittedException && $controller instanceof WopiController) {
return new JSONResponse([], Http::STATUS_FORBIDDEN);
return new JSONResponse([], Http::STATUS_UNAUTHORIZED);
}

if ($exception instanceof NotFoundException && $controller instanceof WopiController) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}

if ($controller instanceof WopiController) {
Expand Down

0 comments on commit d96be3d

Please sign in to comment.