/** * @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']); } }
public function __construct($connection, $config = array()) { parent::__construct($connection, $config); // Set custom User table $user = new User(); $this->config['user_table'] = $user->getSource(); }
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; }
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(); }
/** * @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; }
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); }
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); }
public function __construct($connection, $config = array()) { parent::__construct($connection, $config); $this->config['user_table'] = 'users'; }
public function __construct($connection, $config, ZfcUserStorageBridge $bridge) { parent::__construct($connection, $config); $this->bridge = $bridge; }
public function testCreatePdoStorageUsingConfig() { $config = array('dsn' => sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir())); $storage = new Pdo($config); $this->assertNotNull($storage->getClientDetails('oauth_test_client')); }