summaryrefslogtreecommitdiffstats
path: root/core/ajax
diff options
context:
space:
mode:
authorChristian Reiner <arkascha@balder.site>2012-09-28 13:30:44 +0200
committerChristian Reiner <arkascha@balder.site>2012-09-28 13:30:44 +0200
commit743826bbf34b82b92371cf7e9b0478897188c046 (patch)
tree4bef4f89d23e82698e3a2bdca39841e1ce3e737a /core/ajax
parenta7292e897a70a2f7e79f61396d4888cb694f0860 (diff)
downloadnextcloud-server-743826bbf34b82b92371cf7e9b0478897188c046.tar.gz
nextcloud-server-743826bbf34b82b92371cf7e9b0478897188c046.zip
Reimplementation of CSRF protection including autorefresh
Diffstat (limited to 'core/ajax')
-rw-r--r--core/ajax/requesttoken.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/ajax/requesttoken.php b/core/ajax/requesttoken.php
new file mode 100644
index 00000000000..96d5402e621
--- /dev/null
+++ b/core/ajax/requesttoken.php
@@ -0,0 +1,41 @@
+<?php
+/**
+* ownCloud
+* @author Christian Reiner
+* @copyright 2011-2012 Christian Reiner <foss@christian-reiner.info>
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the license, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library.
+* If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * @file core/ajax/requesttoken.php
+ * @brief Ajax method to retrieve a fresh request protection token for ajax calls
+ * @return json: success/error state indicator including a fresh request token
+ * @author Christian Reiner
+ */
+require_once '../../lib/base.php';
+
+// don't load apps or filesystem for this task
+$RUNTIME_NOAPPS = TRUE;
+$RUNTIME_NOSETUPFS = TRUE;
+
+// Sanity checks
+// using OCP\JSON::callCheck() below protects the token refreshing itself.
+//OCP\JSON::callCheck ( );
+OCP\JSON::checkLoggedIn ( );
+// hand out a fresh token
+OCP\JSON::success ( array ( 'token' => OCP\Util::callRegister() ) );
+?>