-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTPlugin moved to repository at hrz-unimr
- Loading branch information
Showing
315 changed files
with
74,501 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
ILIAS REST Plugin | ||
===================== | ||
This is an extensible REST interface that allows developers to create RESTful APIs on top of the [ILIAS LMS](http://www.ilias.de). | ||
|
||
![Alt text](https://cloud.githubusercontent.com/assets/7113474/3655327/eeec4264-1177-11e4-8256-869db1f98c29.PNG "ILIAS REST Plugin") | ||
|
||
#### Features: | ||
* CRUD (Create-Read-Update-Delete) principle for resources | ||
* Permission management for resources depending on REST clients | ||
* Full OAuth 2.0 support (see [RFC6749](http://tools.ietf.org/html/rfc6749)) including the grant types: | ||
* Authorization Code | ||
* Implicit | ||
* Resource Owner Password Credentials | ||
* Client Credentials | ||
* Easy integration for new REST endpoints | ||
* API discovery | ||
* Based on the PHP SLIM Framework | ||
|
||
Examples | ||
--------- | ||
Example 1 | ||
**Retrieve available routes** | ||
<pre><code>curl -X GET http://localhost/restplugin.php/routes | ||
</code></pre> | ||
|
||
Example 2 | ||
**Retrieve an OAuth 2.0 Access Token** | ||
<pre><code>curl -X POST http://localhost/restplugin.php/v1/oauth2/token -d "grant_type=password&username=root&password=homer"| python -m json.tool | ||
</code></pre> | ||
<pre><code>curl -H "Authorization: Bearer <ACCESS_TOKEN>" http://... | ||
</code></pre> | ||
|
||
##Installation## | ||
Current release: v.0.5.6-alpha | ||
* mkdir -p ILIAS_DIR/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/ | ||
* cd ILIAS_DIR/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/ | ||
* wget https://github.com/eqsoft/RESTPlugin/archive/v.0.5.6-alpha.zip | ||
* unzip v.0.5.6.zip | ||
* mv RESTPlugin-v.0.5.6-alpha Rest | ||
* Copy Rest/gateways/restplugin.php to / | ||
* Plugin directories must be readable by www-user | ||
* Activate Plugin in Administration > Plugins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
<?php | ||
/** | ||
* Slim - a micro PHP 5 framework | ||
* | ||
* @author Josh Lockhart <[email protected]> | ||
* @copyright 2011 Josh Lockhart | ||
* @link http://www.slimframework.com | ||
* @license http://www.slimframework.com/license | ||
* @version 2.4.2 | ||
* @package Slim | ||
* | ||
* MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace Slim; | ||
|
||
/** | ||
* Environment | ||
* | ||
* This class creates and returns a key/value array of common | ||
* environment variables for the current HTTP request. | ||
* | ||
* This is a singleton class; derived environment variables will | ||
* be common across multiple Slim applications. | ||
* | ||
* This class matches the Rack (Ruby) specification as closely | ||
* as possible. More information available below. | ||
* | ||
* @package Slim | ||
* @author Josh Lockhart | ||
* @since 1.6.0 | ||
*/ | ||
class Environment implements \ArrayAccess, \IteratorAggregate | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $properties; | ||
|
||
/** | ||
* @var \Slim\Environment | ||
*/ | ||
protected static $environment; | ||
|
||
/** | ||
* Get environment instance (singleton) | ||
* | ||
* This creates and/or returns an environment instance (singleton) | ||
* derived from $_SERVER variables. You may override the global server | ||
* variables by using `\Slim\Environment::mock()` instead. | ||
* | ||
* @param bool $refresh Refresh properties using global server variables? | ||
* @return \Slim\Environment | ||
*/ | ||
public static function getInstance($refresh = false) | ||
{ | ||
if (is_null(self::$environment) || $refresh) { | ||
self::$environment = new self(); | ||
} | ||
|
||
return self::$environment; | ||
} | ||
|
||
/** | ||
* Get mock environment instance | ||
* | ||
* @param array $userSettings | ||
* @return \Slim\Environment | ||
*/ | ||
public static function mock($userSettings = array()) | ||
{ | ||
$defaults = array( | ||
'REQUEST_METHOD' => 'GET', | ||
'SCRIPT_NAME' => '', | ||
'PATH_INFO' => '', | ||
'QUERY_STRING' => '', | ||
'SERVER_NAME' => 'localhost', | ||
'SERVER_PORT' => 80, | ||
'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | ||
'ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', | ||
'ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', | ||
'USER_AGENT' => 'Slim Framework', | ||
'REMOTE_ADDR' => '127.0.0.1', | ||
'slim.url_scheme' => 'http', | ||
'slim.input' => '', | ||
'slim.errors' => @fopen('php://stderr', 'w') | ||
); | ||
self::$environment = new self(array_merge($defaults, $userSettings)); | ||
|
||
return self::$environment; | ||
} | ||
|
||
/** | ||
* Constructor (private access) | ||
* | ||
* @param array|null $settings If present, these are used instead of global server variables | ||
*/ | ||
private function __construct($settings = null) | ||
{ | ||
if ($settings) { | ||
$this->properties = $settings; | ||
} else { | ||
$env = array(); | ||
|
||
//The HTTP request method | ||
$env['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD']; | ||
|
||
//The IP | ||
$env['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; | ||
|
||
// Server params | ||
$scriptName = $_SERVER['SCRIPT_NAME']; // <-- "/foo/index.php" | ||
$requestUri = $_SERVER['REQUEST_URI']; // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc" | ||
$queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; // <-- "test=abc" or "" | ||
|
||
// Physical path | ||
if (strpos($requestUri, $scriptName) !== false) { | ||
$physicalPath = $scriptName; // <-- Without rewriting | ||
} else { | ||
$physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting | ||
} | ||
$env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes | ||
|
||
// Virtual path | ||
$env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path | ||
$env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string | ||
$env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash | ||
|
||
// Query string (without leading "?") | ||
$env['QUERY_STRING'] = $queryString; | ||
|
||
//Name of server host that is running the script | ||
$env['SERVER_NAME'] = $_SERVER['SERVER_NAME']; | ||
|
||
//Number of server port that is running the script | ||
$env['SERVER_PORT'] = $_SERVER['SERVER_PORT']; | ||
|
||
//HTTP request headers (retains HTTP_ prefix to match $_SERVER) | ||
$headers = \Slim\Http\Headers::extract($_SERVER); | ||
foreach ($headers as $key => $value) { | ||
$env[$key] = $value; | ||
} | ||
|
||
//Is the application running under HTTPS or HTTP protocol? | ||
$env['slim.url_scheme'] = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' ? 'http' : 'https'; | ||
|
||
//Input stream (readable one time only; not available for multipart/form-data requests) | ||
$rawInput = @file_get_contents('php://input'); | ||
if (!$rawInput) { | ||
$rawInput = ''; | ||
} | ||
$env['slim.input'] = $rawInput; | ||
|
||
//Error stream | ||
$env['slim.errors'] = @fopen('php://stderr', 'w'); | ||
|
||
$this->properties = $env; | ||
} | ||
} | ||
|
||
/** | ||
* Array Access: Offset Exists | ||
*/ | ||
public function offsetExists($offset) | ||
{ | ||
return isset($this->properties[$offset]); | ||
} | ||
|
||
/** | ||
* Array Access: Offset Get | ||
*/ | ||
public function offsetGet($offset) | ||
{ | ||
if (isset($this->properties[$offset])) { | ||
return $this->properties[$offset]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Array Access: Offset Set | ||
*/ | ||
public function offsetSet($offset, $value) | ||
{ | ||
$this->properties[$offset] = $value; | ||
} | ||
|
||
/** | ||
* Array Access: Offset Unset | ||
*/ | ||
public function offsetUnset($offset) | ||
{ | ||
unset($this->properties[$offset]); | ||
} | ||
|
||
/** | ||
* IteratorAggregate | ||
* | ||
* @return \ArrayIterator | ||
*/ | ||
public function getIterator() | ||
{ | ||
return new \ArrayIterator($this->properties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Slim - a micro PHP 5 framework | ||
* | ||
* @author Josh Lockhart <[email protected]> | ||
* @copyright 2011 Josh Lockhart | ||
* @link http://www.slimframework.com | ||
* @license http://www.slimframework.com/license | ||
* @version 2.4.2 | ||
* @package Slim | ||
* | ||
* MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace Slim\Exception; | ||
|
||
/** | ||
* Pass Exception | ||
* | ||
* This Exception will cause the Router::dispatch method | ||
* to skip the current matching route and continue to the next | ||
* matching route. If no subsequent routes are found, a | ||
* HTTP 404 Not Found response will be sent to the client. | ||
* | ||
* @package Slim | ||
* @author Josh Lockhart | ||
* @since 1.0.0 | ||
*/ | ||
class Pass extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Slim - a micro PHP 5 framework | ||
* | ||
* @author Josh Lockhart <[email protected]> | ||
* @copyright 2011 Josh Lockhart | ||
* @link http://www.slimframework.com | ||
* @license http://www.slimframework.com/license | ||
* @version 2.4.2 | ||
* @package Slim | ||
* | ||
* MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace Slim\Exception; | ||
|
||
/** | ||
* Stop Exception | ||
* | ||
* This Exception is thrown when the Slim application needs to abort | ||
* processing and return control flow to the outer PHP script. | ||
* | ||
* @package Slim | ||
* @author Josh Lockhart | ||
* @since 1.0.0 | ||
*/ | ||
class Stop extends \Exception | ||
{ | ||
} |
Oops, something went wrong.