コード例 #1
0
ファイル: PdoAdapter.php プロジェクト: BWorld/zf-oauth2
 /**
  * @param string $connection
  * @param array $config
  */
 public function __construct($connection, $config = array())
 {
     parent::__construct($connection, $config);
     if (isset($config['bcrypt_cost'])) {
         $this->setBcryptCost($config['bcrypt_cost']);
     }
 }
コード例 #2
0
 public function __construct($connection, $config = array())
 {
     parent::__construct($connection, $config);
     // Set custom User table
     $user = new User();
     $this->config['user_table'] = $user->getSource();
 }
コード例 #3
0
ファイル: OAuth2Storage.php プロジェクト: higorcouto/novosga
 public function __construct(\Doctrine\ORM\EntityManager $em, $config = array())
 {
     $conn = $em->getConnection()->getWrappedConnection();
     parent::__construct($conn, $config);
     $tableName = $em->getClassMetadata('Novosga\\Model\\OAuthClient')->getTableName();
     $this->config['client_table'] = $tableName;
     $this->em = $em;
 }
コード例 #4
0
ファイル: Server.php プロジェクト: baquiax/renap-oauth2
 public function setup(Application $app)
 {
     //$dsn = "mysql:dbname=renap_users;unix_socket=/tmp/mysqld.sock;host:localhost;";
     $dsn = "mysql:dbname=renap_users;host:localhost;";
     $username = "******";
     $password = "******";
     $storage = new Pdo(array("dsn" => $dsn, "username" => $username, "password" => $password));
     $grantTypes = array('authorization_code' => new AuthorizationCode($storage), 'refresh_token' => new RefreshToken($storage, array('always_issue_new_refresh_token' => true)));
     $server = new OAuth2Server($storage, array('enforce_state' => true, 'allow_implicit' => true, 'issuer' => $_SERVER['HTTP_HOST']), $grantTypes);
     $defaultScope = 'basic';
     $supportedScopes = array('basic', 'admin');
     $memory = new Memory(array('default_scope' => $defaultScope, 'supported_scopes' => $supportedScopes));
     $scopeUtil = new Scope($memory);
     $server->setScopeUtil($scopeUtil);
     $storage->setUser("admin", "admin", "Alexander", "Baquiax", 'admin');
     $app['oauth_server'] = $server;
     $app['mysql_client'] = $storage;
     $app['oauth_response'] = new BridgeResponse();
 }
コード例 #5
0
 /**
  * @param string $client_id
  * @param string $user_id
  *
  * @return bool
  */
 protected function authorized($client_id, $user_id)
 {
     if ($this->storage->getClientUser($client_id, $user_id)) {
         return true;
     }
     if ($_POST && 'yes' === @$_POST['authorized']) {
         $this->storage->setClientUser($client_id, $user_id);
         return true;
     }
     return false;
 }
コード例 #6
0
ファイル: Pdo.php プロジェクト: humandevice/hd-api
 public function __construct($connection = null, $config = array())
 {
     if ($connection === null) {
         if (!empty($this->connection)) {
             $connection = \Yii::$app->get($this->connection);
             if (!$connection->getIsActive()) {
                 $connection->open();
             }
             $connection = $connection->pdo;
         } else {
             $connection = ['dsn' => $this->dsn, 'username' => $this->username, 'password' => $this->password];
         }
     }
     parent::__construct($connection, $config);
 }
コード例 #7
0
 public function __construct($connection = null, $config = array())
 {
     if ($connection === null) {
         if ($this->connection !== null && \Yii::$app->has($this->connection)) {
             $db = \Yii::$app->get($this->connection);
             if (!$db instanceof \yii\db\Connection) {
                 throw new \yii\base\InvalidConfigException('Connection component must implement \\yii\\db\\Connection.');
             }
             if (!$db->getIsActive()) {
                 $db->open();
             }
             $connection = $db->pdo;
             $config = array_merge(array('client_table' => $db->tablePrefix . 'oauth_clients', 'access_token_table' => $db->tablePrefix . 'oauth_access_tokens', 'refresh_token_table' => $db->tablePrefix . 'oauth_refresh_tokens', 'code_table' => $db->tablePrefix . 'oauth_authorization_codes', 'user_table' => $db->tablePrefix . 'oauth_users', 'jwt_table' => $db->tablePrefix . 'oauth_jwt', 'jti_table' => $db->tablePrefix . 'oauth_jti', 'scope_table' => $db->tablePrefix . 'oauth_scopes', 'public_key_table' => $db->tablePrefix . 'oauth_public_keys'), $config);
         } else {
             $connection = ['dsn' => $this->dsn, 'username' => $this->username, 'password' => $this->password];
         }
     }
     parent::__construct($connection, $config);
 }
コード例 #8
0
 public function __construct($connection, $config = array())
 {
     parent::__construct($connection, $config);
     $this->config['user_table'] = 'users';
 }
コード例 #9
0
 public function __construct($connection, $config, ZfcUserStorageBridge $bridge)
 {
     parent::__construct($connection, $config);
     $this->bridge = $bridge;
 }
コード例 #10
0
ファイル: PdoTest.php プロジェクト: manishkhanchandani/mkgxy
 public function testCreatePdoStorageUsingConfig()
 {
     $config = array('dsn' => sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir()));
     $storage = new Pdo($config);
     $this->assertNotNull($storage->getClientDetails('oauth_test_client'));
 }