diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-01-29 15:02:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 15:02:22 +0100 |
commit | 6d86dcb2654739bac62948c94a076c101b1e637d (patch) | |
tree | 6e729b562a8fd1ed050c0d19175f05aed7adb314 /lib | |
parent | 1d8b90b8d3c8a85104d223b7f1d5693280370774 (diff) | |
parent | 7405dfb5447a324b2f5504b3a540c8d35b0b21cb (diff) | |
download | nextcloud-server-6d86dcb2654739bac62948c94a076c101b1e637d.tar.gz nextcloud-server-6d86dcb2654739bac62948c94a076c101b1e637d.zip |
Merge pull request #7873 from nextcloud/fix_5694
Don't perform CSRF check on OCS routes with Bearer auth
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index 1c049fb3621..f45c8f8726c 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -170,10 +170,16 @@ class SecurityMiddleware extends Middleware { * Only allow the CSRF check to fail on OCS Requests. This kind of * hacks around that we have no full token auth in place yet and we * do want to offer CSRF checks for web requests. + * + * Additionally we allow Bearer authenticated requests to pass on OCS routes. + * This allows oauth apps (e.g. moodle) to use the OCS endpoints */ if(!$this->request->passesCSRFCheck() && !( - $controller instanceof OCSController && - $this->request->getHeader('OCS-APIREQUEST') === 'true')) { + $controller instanceof OCSController && ( + $this->request->getHeader('OCS-APIREQUEST') === 'true' || + strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0 + ) + )) { throw new CrossSiteRequestForgeryException(); } } |