diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/remoteStorage/ajax/revokeToken.php | 41 | ||||
-rw-r--r-- | apps/remoteStorage/appinfo/app.php | 1 | ||||
-rw-r--r-- | apps/remoteStorage/appinfo/info.xml | 2 | ||||
-rw-r--r-- | apps/remoteStorage/auth.css | 8 | ||||
-rw-r--r-- | apps/remoteStorage/auth.php | 89 | ||||
-rw-r--r-- | apps/remoteStorage/lib_remoteStorage.php | 3 | ||||
-rw-r--r-- | apps/remoteStorage/remoteStorage-big.png | bin | 0 -> 9742 bytes | |||
-rw-r--r-- | apps/remoteStorage/remoteStorage.png | bin | 0 -> 1273 bytes | |||
-rw-r--r-- | apps/remoteStorage/settings.php | 7 |
9 files changed, 121 insertions, 30 deletions
diff --git a/apps/remoteStorage/ajax/revokeToken.php b/apps/remoteStorage/ajax/revokeToken.php new file mode 100644 index 00000000000..ca56cf560ec --- /dev/null +++ b/apps/remoteStorage/ajax/revokeToken.php @@ -0,0 +1,41 @@ +<?php + +/** +* ownCloud +* +* Original: +* @author Frank Karlitschek +* @copyright 2010 Frank Karlitschek karlitschek@kde.org +* +* Adapted: +* @author Michiel de Jong, 2012 +* +* 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/>. +* +*/ + + +// Do not load FS ... +$RUNTIME_NOSETUPFS = true; + +require_once('../../../lib/base.php'); +OC_Util::checkAppEnabled('remoteStorage'); +require_once('Sabre/autoload.php'); +require_once('../lib_remoteStorage.php'); + +ini_set('default_charset', 'UTF-8'); +#ini_set('error_reporting', ''); +@ob_clean(); + +echo OC_remoteStorage::deleteToken(file_get_contents("php://input")); diff --git a/apps/remoteStorage/appinfo/app.php b/apps/remoteStorage/appinfo/app.php index ac1ecde5082..a1fbebc42f5 100644 --- a/apps/remoteStorage/appinfo/app.php +++ b/apps/remoteStorage/appinfo/app.php @@ -3,3 +3,4 @@ OC_App::register( array( 'order' => 10, 'id' => 'remoteStorage', 'name' => 'remoteStorage compatibility' )); +OC_APP::registerPersonal('remoteStorage','settings'); diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml index 1fc146aac73..121587795db 100644 --- a/apps/remoteStorage/appinfo/info.xml +++ b/apps/remoteStorage/appinfo/info.xml @@ -3,7 +3,7 @@ <id>remoteStorage</id> <name>remoteStorage compatibility</name> <description>Enables your users to use ownCloud as their remote storage for unhosted applications.</description> - <version>0.4</version> + <version>0.5</version> <licence>AGPL or MIT</licence> <author>Michiel de Jong</author> <require>2</require> diff --git a/apps/remoteStorage/auth.css b/apps/remoteStorage/auth.css new file mode 100644 index 00000000000..2dedad5dd0f --- /dev/null +++ b/apps/remoteStorage/auth.css @@ -0,0 +1,8 @@ +h2 { font-size:2em; font-weight:bold; margin-bottom:1em; white-space:nowrap; } +ul.scopes { list-style:disc; } +ul.scopes li { white-space:nowrap; } +h2 img { width: 50% } +#oauth { margin:4em auto 2em; width:20em; } +#allow-auth { background-color:#5c3; text-shadow:#5e3 0 1px 0; color:#fff; +-webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #5f3 inset; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #5f3 inset; box-shadow:0 1px 1px #fff, 0 1px 1px #5f3 inset; } +#deny-auth { padding:0; margin:.7em; border:0; background:none; font-size:1.2em; -moz-box-shadow: 0 0 0 #fff, 0 0 0 #fff inset; -webkit-box-shadow: 0 0 0 #fff, 0 0 0 #fff inset; box-shadow: 0 0 0 #fff, 0 0 0 #fff inset; } diff --git a/apps/remoteStorage/auth.php b/apps/remoteStorage/auth.php index cc40e895e01..c00f9d5555c 100644 --- a/apps/remoteStorage/auth.php +++ b/apps/remoteStorage/auth.php @@ -8,7 +8,7 @@ * @copyright 2010 Frank Karlitschek karlitschek@kde.org * * Adapted: -* @author Michiel de Jong, 2011 +* @author Michiel de Jong, 2012 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -17,11 +17,11 @@ * * 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 +* 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/>. +* License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ @@ -39,24 +39,8 @@ ini_set('default_charset', 'UTF-8'); #ini_set('error_reporting', ''); @ob_clean(); -//allow use as remote storage for other websites -if(isset($_SERVER['HTTP_ORIGIN'])) { - header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); - header('Access-Control-Max-Age: 3600'); - header('Access-Control-Allow-Methods: OPTIONS, GET, PUT, DELETE, PROPFIND'); - header('Access-Control-Allow-Headers: Authorization, Content-Type'); -} else { - header('Access-Control-Allow-Origin: *'); -} - $path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"])); -$pathParts = explode('/', $path); -// for webdav: -// 0/ 1 / 2 / 3 / 4 / 5 / 6 / 7 -// /$ownCloudUser/remoteStorage/webdav/$userHost/$userName/$dataScope/$key -// for oauth: -// 0/ 1 / 2 / 3 / 4 -// /$ownCloudUser/remoteStorage/oauth/auth +$pathParts = explode('/', $path); if(count($pathParts) == 2 && $pathParts[0] == '') { //TODO: input checking. these explodes may fail to produces the desired arrays: @@ -66,7 +50,8 @@ if(count($pathParts) == 2 && $pathParts[0] == '') { if($k=='user_address'){ $userAddress=$v; } else if($k=='redirect_uri'){ - $appUrl=$v; + $appUrlParts=explode('/', $v); + $appUrl = $appUrlParts[2];//bit dodgy i guess } else if($k=='scope'){ $categories=$v; } @@ -78,7 +63,56 @@ if(count($pathParts) == 2 && $pathParts[0] == '') { $token=OC_remoteStorage::createCategories($appUrl, $categories); header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=bearer'); } else { - echo '<form method="POST"><input name="allow" type="submit" value="Allow this web app to store stuff on your owncloud."></form>'; +?> +<!DOCTYPE html> +<html> + <head> + <title>ownCloud</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <link rel="shortcut icon" href="../../../core/img/favicon.png" /><link rel="apple-touch-icon-precomposed" href="../../../core/img/favicon-touch.png" /> + <link rel="stylesheet" href="../../../core/css/styles.css" type="text/css" media="screen" /> + <link rel="stylesheet" href="../auth.css" type="text/css" media="screen" /> + </head> + <body id="body-login"> + <div id="login"> + <header> + <div id="header"> + <img src="../../../core/img/owncloud-logo-medium-white.png" alt="ownCloud" /> + </div> + </header> + <section id="main"> + <div id="oauth"> + <h2><img src="../remoteStorage-big.png" alt="remoteStorage" /></h2> + <p><strong><?php $appUrlParts = explode('/', $_GET['redirect_uri']); echo htmlentities($appUrlParts[2]); ?></strong> + requests read & write access to your + <?php + $categories = explode(',', htmlentities($_GET['scope'])); + if(!count($categories)) { + echo htmlentities($_GET['scope']); + } else { + echo '<em>'.$categories[0].'</em>'; + if(count($categories)==2) { + echo ' and <em>'.$categories[1].'</em>'; + } else if(count($categories)>2) { + for($i=1; $i<count($categories)-1; $i++) { + echo ', <em>'.$categories[$i].'</em>'; + } + echo ', and <em>'.$categories[$i].'</em>'; + } + } + ?>. + </p> + <form accept-charset="UTF-8" method="post"> + <input id="allow-auth" name="allow" type="submit" value="Allow" /> + <input id="deny-auth" name="deny" type="submit" value="Deny" /> + </form> + </div> + </section> + </div> + <footer><p class="info"><a href="http://owncloud.org/">ownCloud</a> – web services under your control</p></footer> + </body> +</html> +<?php } } else { if((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'])) { @@ -88,12 +122,11 @@ if(count($pathParts) == 2 && $pathParts[0] == '') { } $url .= $_SERVER['SERVER_NAME']; $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/remoteStorage/compat.php')); - die('You are '.($currUser?'logged in as '.$currUser.' instead of '.$ownCloudUser:'not logged in').'. Please ' - .'<input type="submit" onclick="' - ."window.open('$url','Close me!','height=600,width=300');" - .'" value="log in">' - .', close the pop-up, and ' - .'<form method="POST"><input name="allow" type="submit" value="Click here"></form>'); + if($currUser) { + die('You are logged in as '.$currUser.' instead of '.$ownCloudUser); + } else { + header('Location: /?redirect_url='.urlencode('/apps/remoteStorage/auth.php'.$_SERVER['PATH_INFO'].'?'.$_SERVER['QUERY_STRING'])); + } } } else { //die('please use auth.php/username?params. '.var_export($pathParts, true)); diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php index a9b73516aad..6e6a19c739f 100644 --- a/apps/remoteStorage/lib_remoteStorage.php +++ b/apps/remoteStorage/lib_remoteStorage.php @@ -20,7 +20,7 @@ class OC_remoteStorage { $ret = array(); while($row=$result->fetchRow()){ $ret[$row['token']] = array( - 'appUrl' => $row['appurl'], + 'appUrl' => $row['appUrl'], 'categories' => $row['category'], ); } @@ -31,6 +31,7 @@ class OC_remoteStorage { $user=OC_User::getUser(); $query=OC_DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?"); $result=$query->execute(array($token,$user)); + return 'unknown';//how can we see if any rows were affected? } private static function addToken($token, $appUrl, $categories){ $user=OC_User::getUser(); diff --git a/apps/remoteStorage/remoteStorage-big.png b/apps/remoteStorage/remoteStorage-big.png Binary files differnew file mode 100644 index 00000000000..7c429a6a738 --- /dev/null +++ b/apps/remoteStorage/remoteStorage-big.png diff --git a/apps/remoteStorage/remoteStorage.png b/apps/remoteStorage/remoteStorage.png Binary files differnew file mode 100644 index 00000000000..6b751c09997 --- /dev/null +++ b/apps/remoteStorage/remoteStorage.png diff --git a/apps/remoteStorage/settings.php b/apps/remoteStorage/settings.php new file mode 100644 index 00000000000..fa85f77a535 --- /dev/null +++ b/apps/remoteStorage/settings.php @@ -0,0 +1,7 @@ +<?php + +require_once('lib_remoteStorage.php'); +$tmpl = new OC_Template( 'remoteStorage', 'settings'); + +return $tmpl->fetchPage(); +?> |