Skip to content

Commit

Permalink
Merge pull request #31807 from nextcloud/fix/cors_csrf
Browse files Browse the repository at this point in the history
Accept CSRF on CORS routes
  • Loading branch information
nickvergessen authored Sep 21, 2022
2 parents 48def62 + c8b7a23 commit d0ead94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function beforeController($controller, $methodName) {
$user = array_key_exists('PHP_AUTH_USER', $this->request->server) ? $this->request->server['PHP_AUTH_USER'] : null;
$pass = array_key_exists('PHP_AUTH_PW', $this->request->server) ? $this->request->server['PHP_AUTH_PW'] : null;

// Allow to use the current session if a CSRF token is provided
if ($this->request->passesCSRFCheck()) {
return;
}
$this->session->logout();
try {
if ($user === null || $pass === null || !$this->session->logClientIn($user, $pass, $this->request, $this->throttler)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/public/AppFramework/OCSController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ abstract class OCSController extends ApiController {
public function __construct($appName,
IRequest $request,
$corsMethods = 'PUT, POST, GET, DELETE, PATCH',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept, OCS-APIRequest',
$corsMaxAge = 1728000) {
parent::__construct($appName, $request, $corsMethods,
$corsAllowedHeaders, $corsMaxAge);
Expand Down

0 comments on commit d0ead94

Please sign in to comment.