【发布时间】:2015-11-08 12:46:02
【问题描述】:
我目前正在我的网站中实施 OAuth2,以保持用户在 Android 应用中的登录状态。我想将默认的 OAuth2 用户数据库更改为我自己的用户数据库。不幸的是,我不知道该怎么做。应该可以通过覆盖类而不改变核心库中的代码,但是怎么做呢?
这是我在server.php 文件中的内容:
// Autoloading (composer is preferred, but for this example let's just do this)
require_once('/src/OAuth2/Autoloader.php');
OAuth2\Autoloader::register();
$storage = new OAuth2\Storage\Pdo(array('dsn' => 'mysql:host=xxxx;dbname=xxxx', 'username' => 'xxxx', 'password' => 'xxxx'));
// Pass a storage object or array of storage objects to the OAuth2 server class
$server = new OAuth2\Server($storage);
// Add the "Password / User Credentials" grant type
$server->addGrantType(new OAuth2\GrantType\UserCredentials($storage));
所以在这里我想使用我自己的用户表而不是默认的oauth_users 表。而且因为密码是加盐的,所以我也需要进行不同的密码检查。我正在使用 BShaffer OAuth2 库:https://github.com/bshaffer/oauth2-server-php
【问题讨论】:
-
您好,我也有同样的问题,您有答案了吗?
标签: php database oauth oauth-2.0