Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/apps.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorF. Kooman <fkooman@tuxed.net>2012-10-27 20:13:37 +0400
committerF. Kooman <fkooman@tuxed.net>2012-10-27 20:13:37 +0400
commitb94273618fdf3e99d3949c8d3b1ef25fcd99996b (patch)
tree616e1a3e15ef6955c70392d92ac0d124f2d1ba25 /user_oauth
parenta9ae9d01d1c60134e00d88f1cf8d107cd5522a4f (diff)
most stuff should be included now, just testing and integration stuff
Diffstat (limited to 'user_oauth')
-rw-r--r--user_oauth/AbstractBearer.php33
-rw-r--r--user_oauth/appinfo/app.php8
-rw-r--r--user_oauth/index.php5
-rw-r--r--user_oauth/settings.php2
-rw-r--r--user_oauth/templates/main.php3
-rw-r--r--user_oauth/templates/settings.php4
-rw-r--r--user_oauth/webdav.php49
7 files changed, 85 insertions, 19 deletions
diff --git a/user_oauth/AbstractBearer.php b/user_oauth/AbstractBearer.php
new file mode 100644
index 000000000..37570668b
--- /dev/null
+++ b/user_oauth/AbstractBearer.php
@@ -0,0 +1,33 @@
+<?php
+
+require_once 'lib/RemoteResourceServer.php';
+
+abstract class Sabre_DAV_Auth_Backend_AbstractBearer implements Sabre_DAV_Auth_IBackend {
+
+ protected $currentUser;
+ protected $tokenInfoEndpoint;
+
+ public function __construct($tokenInfoEndpoint) {
+ $this->tokenInfoEndpoint = $tokenInfoEndpoint;
+ }
+
+ public function getCurrentUser() {
+ return $this->currentUser;
+ }
+
+ public function authenticate(Sabre_DAV_Server $server, $realm) {
+ $config = array(
+ "tokenInfoEndpoint" => $this->tokenInfoEndpoint
+ );
+
+ $rs = new RemoteResourceServer($config);
+ $rs->verifyRequest();
+
+ $attributes = $rs->getAttributes();
+
+ $this->currentUser = $attributes["uid"][0];
+ return true;
+ }
+
+}
+
diff --git a/user_oauth/appinfo/app.php b/user_oauth/appinfo/app.php
index 873d67a0e..0e028d088 100644
--- a/user_oauth/appinfo/app.php
+++ b/user_oauth/appinfo/app.php
@@ -24,11 +24,3 @@
*/
OCP\App::registerAdmin( 'user_oauth', 'settings' );
-
-OCP\App::addNavigationEntry( array(
- 'id' => 'user_oauthe',
- 'order' => 74,
- 'href' => OCP\Util::linkTo( 'user_oauth', 'index.php' ),
- 'icon' => OCP\Util::imagePath( 'user_oauth', 'example.png' ),
- 'name' => 'OAuth'
-));
diff --git a/user_oauth/index.php b/user_oauth/index.php
index 4b8897724..07faa09e0 100644
--- a/user_oauth/index.php
+++ b/user_oauth/index.php
@@ -24,8 +24,3 @@
// Check if we are a user
OCP\User::checkLoggedIn();
-//$somesetting = OCP\Config::getSystemValue( "somesetting", '' );
-OCP\App::setActiveNavigationEntry( 'files_oauth' );
-$tmpl = new OCP\Template( 'files_oauth', 'main', 'user' );
-//$tmpl->assign( 'somesetting', $somesetting );
-$tmpl->printPage();
diff --git a/user_oauth/settings.php b/user_oauth/settings.php
index bee3b407d..298bab458 100644
--- a/user_oauth/settings.php
+++ b/user_oauth/settings.php
@@ -6,6 +6,6 @@ OCP\Util::addScript( "user_oauth", "admin" );
$tmpl = new OCP\Template( 'user_oauth', 'settings');
-$tmpl->assign('url', OCP\Config::getSystemValue( "somesetting", '' ));
+$tmpl->assign('tokenInfoEndpoint', OCP\Config::getSystemValue( "tokenInfoEndpoint", 'http://localhost/oauth/php-oauth/tokeninfo.php' ));
return $tmpl->fetchPage();
diff --git a/user_oauth/templates/main.php b/user_oauth/templates/main.php
deleted file mode 100644
index 735866ae0..000000000
--- a/user_oauth/templates/main.php
+++ /dev/null
@@ -1,3 +0,0 @@
-<h1>This is the OAuth</h1>
-
-<?php echo $l->t('Some Setting');?>: "<?php echo $_['somesetting']; ?>"
diff --git a/user_oauth/templates/settings.php b/user_oauth/templates/settings.php
index ff172b460..80f022bed 100644
--- a/user_oauth/templates/settings.php
+++ b/user_oauth/templates/settings.php
@@ -1,8 +1,8 @@
<form id="user_oauth">
<fieldset class="personalblock">
<strong>OAuth</strong><br />
- <input type="text" name="somesetting" id="somesetting" value="<?php echo $_['url']; ?>" placeholder="<?php echo $l->t('Some Setting');?>" />
+ <input type="text" name="tokenInfoEndpoint" id="tokenInfoEndpoint" value="<?php echo $_['tokenInfoEndpoint']; ?>" placeholder="<?php echo $l->t('Token Info Endpoint');?>" />
<br />
- <span class="msg"></span>
+ <span class="msg">This is the OAuth AS Token Info Endpoint.</span>
</fieldset>
</form>
diff --git a/user_oauth/webdav.php b/user_oauth/webdav.php
new file mode 100644
index 000000000..ed23faf1c
--- /dev/null
+++ b/user_oauth/webdav.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @author Frank Karlitschek
+ * @author Jakob Sack
+ * @copyright 2012 Frank Karlitschek frank@owncloud.org
+ * @copyright 2011 Jakob Sack kde@jakobsack.de
+ *
+ * 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/>.
+ *
+ */
+
+// only need filesystem apps
+$RUNTIME_APPTYPES=array('filesystem','authentication');
+require_once '../lib/base.php';
+
+$tokenInfoEndpoint = \OC_Config::getValue( "tokenInfoEndpoint", "http://localhost/oauth/php-oauth/tokeninfo.php" );
+
+// Backends
+$authBackend = new OC_Connector_Sabre_Auth_Bearer($tokenInfoEndpoint);
+$lockBackend = new OC_Connector_Sabre_Locks();
+
+// Create ownCloud Dir
+$publicDir = new OC_Connector_Sabre_Directory('');
+
+// Fire up server
+$server = new Sabre_DAV_Server($publicDir);
+$server->setBaseUri(OC::$WEBROOT. '/files/webdav.php');
+
+// Load plugins
+$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud'));
+$server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend));
+$server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload
+
+// And off we go!
+$server->exec();