Skip to content

Commit

Permalink
Allow CSRF on CORS routes
Browse files Browse the repository at this point in the history
Co-authored-by: Julius Härtl <[email protected]>
Co-authored-by: Andreas Brinner <[email protected]>
Signed-off-by: Jonas Rittershofer <[email protected]>
  • Loading branch information
3 people authored and nickvergessen committed Sep 21, 2022
1 parent 48def62 commit c8b7a23
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 c8b7a23

Please sign in to comment.