public function __construct() { global $CONFIG; \OAuth2\Autoloader::register(); $storage = new \OAuth2\Storage\Pdo(array('dsn' => "mysql:dbname=" . $CONFIG->dbname . ";host=" . $CONFIG->dbhost, 'username' => $CONFIG->dbuser, 'password' => $CONFIG->dbpass)); $server = new \OAuth2\Server($storage, array('access_lifetime' => 3600 * 24 * 7, 'enforce_state' => false)); $uc_storage = new UserCredentialsStorage(); $server->addGrantType(new \OAuth2\GrantType\UserCredentials($uc_storage)); $server->addGrantType(new \OAuth2\GrantType\RefreshToken($storage, array('always_issue_new_refresh_token' => true, 'refresh_token_lifetime' => 3600 * 24 * 30 * 6))); $this->server = $server; }
/** * 搭建OAuth2 的服务 */ public function oauth_server() { require_once './OAuth2/Autoloader.php'; \OAuth2\Autoloader::register(); $dsn = 'mysql:host=127.0.0.1;dbname=opencenter'; $this->storage = new \OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => 'root', 'password' => 'suzhouadmin')); $server = new \OAuth2\Server($this->storage); $this->server_all = $server; $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($this->storage)); $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($this->storage)); }
/** * Register the service provider. * * @return void */ public function register() { // Register 'underlyingclass' instance container to our UnderlyingClass object $this->app['oauth2server'] = $this->app->share(function ($app) { OAuth2\Autoloader::register(); $storage = new OAuth2\Storage\Pdo(array('dsn' => "mysql:host=localhost;dbname=db_name", 'username' => "root", 'password' => "somepassword")); // Pass a storage object or array of storage objects to the OAuth2 server class $config = array('allow_implicit' => true, 'access_lifetime' => 3600 * 24 * 7 * 3); // 3 weeks duration $server = new OAuth2\Server($storage, $config); // Add the "Client Credentials" grant type (it is the simplest of the grant types) $server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage)); // Add the "Authorization Code" grant type (this is where the oauth magic happens) $server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); return $server; }); // Shortcut so developers don't need to add an Alias in app/config/app.php $this->app->booting(function () { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Oauth2Server', 'Victorhqc\\OAuth2\\OFacade'); }); }
public function __construct() { OAuth2\Autoloader::register(); $this->storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password)); $this->server = new OAuth2\Server($this->storage); }
<?php /* * 这个文件是 youpaiyunzhi 的一部分。 * * (c) shsrain <*****@*****.**> * * 对于全版权和许可信息,请查看分发此源代码的许可文件。 */ /** * 这是一个扩展包加载文件类。 * * @author shsrain <*****@*****.**> */ require_once __DIR__ . '/jsonlint/vendor/autoload.php'; require_once __DIR__ . '/jsonschema/vendor/autoload.php'; require_once __DIR__ . '/json/vendor/autoload.php'; require_once __DIR__ . '/validation/vendor/autoload.php'; require_once __DIR__ . '/pagination/vendor/autoload.php'; require_once __DIR__ . '/phpsocketraw/vendor/autoload.php'; require_once __DIR__ . '/Cache/autoload.php'; require_once __DIR__ . '/Image/autoload.php'; require_once __DIR__ . '/Upload/vendor/autoload.php'; require_once __DIR__ . '/OAuth2/Autoloader.php'; \OAuth2\Autoloader::register(); require_once __DIR__ . '/SimplePHPCache/vendor/autoload.php'; require_once __DIR__ . '/filesystem/vendor/autoload.php'; require_once __DIR__ . '/httpSendFile/vendor/autoload.php'; require_once __DIR__ . '/FastRoute/vendor/autoload.php'; require_once __DIR__ . '/react/vendor/autoload.php';