/**
  * @param string $file
  * @return IniReader|null
  */
 private function openFile($file)
 {
     $file = $this->getDirectory() . $file;
     if (file_exists($file)) {
         return IniReader::fromFile($file);
     }
 }
Esempio n. 2
0
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once dirname(__DIR__) . '/vendor/autoload.php';
use fkooman\Ini\IniReader;
use fkooman\OAuth\Server\ApprovalsService;
use fkooman\OAuth\Server\Authenticator;
use fkooman\Rest\PluginRegistry;
use fkooman\OAuth\Server\PdoStorage;
use fkooman\Rest\Plugin\ReferrerCheck\ReferrerCheckPlugin;
use fkooman\Rest\ExceptionHandler;
ExceptionHandler::register();
$iniReader = IniReader::fromFile(dirname(__DIR__) . '/config/oauth.ini');
$db = new PDO($iniReader->v('PdoStorage', 'dsn'), $iniReader->v('PdoStorage', 'username', false), $iniReader->v('PdoStorage', 'password', false));
$auth = new Authenticator($iniReader);
$authenticationPlugin = $auth->getAuthenticationPlugin();
$service = new ApprovalsService(new PdoStorage($db));
$pluginRegistry = new PluginRegistry();
$pluginRegistry->registerDefaultPlugin(new ReferrerCheckPlugin());
$pluginRegistry->registerDefaultPlugin($authenticationPlugin);
$service->setPluginRegistry($pluginRegistry);
$service->run()->send();
Esempio n. 3
0
 /**
  * @param IniReader $iniReader
  * @return array
  */
 protected function getSpecificConfiguration(IniReader $iniReader)
 {
     return array(self::CONSUMER_KEY => $iniReader->v(self::CONSUMER_KEY), self::CONSUMER_SECRET => $iniReader->v(self::CONSUMER_SECRET), self::OAUTH_TOKEN => urlencode($iniReader->v(self::OAUTH_TOKEN)), self::OAUTH_TOKEN_SECRET => urlencode($iniReader->v(self::OAUTH_TOKEN_SECRET)));
 }
Esempio n. 4
0
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';
use fkooman\Ini\IniReader;
use fkooman\OAuth\Storage\PdoCodeTokenStorage;
try {
    $config = IniReader::fromFile(dirname(__DIR__) . '/config/server.ini');
    // initialize the DB
    $pdo = new PDO($config->v('Db', 'dsn'), $config->v('Db', 'username', false), $config->v('Db', 'password', false));
    $storage = new PdoCodeTokenStorage($pdo);
    $storage->initDatabase();
} catch (Exception $e) {
    echo $e->getMessage() . PHP_EOL;
    exit(1);
}
Esempio n. 5
0
 /**
  * @param IniReader $iniReader
  * @return array
  */
 protected function getSpecificConfiguration(IniReader $iniReader)
 {
     return array(self::API_KEY => $iniReader->v(self::API_KEY));
 }