OAuth related syntax fixes, nothing big
Making better use of class autoloading too.
This commit is contained in:
parent
5974493707
commit
cc34bb48c7
@ -28,11 +28,7 @@
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Action for getting OAuth token credentials (exchange an authorized
|
||||
@ -44,7 +40,7 @@ require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiOauthAccessTokenAction extends ApiOauthAction
|
||||
class ApiOAuthAccessTokenAction extends ApiOAuthAction
|
||||
{
|
||||
protected $reqToken = null;
|
||||
protected $verifier = null;
|
||||
@ -60,7 +56,7 @@ class ApiOauthAccessTokenAction extends ApiOauthAction
|
||||
{
|
||||
parent::handle($args);
|
||||
|
||||
$datastore = new ApiStatusNetOAuthDataStore();
|
||||
$datastore = new ApiGNUSocialOAuthDataStore();
|
||||
$server = new OAuthServer($datastore);
|
||||
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
|
||||
|
@ -31,9 +31,6 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
require_once INSTALLDIR . '/lib/info.php';
|
||||
|
||||
/**
|
||||
* Authorize an OAuth request token
|
||||
*
|
||||
@ -43,7 +40,7 @@ require_once INSTALLDIR . '/lib/info.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiOauthAuthorizeAction extends Action
|
||||
class ApiOAuthAuthorizeAction extends ApiOAuthAction
|
||||
{
|
||||
var $oauthTokenParam;
|
||||
var $reqToken;
|
||||
@ -71,7 +68,7 @@ class ApiOauthAuthorizeAction extends Action
|
||||
$this->password = $this->arg('password');
|
||||
$this->oauthTokenParam = $this->arg('oauth_token');
|
||||
$this->mode = $this->arg('mode');
|
||||
$this->store = new ApiStatusNetOAuthDataStore();
|
||||
$this->store = new ApiGNUSocialOAuthDataStore();
|
||||
|
||||
try {
|
||||
$this->app = $this->store->getAppByRequestToken($this->oauthTokenParam);
|
||||
@ -367,7 +364,7 @@ class ApiOauthAuthorizeAction extends Action
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'form_apioauthauthorize',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('ApiOauthAuthorize')));
|
||||
'action' => common_local_url('ApiOAuthAuthorize')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->element('legend', array('id' => 'apioauthauthorize_allowdeny'),
|
||||
// TRANS: Fieldset legend.
|
||||
@ -613,7 +610,7 @@ class ApiOauthAuthorizeAction extends Action
|
||||
}
|
||||
|
||||
if ($this->reqToken->verified_callback == 'oob') {
|
||||
$pin = new ApiOauthPinAction(
|
||||
$pin = new ApiOAuthPinAction(
|
||||
$title,
|
||||
$msg,
|
||||
$this->reqToken->verifier,
|
||||
|
@ -42,7 +42,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiOauthPinAction extends InfoAction
|
||||
class ApiOAuthPinAction extends InfoAction
|
||||
{
|
||||
function __construct($title, $message, $verifier, $desktopMode = false)
|
||||
{
|
||||
|
@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
|
||||
/**
|
||||
* Issue temporary OAuth credentials (a request token)
|
||||
*
|
||||
@ -42,7 +40,7 @@ require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiOauthRequestTokenAction extends ApiOauthAction
|
||||
class ApiOAuthRequestTokenAction extends ApiOAuthAction
|
||||
{
|
||||
/**
|
||||
* Take arguments for running
|
||||
@ -75,7 +73,7 @@ class ApiOauthRequestTokenAction extends ApiOauthAction
|
||||
{
|
||||
parent::handle($args);
|
||||
|
||||
$datastore = new ApiStatusNetOAuthDataStore();
|
||||
$datastore = new ApiGNUSocialOAuthDataStore();
|
||||
$server = new OAuthServer($datastore);
|
||||
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
|
||||
|
@ -32,7 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/applicationlist.php';
|
||||
require_once INSTALLDIR . '/lib/statusnetoauthstore.php';
|
||||
|
||||
/**
|
||||
* Show a user's registered OAuth applications
|
||||
|
@ -32,7 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/applicationlist.php';
|
||||
require_once INSTALLDIR . '/lib/statusnetoauthstore.php';
|
||||
|
||||
/**
|
||||
* Show connected OAuth applications
|
||||
@ -169,7 +168,7 @@ class OauthconnectionssettingsAction extends SettingsAction
|
||||
|
||||
$app = Oauth_application::getKV('id', $appUser->application_id);
|
||||
|
||||
$datastore = new ApiStatusNetOAuthDataStore();
|
||||
$datastore = new ApiGNUSocialOAuthDataStore();
|
||||
$datastore->revoke_token($appUser->token, 1);
|
||||
|
||||
$result = $appUser->delete();
|
||||
|
@ -261,13 +261,13 @@ class ShowApplicationAction extends Action
|
||||
$this->element('dd', null, $consumer->consumer_secret);
|
||||
// TRANS: Field label on application page.
|
||||
$this->element('dt', null, _('Request token URL'));
|
||||
$this->element('dd', null, common_local_url('ApiOauthRequestToken'));
|
||||
$this->element('dd', null, common_local_url('ApiOAuthRequestToken'));
|
||||
// TRANS: Field label on application page.
|
||||
$this->element('dt', null, _('Access token URL'));
|
||||
$this->element('dd', null, common_local_url('ApiOauthAccessToken'));
|
||||
$this->element('dd', null, common_local_url('ApiOAuthAccessToken'));
|
||||
// TRANS: Field label on application page.
|
||||
$this->element('dt', null, _('Authorize URL'));
|
||||
$this->element('dd', null, common_local_url('ApiOauthAuthorize'));
|
||||
$this->element('dd', null, common_local_url('ApiOAuthAuthorize'));
|
||||
$this->elementEnd('dl');
|
||||
|
||||
$this->element('p', 'note',
|
||||
|
@ -57,8 +57,6 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
|
||||
/**
|
||||
* Actions extending this class will require auth
|
||||
*
|
||||
@ -133,7 +131,7 @@ class ApiAuthAction extends ApiAction
|
||||
*/
|
||||
function getOAuthRequest()
|
||||
{
|
||||
ApiOauthAction::cleanRequest();
|
||||
ApiOAuthAction::cleanRequest();
|
||||
|
||||
$req = OAuthRequest::from_request();
|
||||
|
||||
@ -160,7 +158,7 @@ class ApiAuthAction extends ApiAction
|
||||
*/
|
||||
function checkOAuthRequest($request)
|
||||
{
|
||||
$datastore = new ApiStatusNetOAuthDataStore();
|
||||
$datastore = new ApiGNUSocialOAuthDataStore();
|
||||
$server = new OAuthServer($datastore);
|
||||
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
|
||||
|
@ -17,14 +17,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
require_once 'OAuth.php';
|
||||
|
||||
/**
|
||||
* @fixme class doc
|
||||
*/
|
||||
class ApiStatusNetOAuthDataStore extends OAuthDataStore
|
||||
class ApiGNUSocialOAuthDataStore extends OAuthDataStore
|
||||
{
|
||||
function lookup_consumer($consumerKey)
|
||||
{
|
||||
@ -120,7 +120,7 @@ class ApiStatusNetOAuthDataStore extends OAuthDataStore
|
||||
}
|
||||
}
|
||||
|
||||
function new_access_token($token, $consumer, $verifier)
|
||||
function new_access_token($token, $consumer, $verifier = null)
|
||||
{
|
||||
common_debug(
|
||||
sprintf(
|
||||
@ -405,7 +405,7 @@ class ApiStatusNetOAuthDataStore extends OAuthDataStore
|
||||
$t->verifier = common_good_rand(8);
|
||||
}
|
||||
|
||||
$t->created = DB_DataObject_Cast::dateTime();
|
||||
$t->created = common_sql_now();
|
||||
if (!$t->insert()) {
|
||||
return null;
|
||||
} else {
|
@ -31,7 +31,6 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
require_once INSTALLDIR . '/lib/apiaction.php';
|
||||
require_once INSTALLDIR . '/lib/statusnetoauthstore.php';
|
||||
|
||||
/**
|
||||
* Base action for API OAuth enpoints. Clean up the
|
||||
@ -43,7 +42,7 @@ require_once INSTALLDIR . '/lib/statusnetoauthstore.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiOauthAction extends ApiAction
|
||||
class ApiOAuthAction extends ApiAction
|
||||
{
|
||||
/**
|
||||
* Is this a read-only action?
|
@ -33,8 +33,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/info.php';
|
||||
|
||||
/**
|
||||
* Base class for displaying HTTP errors
|
||||
*
|
||||
|
@ -787,13 +787,13 @@ class Router
|
||||
$m->connect('api/trends.json', array('action' => 'ApiTrends'));
|
||||
|
||||
$m->connect('api/oauth/request_token',
|
||||
array('action' => 'ApiOauthRequestToken'));
|
||||
array('action' => 'ApiOAuthRequestToken'));
|
||||
|
||||
$m->connect('api/oauth/access_token',
|
||||
array('action' => 'ApiOauthAccessToken'));
|
||||
array('action' => 'ApiOAuthAccessToken'));
|
||||
|
||||
$m->connect('api/oauth/authorize',
|
||||
array('action' => 'ApiOauthAuthorize'));
|
||||
array('action' => 'ApiOAuthAuthorize'));
|
||||
|
||||
// Admin
|
||||
|
||||
|
@ -738,7 +738,7 @@ class OpenIDPlugin extends Plugin
|
||||
oid_assert_allowed($openid_url);
|
||||
|
||||
$returnto = common_local_url(
|
||||
'ApiOauthAuthorize',
|
||||
'ApiOAuthAuthorize',
|
||||
array(),
|
||||
array(
|
||||
'oauth_token' => $action->arg('oauth_token'),
|
||||
|
Loading…
Reference in New Issue
Block a user