From c78351f749e1a8fa843f97b9612244f44d7b76de Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Mon, 4 Apr 2011 16:37:38 -0500 Subject: [PATCH 01/35] Added base controller for demos and description file --- classes/controller/oauth/demo.php | 130 ++++++++++++++++++++++++++++++ views/demo/oauth/index.php | 15 ++++ 2 files changed, 145 insertions(+) create mode 100644 classes/controller/oauth/demo.php create mode 100644 views/demo/oauth/index.php diff --git a/classes/controller/oauth/demo.php b/classes/controller/oauth/demo.php new file mode 100644 index 0000000..161b9c0 --- /dev/null +++ b/classes/controller/oauth/demo.php @@ -0,0 +1,130 @@ +session = Session::instance('cookie'); + + // Get the name of the demo from the class name + $provider = strtolower($this->api); + + // Load the provider + $this->provider = OAuth_Provider::factory($provider); + + // Load the consumer + $this->consumer = OAuth_Consumer::factory(Kohana::config("oauth.{$provider}")); + + if ($token = $this->session->get($this->key('access'))) + { + // Make the access token available + $this->token = $token; + } + } + + public function key($name) + { + return "demo_{$this->provider->name}_{$name}"; + } + + public function demo_login() + { + // Attempt to complete signin + if ($verifier = Arr::get($_REQUEST, 'oauth_verifier')) + { + if ( ! $token = $this->session->get($this->key('request')) OR $token->token !== Arr::get($_REQUEST, 'oauth_token')) + { + // Token is invalid + $this->session->delete($this->key('request')); + + // Restart the login process + $this->request->redirect($this->request->uri); + } + + // Store the verifier in the token + $token->verifier($verifier); + + // Exchange the request token for an access token + $token = $this->provider->access_token($this->consumer, $token); + + // Store the access token + $this->session->set($this->key('access'), $token); + + // Request token is no longer needed + $this->session->delete($this->key('request')); + + // Refresh the page to prevent errors + $this->request->redirect($this->request->uri); + } + + if ($this->token) + { + // Login succesful + $this->content = Kohana::debug('Access token granted:', $this->token); + } + else + { + // We will need a callback URL for the user to return to + $callback = $this->request->url(NULL, TRUE); + + // Add the callback URL to the consumer + $this->consumer->callback($callback); + + // Get a request token for the consumer + $token = $this->provider->request_token($this->consumer); + + // Get the login URL from the provider + $url = $this->provider->authorize_url($token); + + // Store the token + $this->session->set($this->key('request'), $token); + + // Redirect to the twitter login page + $this->content = HTML::anchor($url, "Login to {$this->api}"); + } + } + + public function demo_logout() + { + if (Arr::get($_GET, 'confirm')) + { + // Delete the access token + $this->session->delete($this->key('request'), $this->key('access')); + + // Redirect to the demo list + $this->request->redirect($this->request->uri(array('action' => FALSE, 'id' => FALSE))); + } + + $this->content = HTML::anchor("{$this->request->uri}?confirm=yes", "Logout of {$this->api}"); + } + +} // End Demo diff --git a/views/demo/oauth/index.php b/views/demo/oauth/index.php new file mode 100644 index 0000000..b44fd4c --- /dev/null +++ b/views/demo/oauth/index.php @@ -0,0 +1,15 @@ +

OAuth Demo

+ +

This demo makes use of the OAuth Module for Kohana. + +

Demo Variables

+
+
$this->provider
+
OAuth_Provider instance for the current demo
+ +
$this->consumer
+
OAuth_Consumer instance for the provider
+ +
$this->token
+
OAuth_Token_Access instance, when authenticated
+
From d7336a696ded2516ef9c0af38bf46a2004d361c6 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 01:16:03 -0500 Subject: [PATCH 02/35] Renamed OAuth_Demo to Demo_OAuth --- classes/controller/{oauth/demo.php => demo/oauth.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename classes/controller/{oauth/demo.php => demo/oauth.php} (98%) diff --git a/classes/controller/oauth/demo.php b/classes/controller/demo/oauth.php similarity index 98% rename from classes/controller/oauth/demo.php rename to classes/controller/demo/oauth.php index 161b9c0..bf147c1 100644 --- a/classes/controller/oauth/demo.php +++ b/classes/controller/demo/oauth.php @@ -11,7 +11,7 @@ * @license http://kohanaframework.org/license * @since 3.1.3 */ -abstract class Controller_OAuth_Demo extends Controller_Demo { +abstract class Controller_Demo_OAuth extends Controller_Demo { /** * @var object OAuth_Provider From 41c0d0d7c16be5cb9c079c3a09ee5ee688809b9d Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 12:03:03 -0500 Subject: [PATCH 03/35] Fixed permissions on OAuth files --- classes/kohana/oauth.php | 0 classes/kohana/oauth/consumer.php | 0 classes/kohana/oauth/exception.php | 0 classes/kohana/oauth/request.php | 0 classes/kohana/oauth/request/access.php | 0 classes/kohana/oauth/request/authorize.php | 0 classes/kohana/oauth/request/credentials.php | 0 classes/kohana/oauth/request/resource.php | 0 classes/kohana/oauth/response.php | 0 classes/kohana/oauth/server.php | 0 classes/kohana/oauth/signature.php | 0 classes/kohana/oauth/token.php | 0 12 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 classes/kohana/oauth.php mode change 100755 => 100644 classes/kohana/oauth/consumer.php mode change 100755 => 100644 classes/kohana/oauth/exception.php mode change 100755 => 100644 classes/kohana/oauth/request.php mode change 100755 => 100644 classes/kohana/oauth/request/access.php mode change 100755 => 100644 classes/kohana/oauth/request/authorize.php mode change 100755 => 100644 classes/kohana/oauth/request/credentials.php mode change 100755 => 100644 classes/kohana/oauth/request/resource.php mode change 100755 => 100644 classes/kohana/oauth/response.php mode change 100755 => 100644 classes/kohana/oauth/server.php mode change 100755 => 100644 classes/kohana/oauth/signature.php mode change 100755 => 100644 classes/kohana/oauth/token.php diff --git a/classes/kohana/oauth.php b/classes/kohana/oauth.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/consumer.php b/classes/kohana/oauth/consumer.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/exception.php b/classes/kohana/oauth/exception.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/request.php b/classes/kohana/oauth/request.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/request/access.php b/classes/kohana/oauth/request/access.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/request/authorize.php b/classes/kohana/oauth/request/authorize.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/request/credentials.php b/classes/kohana/oauth/request/credentials.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/request/resource.php b/classes/kohana/oauth/request/resource.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/response.php b/classes/kohana/oauth/response.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/server.php b/classes/kohana/oauth/server.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/signature.php b/classes/kohana/oauth/signature.php old mode 100755 new mode 100644 diff --git a/classes/kohana/oauth/token.php b/classes/kohana/oauth/token.php old mode 100755 new mode 100644 From 56d62a80df5e8289ffa179c0f63e23aa31083dc3 Mon Sep 17 00:00:00 2001 From: biakaveron Date: Tue, 5 Apr 2011 11:54:52 +0400 Subject: [PATCH 04/35] Implemented OAuth v2 Signed-off-by: Woody Gilk --- classes/kohana/oauth/v2.php | 48 +++++++++++ classes/kohana/oauth/v2/provider.php | 80 +++++++++++++++++++ classes/kohana/oauth/v2/provider/github.php | 30 +++++++ classes/kohana/oauth/v2/request.php | 37 +++++++++ classes/kohana/oauth/v2/request/authorize.php | 9 +++ .../kohana/oauth/v2/request/credentials.php | 6 ++ classes/kohana/oauth/v2/request/token.php | 11 +++ classes/kohana/oauth/v2/token.php | 21 +++++ classes/kohana/oauth/v2/token/access.php | 10 +++ classes/oauth/v2.php | 3 + classes/oauth/v2/provider.php | 3 + classes/oauth/v2/provider/github.php | 3 + classes/oauth/v2/request.php | 3 + classes/oauth/v2/request/authorize.php | 3 + classes/oauth/v2/request/credentials.php | 3 + classes/oauth/v2/request/token.php | 3 + classes/oauth/v2/token.php | 3 + classes/oauth/v2/token/access.php | 3 + 18 files changed, 279 insertions(+) create mode 100644 classes/kohana/oauth/v2.php create mode 100644 classes/kohana/oauth/v2/provider.php create mode 100644 classes/kohana/oauth/v2/provider/github.php create mode 100644 classes/kohana/oauth/v2/request.php create mode 100644 classes/kohana/oauth/v2/request/authorize.php create mode 100644 classes/kohana/oauth/v2/request/credentials.php create mode 100644 classes/kohana/oauth/v2/request/token.php create mode 100644 classes/kohana/oauth/v2/token.php create mode 100644 classes/kohana/oauth/v2/token/access.php create mode 100644 classes/oauth/v2.php create mode 100644 classes/oauth/v2/provider.php create mode 100644 classes/oauth/v2/provider/github.php create mode 100644 classes/oauth/v2/request.php create mode 100644 classes/oauth/v2/request/authorize.php create mode 100644 classes/oauth/v2/request/credentials.php create mode 100644 classes/oauth/v2/request/token.php create mode 100644 classes/oauth/v2/token.php create mode 100644 classes/oauth/v2/token/access.php diff --git a/classes/kohana/oauth/v2.php b/classes/kohana/oauth/v2.php new file mode 100644 index 0000000..5e465eb --- /dev/null +++ b/classes/kohana/oauth/v2.php @@ -0,0 +1,48 @@ +url_access_token(); + } + + public function request_token(OAuth_Consumer $consumer, array $params = NULL) + { + // Create a new GET request for a request token with the required parameters + $request = OAuth_v2_Request::factory('authorize', 'GET', $this->url_authorize(), array( + 'response_type' => 'code', + 'client_id' => $consumer->key(), + 'redirect_uri' => $consumer->callback(), + )); + + if ($params) + { + // Load user parameters + $request->params($params); + } + + // Execute request (will redirect to OAuth server) + $request->execute(); + } + + public function access_token(OAuth_Consumer $consumer, $code, array $params = NULL) + { + $params = (array)$params + array( + 'grant_type' => 'authorization_code', + 'client_id' => $consumer->key(), + 'code' => $code, + ); + + if ($secret = $consumer->secret()) + { + $params['client_secret'] = $secret; + } + + $request = OAuth_v2_Request::factory('token', 'POST', $this->url_access_token(), $params); + + $response = $request->execute(); + return OAuth_v2_Token::factory('access', array( + 'token' => $response->param('access_token') + )); + } + + public function verify_credentials(OAuth_v2_Token_Access $token, OAuth_Consumer $consumer) + { + $request = OAuth_v2_Request::factory('credentials', 'GET', $this->url_verify_credentials(), array( + 'oauth_consumer_key' => $consumer->key(), + 'oauth_token' => $token->token(), + )); + + return $request->execute(); + } + +} diff --git a/classes/kohana/oauth/v2/provider/github.php b/classes/kohana/oauth/v2/provider/github.php new file mode 100644 index 0000000..af88ac6 --- /dev/null +++ b/classes/kohana/oauth/v2/provider/github.php @@ -0,0 +1,30 @@ +url_verify_credentials(), array( + 'access_token' => $token->token(), + )); + + return json_decode($request->execute()); + } +} \ No newline at end of file diff --git a/classes/kohana/oauth/v2/request.php b/classes/kohana/oauth/v2/request.php new file mode 100644 index 0000000..65a157b --- /dev/null +++ b/classes/kohana/oauth/v2/request.php @@ -0,0 +1,37 @@ +redirect($this->_url.'?'.$this->as_query()); + } +} \ No newline at end of file diff --git a/classes/kohana/oauth/v2/request/credentials.php b/classes/kohana/oauth/v2/request/credentials.php new file mode 100644 index 0000000..4499caf --- /dev/null +++ b/classes/kohana/oauth/v2/request/credentials.php @@ -0,0 +1,6 @@ + Date: Wed, 13 Apr 2011 00:56:29 -0500 Subject: [PATCH 05/35] Rename all v2 class files from oauth/v2 to oauth2 --- classes/kohana/{oauth/v2.php => oauth2.php} | 0 classes/kohana/{oauth/v2 => oauth2}/provider.php | 0 classes/kohana/{oauth/v2 => oauth2}/provider/github.php | 0 classes/kohana/{oauth/v2 => oauth2}/request.php | 0 classes/kohana/{oauth/v2 => oauth2}/request/authorize.php | 0 classes/kohana/{oauth/v2 => oauth2}/request/credentials.php | 0 classes/kohana/{oauth/v2 => oauth2}/request/token.php | 0 classes/kohana/{oauth/v2 => oauth2}/token.php | 0 classes/kohana/{oauth/v2 => oauth2}/token/access.php | 0 classes/{oauth/v2.php => oauth2.php} | 0 classes/{oauth/v2 => oauth2}/provider.php | 0 classes/{oauth/v2 => oauth2}/provider/github.php | 0 classes/{oauth/v2 => oauth2}/request.php | 0 classes/{oauth/v2 => oauth2}/request/authorize.php | 0 classes/{oauth/v2 => oauth2}/request/credentials.php | 0 classes/{oauth/v2 => oauth2}/request/token.php | 0 classes/{oauth/v2 => oauth2}/token.php | 0 classes/{oauth/v2 => oauth2}/token/access.php | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename classes/kohana/{oauth/v2.php => oauth2.php} (100%) rename classes/kohana/{oauth/v2 => oauth2}/provider.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/provider/github.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/request.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/request/authorize.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/request/credentials.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/request/token.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/token.php (100%) rename classes/kohana/{oauth/v2 => oauth2}/token/access.php (100%) rename classes/{oauth/v2.php => oauth2.php} (100%) rename classes/{oauth/v2 => oauth2}/provider.php (100%) rename classes/{oauth/v2 => oauth2}/provider/github.php (100%) rename classes/{oauth/v2 => oauth2}/request.php (100%) rename classes/{oauth/v2 => oauth2}/request/authorize.php (100%) rename classes/{oauth/v2 => oauth2}/request/credentials.php (100%) rename classes/{oauth/v2 => oauth2}/request/token.php (100%) rename classes/{oauth/v2 => oauth2}/token.php (100%) rename classes/{oauth/v2 => oauth2}/token/access.php (100%) diff --git a/classes/kohana/oauth/v2.php b/classes/kohana/oauth2.php similarity index 100% rename from classes/kohana/oauth/v2.php rename to classes/kohana/oauth2.php diff --git a/classes/kohana/oauth/v2/provider.php b/classes/kohana/oauth2/provider.php similarity index 100% rename from classes/kohana/oauth/v2/provider.php rename to classes/kohana/oauth2/provider.php diff --git a/classes/kohana/oauth/v2/provider/github.php b/classes/kohana/oauth2/provider/github.php similarity index 100% rename from classes/kohana/oauth/v2/provider/github.php rename to classes/kohana/oauth2/provider/github.php diff --git a/classes/kohana/oauth/v2/request.php b/classes/kohana/oauth2/request.php similarity index 100% rename from classes/kohana/oauth/v2/request.php rename to classes/kohana/oauth2/request.php diff --git a/classes/kohana/oauth/v2/request/authorize.php b/classes/kohana/oauth2/request/authorize.php similarity index 100% rename from classes/kohana/oauth/v2/request/authorize.php rename to classes/kohana/oauth2/request/authorize.php diff --git a/classes/kohana/oauth/v2/request/credentials.php b/classes/kohana/oauth2/request/credentials.php similarity index 100% rename from classes/kohana/oauth/v2/request/credentials.php rename to classes/kohana/oauth2/request/credentials.php diff --git a/classes/kohana/oauth/v2/request/token.php b/classes/kohana/oauth2/request/token.php similarity index 100% rename from classes/kohana/oauth/v2/request/token.php rename to classes/kohana/oauth2/request/token.php diff --git a/classes/kohana/oauth/v2/token.php b/classes/kohana/oauth2/token.php similarity index 100% rename from classes/kohana/oauth/v2/token.php rename to classes/kohana/oauth2/token.php diff --git a/classes/kohana/oauth/v2/token/access.php b/classes/kohana/oauth2/token/access.php similarity index 100% rename from classes/kohana/oauth/v2/token/access.php rename to classes/kohana/oauth2/token/access.php diff --git a/classes/oauth/v2.php b/classes/oauth2.php similarity index 100% rename from classes/oauth/v2.php rename to classes/oauth2.php diff --git a/classes/oauth/v2/provider.php b/classes/oauth2/provider.php similarity index 100% rename from classes/oauth/v2/provider.php rename to classes/oauth2/provider.php diff --git a/classes/oauth/v2/provider/github.php b/classes/oauth2/provider/github.php similarity index 100% rename from classes/oauth/v2/provider/github.php rename to classes/oauth2/provider/github.php diff --git a/classes/oauth/v2/request.php b/classes/oauth2/request.php similarity index 100% rename from classes/oauth/v2/request.php rename to classes/oauth2/request.php diff --git a/classes/oauth/v2/request/authorize.php b/classes/oauth2/request/authorize.php similarity index 100% rename from classes/oauth/v2/request/authorize.php rename to classes/oauth2/request/authorize.php diff --git a/classes/oauth/v2/request/credentials.php b/classes/oauth2/request/credentials.php similarity index 100% rename from classes/oauth/v2/request/credentials.php rename to classes/oauth2/request/credentials.php diff --git a/classes/oauth/v2/request/token.php b/classes/oauth2/request/token.php similarity index 100% rename from classes/oauth/v2/request/token.php rename to classes/oauth2/request/token.php diff --git a/classes/oauth/v2/token.php b/classes/oauth2/token.php similarity index 100% rename from classes/oauth/v2/token.php rename to classes/oauth2/token.php diff --git a/classes/oauth/v2/token/access.php b/classes/oauth2/token/access.php similarity index 100% rename from classes/oauth/v2/token/access.php rename to classes/oauth2/token/access.php From 65550f65ea165b156e0dddd596a3fa868b2f3bae Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 00:57:20 -0500 Subject: [PATCH 06/35] Redeclare all OAuth_v2 classes as OAuth2 --- classes/kohana/oauth2.php | 14 +++++++------- classes/kohana/oauth2/provider.php | 14 +++++++------- classes/kohana/oauth2/provider/github.php | 6 +++--- classes/kohana/oauth2/request.php | 6 +++--- classes/kohana/oauth2/request/authorize.php | 2 +- classes/kohana/oauth2/request/credentials.php | 2 +- classes/kohana/oauth2/request/token.php | 2 +- classes/kohana/oauth2/token.php | 8 ++++---- classes/kohana/oauth2/token/access.php | 2 +- classes/oauth2.php | 2 +- classes/oauth2/provider.php | 2 +- classes/oauth2/provider/github.php | 2 +- classes/oauth2/request.php | 2 +- classes/oauth2/request/authorize.php | 2 +- classes/oauth2/request/credentials.php | 2 +- classes/oauth2/request/token.php | 2 +- classes/oauth2/token.php | 2 +- classes/oauth2/token/access.php | 2 +- 18 files changed, 37 insertions(+), 37 deletions(-) diff --git a/classes/kohana/oauth2.php b/classes/kohana/oauth2.php index 5e465eb..6b15015 100644 --- a/classes/kohana/oauth2.php +++ b/classes/kohana/oauth2.php @@ -9,7 +9,7 @@ * @license http://kohanaframework.org/license * @since 3.0.7 */ -abstract class Kohana_OAuth_v2 extends OAuth { +abstract class Kohana_OAuth2 extends OAuth { /** * Get request object @@ -18,31 +18,31 @@ abstract class Kohana_OAuth_v2 extends OAuth { * @param string Request method (POST, GET) * @param string URL * @param array Request params - * @return OAuth_v2_Request + * @return OAuth2_Request */ public function request($type, $method, $url, array $options = NULL) { - return OAuth_v2_Request::factory($type, $method, $url, $options); + return OAuth2_Request::factory($type, $method, $url, $options); } /** * @param $name Provider name * @param array Provider options - * @return OAuth_v2_Provider + * @return OAuth2_Provider */ public function provider($name, array $options = NULL) { - return OAuth_v2_Provider::factory($name, $options); + return OAuth2_Provider::factory($name, $options); } /** * @param $name Token type * @param array Token options - * @return OAuth_v2_Token + * @return OAuth2_Token */ public function token($name, array $options = NULL) { - return OAuth_v2_Token::factory($name, $options); + return OAuth2_Token::factory($name, $options); } } \ No newline at end of file diff --git a/classes/kohana/oauth2/provider.php b/classes/kohana/oauth2/provider.php index 75669b8..377b2e3 100644 --- a/classes/kohana/oauth2/provider.php +++ b/classes/kohana/oauth2/provider.php @@ -1,10 +1,10 @@ url_authorize(), array( + $request = OAuth2_Request::factory('authorize', 'GET', $this->url_authorize(), array( 'response_type' => 'code', 'client_id' => $consumer->key(), 'redirect_uri' => $consumer->callback(), @@ -59,17 +59,17 @@ public function access_token(OAuth_Consumer $consumer, $code, array $params = NU $params['client_secret'] = $secret; } - $request = OAuth_v2_Request::factory('token', 'POST', $this->url_access_token(), $params); + $request = OAuth2_Request::factory('token', 'POST', $this->url_access_token(), $params); $response = $request->execute(); - return OAuth_v2_Token::factory('access', array( + return OAuth2_Token::factory('access', array( 'token' => $response->param('access_token') )); } - public function verify_credentials(OAuth_v2_Token_Access $token, OAuth_Consumer $consumer) + public function verify_credentials(OAuth2_Token_Access $token, OAuth_Consumer $consumer) { - $request = OAuth_v2_Request::factory('credentials', 'GET', $this->url_verify_credentials(), array( + $request = OAuth2_Request::factory('credentials', 'GET', $this->url_verify_credentials(), array( 'oauth_consumer_key' => $consumer->key(), 'oauth_token' => $token->token(), )); diff --git a/classes/kohana/oauth2/provider/github.php b/classes/kohana/oauth2/provider/github.php index af88ac6..6d4ed79 100644 --- a/classes/kohana/oauth2/provider/github.php +++ b/classes/kohana/oauth2/provider/github.php @@ -1,6 +1,6 @@ url_verify_credentials(), array( + $request = OAuth2_Request::factory('credentials', 'GET', $this->url_verify_credentials(), array( 'access_token' => $token->token(), )); diff --git a/classes/kohana/oauth2/request.php b/classes/kohana/oauth2/request.php index 65a157b..9779b00 100644 --- a/classes/kohana/oauth2/request.php +++ b/classes/kohana/oauth2/request.php @@ -9,7 +9,7 @@ * @license http://kohanaframework.org/license * @since 3.0.7 */ -abstract class Kohana_OAuth_v2_Request extends OAuth_Request { +abstract class Kohana_OAuth2_Request extends OAuth_Request { /** * @static @@ -17,11 +17,11 @@ abstract class Kohana_OAuth_v2_Request extends OAuth_Request { * @param string $method * @param string $url * @param array $params - * @return OAuth_v2_Request + * @return OAuth2_Request */ public static function factory($type, $method, $url = NULL, array $params = NULL) { - $class = 'OAuth_v2_Request_'.$type; + $class = 'OAuth2_Request_'.$type; return new $class($method, $url, $params); } diff --git a/classes/kohana/oauth2/request/authorize.php b/classes/kohana/oauth2/request/authorize.php index c9e834f..41ccb79 100644 --- a/classes/kohana/oauth2/request/authorize.php +++ b/classes/kohana/oauth2/request/authorize.php @@ -1,6 +1,6 @@ Date: Wed, 13 Apr 2011 01:01:53 -0500 Subject: [PATCH 07/35] Remove verify_credentials from OAuth2 provider abstract and providers, it is not included in the OAuth2 spec. --- classes/kohana/oauth2/provider.php | 18 +----------------- classes/kohana/oauth2/provider/github.php | 13 ------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/classes/kohana/oauth2/provider.php b/classes/kohana/oauth2/provider.php index 377b2e3..2386c30 100644 --- a/classes/kohana/oauth2/provider.php +++ b/classes/kohana/oauth2/provider.php @@ -10,14 +10,8 @@ public static function factory($name, array $options = NULL) } abstract public function url_authorize(); + abstract public function url_access_token(array $params = NULL); - /** - * Returns the account info url - * - * @param array $params - * @return string - */ - abstract public function url_verify_credentials(array $params = NULL); public $name; @@ -67,14 +61,4 @@ public function access_token(OAuth_Consumer $consumer, $code, array $params = NU )); } - public function verify_credentials(OAuth2_Token_Access $token, OAuth_Consumer $consumer) - { - $request = OAuth2_Request::factory('credentials', 'GET', $this->url_verify_credentials(), array( - 'oauth_consumer_key' => $consumer->key(), - 'oauth_token' => $token->token(), - )); - - return $request->execute(); - } - } diff --git a/classes/kohana/oauth2/provider/github.php b/classes/kohana/oauth2/provider/github.php index 6d4ed79..c3dc660 100644 --- a/classes/kohana/oauth2/provider/github.php +++ b/classes/kohana/oauth2/provider/github.php @@ -14,17 +14,4 @@ public function url_access_token(array $params = NULL) return 'https://github.com/login/oauth/access_token'; } - public function url_verify_credentials(array $params = NULL) - { - return 'https://github.com/api/v2/json/user/show'; - } - - public function verify_credentials(OAuth2_Token_Access $token, OAuth_Consumer $consumer) - { - $request = OAuth2_Request::factory('credentials', 'GET', $this->url_verify_credentials(), array( - 'access_token' => $token->token(), - )); - - return json_decode($request->execute()); - } } \ No newline at end of file From bb7b9055505ed4c96bc1072b9168f205e77753f4 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 11:25:07 -0500 Subject: [PATCH 08/35] Cleaning up OAuth2 classes, fixing formatting and line endings --- classes/kohana/oauth2.php | 2 +- classes/kohana/oauth2/provider.php | 23 ++++++++++--------- classes/kohana/oauth2/provider/github.php | 4 ++-- classes/kohana/oauth2/request.php | 9 +++----- classes/kohana/oauth2/request/authorize.php | 7 ++++-- classes/kohana/oauth2/request/credentials.php | 5 ++-- classes/kohana/oauth2/request/token.php | 5 ++-- classes/kohana/oauth2/token.php | 2 +- classes/kohana/oauth2/token/access.php | 9 ++++---- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/classes/kohana/oauth2.php b/classes/kohana/oauth2.php index 6b15015..36711e8 100644 --- a/classes/kohana/oauth2.php +++ b/classes/kohana/oauth2.php @@ -45,4 +45,4 @@ public function token($name, array $options = NULL) return OAuth2_Token::factory($name, $options); } -} \ No newline at end of file +} diff --git a/classes/kohana/oauth2/provider.php b/classes/kohana/oauth2/provider.php index 2386c30..71290bd 100644 --- a/classes/kohana/oauth2/provider.php +++ b/classes/kohana/oauth2/provider.php @@ -11,7 +11,7 @@ public static function factory($name, array $options = NULL) abstract public function url_authorize(); - abstract public function url_access_token(array $params = NULL); + abstract public function url_access_token(); public $name; @@ -26,8 +26,8 @@ public function request_token(OAuth_Consumer $consumer, array $params = NULL) // Create a new GET request for a request token with the required parameters $request = OAuth2_Request::factory('authorize', 'GET', $this->url_authorize(), array( 'response_type' => 'code', - 'client_id' => $consumer->key(), - 'redirect_uri' => $consumer->callback(), + 'client_id' => $consumer->id, + 'redirect_uri' => $consumer->callback, )); if ($params) @@ -42,22 +42,23 @@ public function request_token(OAuth_Consumer $consumer, array $params = NULL) public function access_token(OAuth_Consumer $consumer, $code, array $params = NULL) { - $params = (array)$params + array( + $request = OAuth2_Request::factory('token', 'POST', $this->url_access_token(), array( 'grant_type' => 'authorization_code', - 'client_id' => $consumer->key(), 'code' => $code, - ); + 'client_id' => $consumer->id, + 'client_secret' => $consumer->secret, + )); - if ($secret = $consumer->secret()) + if ($params) { - $params['client_secret'] = $secret; + // Load user parameters + $request->params($params); } - $request = OAuth2_Request::factory('token', 'POST', $this->url_access_token(), $params); - $response = $request->execute(); + return OAuth2_Token::factory('access', array( - 'token' => $response->param('access_token') + 'token' => $response->param('access_token') )); } diff --git a/classes/kohana/oauth2/provider/github.php b/classes/kohana/oauth2/provider/github.php index c3dc660..1563800 100644 --- a/classes/kohana/oauth2/provider/github.php +++ b/classes/kohana/oauth2/provider/github.php @@ -9,9 +9,9 @@ public function url_authorize() return 'https://github.com/login/oauth/authorize'; } - public function url_access_token(array $params = NULL) + public function url_access_token() { return 'https://github.com/login/oauth/access_token'; } -} \ No newline at end of file +} diff --git a/classes/kohana/oauth2/request.php b/classes/kohana/oauth2/request.php index 9779b00..a090566 100644 --- a/classes/kohana/oauth2/request.php +++ b/classes/kohana/oauth2/request.php @@ -22,16 +22,13 @@ abstract class Kohana_OAuth2_Request extends OAuth_Request { public static function factory($type, $method, $url = NULL, array $params = NULL) { $class = 'OAuth2_Request_'.$type; + return new $class($method, $url, $params); } - /** - * @var string OAuth complaince version - */ - protected $_version = '2.0'; - /** * @var boolean send Authorization header? */ - protected $_send_header = FALSE; + public $send_header = FALSE; + } diff --git a/classes/kohana/oauth2/request/authorize.php b/classes/kohana/oauth2/request/authorize.php index 41ccb79..31b09b5 100644 --- a/classes/kohana/oauth2/request/authorize.php +++ b/classes/kohana/oauth2/request/authorize.php @@ -2,8 +2,11 @@ abstract class Kohana_OAuth2_Request_Authorize extends OAuth2_Request { + protected $name = 'authorize'; + public function execute(array $options = NULL) { - Request::$initial->redirect($this->_url.'?'.$this->as_query()); + return Request::current()->redirect($this->as_url()); } -} \ No newline at end of file + +} diff --git a/classes/kohana/oauth2/request/credentials.php b/classes/kohana/oauth2/request/credentials.php index 0a35f5a..3b82bc3 100644 --- a/classes/kohana/oauth2/request/credentials.php +++ b/classes/kohana/oauth2/request/credentials.php @@ -2,5 +2,6 @@ abstract class Kohana_OAuth2_Request_Credentials extends OAuth2_Request { - protected $_name = 'credentials'; -} \ No newline at end of file + protected $name = 'credentials'; + +} diff --git a/classes/kohana/oauth2/request/token.php b/classes/kohana/oauth2/request/token.php index 3d7fe47..59d6497 100644 --- a/classes/kohana/oauth2/request/token.php +++ b/classes/kohana/oauth2/request/token.php @@ -2,10 +2,11 @@ abstract class Kohana_OAuth2_Request_Token extends OAuth2_Request { - protected $_name = 'token'; + protected $name = 'token'; public function execute(array $options = NULL) { return OAuth_Response::factory(parent::execute($options)); } -} \ No newline at end of file + +} diff --git a/classes/kohana/oauth2/token.php b/classes/kohana/oauth2/token.php index 0cd153d..fc640f8 100644 --- a/classes/kohana/oauth2/token.php +++ b/classes/kohana/oauth2/token.php @@ -18,4 +18,4 @@ public static function factory($name, array $options = NULL) return new $class($options); } -} \ No newline at end of file +} diff --git a/classes/kohana/oauth2/token/access.php b/classes/kohana/oauth2/token/access.php index 6006ae3..17f14c2 100644 --- a/classes/kohana/oauth2/token/access.php +++ b/classes/kohana/oauth2/token/access.php @@ -2,9 +2,10 @@ abstract class Kohana_OAuth2_Token_Access extends OAuth2_Token { - protected $_name = 'access'; + protected $name = 'access'; - protected $_required = array( - 'token' + protected $required = array( + 'token', ); -} \ No newline at end of file + +} From 48d3060d4dac54780def9dad74e427482debfedb Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 11:26:11 -0500 Subject: [PATCH 09/35] Added OAuth2 example to config/oauth --- config/oauth.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config/oauth.php b/config/oauth.php index 3db6d30..1ffa654 100644 --- a/config/oauth.php +++ b/config/oauth.php @@ -8,8 +8,17 @@ * You will be given a "consumer key" and "consumer secret", which must * be provided when making OAuth requests. */ - 'twitter' => array( - 'key' => 'your consumer key', - 'secret' => 'your consumer secret' - ), + // 'twitter' => array( + // 'key' => 'your consumer key', + // 'secret' => 'your consumer secret' + // ), + /** + * Github applications can be registered at https://github.com/account/applications/new. + * You will be given a "client id" and "client secret", which must + * be provided when making OAuth2 requests. + */ + // 'github' => array( + // 'id' => 'your client id', + // 'secret' => 'your client secret' + // ), ); \ No newline at end of file From 06cfa23fb7de3c5e95de213128549f6350b6871e Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 11:57:38 -0500 Subject: [PATCH 10/35] Modify OAuth_Token to have a configured set of required options --- classes/kohana/oauth/token.php | 25 +++++++++++-------------- classes/kohana/oauth/token/access.php | 10 ++++++++++ classes/kohana/oauth/token/request.php | 10 ++++++++++ classes/kohana/oauth2/token/access.php | 4 ---- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/classes/kohana/oauth/token.php b/classes/kohana/oauth/token.php index b474098..fadf830 100644 --- a/classes/kohana/oauth/token.php +++ b/classes/kohana/oauth/token.php @@ -38,9 +38,11 @@ public static function factory($name, array $options = NULL) protected $token; /** - * @var string token secret + * @var string required parameters */ - protected $secret; + protected $required = array( + 'token', + ); /** * Sets the token and secret values. @@ -50,21 +52,16 @@ public static function factory($name, array $options = NULL) */ public function __construct(array $options = NULL) { - if ( ! isset($options['token'])) + foreach ($this->required as $key) { - throw new Kohana_OAuth_Exception('Required option not passed: :option', - array(':option' => 'token')); - } + if ( ! isset($options[$key])) + { + throw new Kohana_OAuth_Exception('Required option not passed: :option', + array(':option' => $key)); + } - if ( ! isset($options['secret'])) - { - throw new Kohana_OAuth_Exception('Required option not passed: :option', - array(':option' => 'secret')); + $this->$key = $options[$key]; } - - $this->token = $options['token']; - - $this->secret = $options['secret']; } /** diff --git a/classes/kohana/oauth/token/access.php b/classes/kohana/oauth/token/access.php index 7d0564d..7ad811e 100644 --- a/classes/kohana/oauth/token/access.php +++ b/classes/kohana/oauth/token/access.php @@ -13,4 +13,14 @@ class Kohana_OAuth_Token_Access extends OAuth_Token { protected $name = 'access'; + /** + * @var string token secret + */ + protected $secret; + + protected $required = array( + 'token', + 'secret', + ); + } // End OAuth_Token_Access diff --git a/classes/kohana/oauth/token/request.php b/classes/kohana/oauth/token/request.php index 0c4278e..f423f07 100644 --- a/classes/kohana/oauth/token/request.php +++ b/classes/kohana/oauth/token/request.php @@ -13,11 +13,21 @@ class Kohana_OAuth_Token_Request extends OAuth_Token { protected $name = 'request'; + /** + * @var string token secret + */ + protected $secret; + /** * @var string request token verifier */ protected $verifier; + protected $required = array( + 'token', + 'secret', + ); + /** * Change the token verifier. * diff --git a/classes/kohana/oauth2/token/access.php b/classes/kohana/oauth2/token/access.php index 17f14c2..5f8b1c3 100644 --- a/classes/kohana/oauth2/token/access.php +++ b/classes/kohana/oauth2/token/access.php @@ -4,8 +4,4 @@ abstract class Kohana_OAuth2_Token_Access extends OAuth2_Token { protected $name = 'access'; - protected $required = array( - 'token', - ); - } From ddbc97a7b18307454b3efe371d0dce79f2e66df1 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 12:00:07 -0500 Subject: [PATCH 11/35] OAuth2 refers to "clients" instead of "consumers", uses "id" instead of "key" --- classes/kohana/oauth2/client.php | 90 ++++++++++++++++++++++++++++++ classes/kohana/oauth2/provider.php | 15 +++-- classes/oauth2/client.php | 3 + 3 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 classes/kohana/oauth2/client.php create mode 100644 classes/oauth2/client.php diff --git a/classes/kohana/oauth2/client.php b/classes/kohana/oauth2/client.php new file mode 100644 index 0000000..7a4612d --- /dev/null +++ b/classes/kohana/oauth2/client.php @@ -0,0 +1,90 @@ + 'id')); + } + + if ( ! isset($options['secret'])) + { + throw new Kohana_OAuth_Exception('Required option not passed: :option', + array(':option' => 'secret')); + } + + $this->id = $options['id']; + + $this->secret = $options['secret']; + + if (isset($options['callback'])) + { + $this->callback = $options['callback']; + } + } + + /** + * Return the value of any protected class variable. + * + * // Get the client key + * $key = $client->key; + * + * @param string variable name + * @return mixed + */ + public function __get($key) + { + return $this->$key; + } + + /** + * Change the client callback. + * + * @param string new consumer callback + * @return $this + */ + public function callback($callback) + { + $this->callback = $callback; + + return $this; + } + +} diff --git a/classes/kohana/oauth2/provider.php b/classes/kohana/oauth2/provider.php index 71290bd..008322e 100644 --- a/classes/kohana/oauth2/provider.php +++ b/classes/kohana/oauth2/provider.php @@ -21,13 +21,13 @@ public function url_refresh_token() return $this->url_access_token(); } - public function request_token(OAuth_Consumer $consumer, array $params = NULL) + public function authorize_url(OAuth2_Client $client, array $params = NULL) { // Create a new GET request for a request token with the required parameters $request = OAuth2_Request::factory('authorize', 'GET', $this->url_authorize(), array( 'response_type' => 'code', - 'client_id' => $consumer->id, - 'redirect_uri' => $consumer->callback, + 'client_id' => $client->id, + 'redirect_uri' => $client->callback, )); if ($params) @@ -36,17 +36,16 @@ public function request_token(OAuth_Consumer $consumer, array $params = NULL) $request->params($params); } - // Execute request (will redirect to OAuth server) - $request->execute(); + return $request->as_url(); } - public function access_token(OAuth_Consumer $consumer, $code, array $params = NULL) + public function access_token(OAuth2_Client $client, $code, array $params = NULL) { $request = OAuth2_Request::factory('token', 'POST', $this->url_access_token(), array( 'grant_type' => 'authorization_code', 'code' => $code, - 'client_id' => $consumer->id, - 'client_secret' => $consumer->secret, + 'client_id' => $client->id, + 'client_secret' => $client->secret, )); if ($params) diff --git a/classes/oauth2/client.php b/classes/oauth2/client.php new file mode 100644 index 0000000..57b1ede --- /dev/null +++ b/classes/oauth2/client.php @@ -0,0 +1,3 @@ + Date: Wed, 13 Apr 2011 12:02:19 -0500 Subject: [PATCH 12/35] Added OAuth2 demo controller --- classes/controller/demo/oauth2.php | 109 +++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 classes/controller/demo/oauth2.php diff --git a/classes/controller/demo/oauth2.php b/classes/controller/demo/oauth2.php new file mode 100644 index 0000000..44fb261 --- /dev/null +++ b/classes/controller/demo/oauth2.php @@ -0,0 +1,109 @@ +session = Session::instance('cookie'); + + // Get the name of the demo from the class name + $provider = strtolower($this->api); + + // Load the provider + $this->provider = OAuth2_Provider::factory($provider); + + // Load the client + $this->client = OAuth2_Client::factory(Kohana::config("oauth.{$provider}")); + + if ($token = $this->session->get($this->key('access'))) + { + // Make the access token available + $this->token = $token; + } + } + + public function key($name) + { + return "demo_{$this->provider->name}_{$name}"; + } + + public function demo_login() + { + // Attempt to complete signin + if ($code = Arr::get($_REQUEST, 'code')) + { + // Exchange the authorization code for an access token + $token = $this->provider->access_token($this->client, $code); + + // Store the access token + $this->session->set($this->key('access'), $token); + + // Refresh the page to prevent errors + $this->request->redirect($this->request->uri); + } + + if ($this->token) + { + // Login succesful + $this->content = Kohana::debug('Access token granted:', $this->token); + } + else + { + // We will need a callback URL for the user to return to + $callback = $this->request->url(NULL, TRUE); + + // Add the callback URL to the consumer + $this->client->callback($callback); + + // Get the login URL from the provider + $url = $this->provider->authorize_url($this->client); + + // Redirect to the twitter login page + $this->content = HTML::anchor($url, "Login to {$this->api}"); + } + } + + public function demo_logout() + { + if (Arr::get($_GET, 'confirm')) + { + // Delete the access token + $this->session->delete($this->key('access')); + + // Redirect to the demo list + $this->request->redirect($this->request->uri(array('action' => FALSE, 'id' => FALSE))); + } + + $this->content = HTML::anchor("{$this->request->uri}?confirm=yes", "Logout of {$this->api}"); + } + +} // End Demo From 93b5bd33d0b4978aeb90061f257f0323e707bb4a Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Wed, 13 Apr 2011 12:26:03 -0500 Subject: [PATCH 13/35] 3.1 compatibility fix --- classes/kohana/oauth/request/authorize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/kohana/oauth/request/authorize.php b/classes/kohana/oauth/request/authorize.php index e31dc9b..2ce9037 100644 --- a/classes/kohana/oauth/request/authorize.php +++ b/classes/kohana/oauth/request/authorize.php @@ -20,7 +20,7 @@ class Kohana_OAuth_Request_Authorize extends OAuth_Request { public function execute(array $options = NULL) { - return Request::instance()->redirect($this->as_url()); + return Request::current()->redirect($this->as_url()); } } // End OAuth_Request_Authorize From 766637ce94a8a293028aecb541c6139e30b00e73 Mon Sep 17 00:00:00 2001 From: Brotkin Ivan Date: Wed, 20 Apr 2011 05:59:54 -0700 Subject: [PATCH 14/35] Added required params to OAuth v1 Request_Credentials class --- classes/kohana/oauth/request/credentials.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/kohana/oauth/request/credentials.php b/classes/kohana/oauth/request/credentials.php index ea65e31..90c4bbe 100644 --- a/classes/kohana/oauth/request/credentials.php +++ b/classes/kohana/oauth/request/credentials.php @@ -11,6 +11,14 @@ */ class Kohana_OAuth_Request_Credentials extends OAuth_Request { - + protected $required = array( + 'oauth_consumer_key' => TRUE, + 'oauth_token' => TRUE, + 'oauth_signature_method' => TRUE, + 'oauth_signature' => TRUE, + 'oauth_timestamp' => TRUE, + 'oauth_nonce' => TRUE, + 'oauth_version' => TRUE, + ); } // End OAuth_Request_Credentials From 7bb49d724f4c065acb520c65e1ed737f1324d811 Mon Sep 17 00:00:00 2001 From: biakaveron Date: Tue, 31 May 2011 00:41:46 +0400 Subject: [PATCH 15/35] OAuth2 Access_Request must sent redirect_uri if set --- classes/kohana/oauth2/provider.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/classes/kohana/oauth2/provider.php b/classes/kohana/oauth2/provider.php index 008322e..c1a50fb 100644 --- a/classes/kohana/oauth2/provider.php +++ b/classes/kohana/oauth2/provider.php @@ -48,6 +48,11 @@ public function access_token(OAuth2_Client $client, $code, array $params = NULL) 'client_secret' => $client->secret, )); + if ($client->callback) + { + $request->param('redirect_uri', $client->callback); + } + if ($params) { // Load user parameters From f635fbb2ea1c7605cb38bc846d2a45766861ce9f Mon Sep 17 00:00:00 2001 From: biakaveron Date: Tue, 31 May 2011 00:42:53 +0400 Subject: [PATCH 16/35] Added OAuth v2 Facebook driver --- classes/kohana/oauth2/provider/facebook.php | 18 ++++++++++++++++++ classes/oauth2/provider/facebook.php | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 classes/kohana/oauth2/provider/facebook.php create mode 100644 classes/oauth2/provider/facebook.php diff --git a/classes/kohana/oauth2/provider/facebook.php b/classes/kohana/oauth2/provider/facebook.php new file mode 100644 index 0000000..0569315 --- /dev/null +++ b/classes/kohana/oauth2/provider/facebook.php @@ -0,0 +1,18 @@ + Date: Tue, 14 Jun 2011 14:58:26 +0300 Subject: [PATCH 17/35] Fixing: Request::uri() is a function, closing

tag --- classes/controller/demo/oauth.php | 4 ++-- views/demo/oauth/index.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/controller/demo/oauth.php b/classes/controller/demo/oauth.php index bf147c1..5b377b3 100644 --- a/classes/controller/demo/oauth.php +++ b/classes/controller/demo/oauth.php @@ -67,7 +67,7 @@ public function demo_login() $this->session->delete($this->key('request')); // Restart the login process - $this->request->redirect($this->request->uri); + $this->request->redirect($this->request->uri()); } // Store the verifier in the token @@ -124,7 +124,7 @@ public function demo_logout() $this->request->redirect($this->request->uri(array('action' => FALSE, 'id' => FALSE))); } - $this->content = HTML::anchor("{$this->request->uri}?confirm=yes", "Logout of {$this->api}"); + $this->content = HTML::anchor("{$this->request->uri()}?confirm=yes", "Logout of {$this->api}"); } } // End Demo diff --git a/views/demo/oauth/index.php b/views/demo/oauth/index.php index b44fd4c..6617171 100644 --- a/views/demo/oauth/index.php +++ b/views/demo/oauth/index.php @@ -1,4 +1,4 @@ -

OAuth Demo

+

OAuth Demo

This demo makes use of the OAuth Module for Kohana. From fc6ceb65e53ae76dfce859995d555d4d5e565347 Mon Sep 17 00:00:00 2001 From: Rafael Bodill Date: Thu, 16 Jun 2011 00:59:51 +0300 Subject: [PATCH 18/35] Adding a Linkedin provider --- classes/kohana/oauth/provider/linkedin.php | 60 ++++++++++++++++++++++ classes/oauth/provider/linkedin.php | 3 ++ 2 files changed, 63 insertions(+) create mode 100644 classes/kohana/oauth/provider/linkedin.php create mode 100644 classes/oauth/provider/linkedin.php diff --git a/classes/kohana/oauth/provider/linkedin.php b/classes/kohana/oauth/provider/linkedin.php new file mode 100644 index 0000000..5360001 --- /dev/null +++ b/classes/kohana/oauth/provider/linkedin.php @@ -0,0 +1,60 @@ +. + * + * [!!] This class does not implement the Linkedin API. It is only an + * implementation of standard OAuth with Linkedin as the service provider. + * + * @package Kohana/OAuth + * @category Provider + * @author Kohana Team + * @copyright (c) 2010 Kohana Team + * @license http://kohanaframework.org/license + * @since 3.0.7 + */ +class Kohana_OAuth_Provider_Linkedin extends OAuth_Provider { + + /** + * @var string Provider name + */ + public $name = 'linkedin'; + + /** + * @var string Signature + */ + protected $signature = 'HMAC-SHA1'; + + /** + * Request token URL + * + * @return string + */ + public function url_request_token() + { + return 'https://api.linkedin.com/uas/oauth/requestToken'; + } + + /** + * Authorize URL + * + * @return string + */ + public function url_authorize() + { + return 'https://api.linkedin.com/uas/oauth/authorize'; + } + + /** + * Access token URL + * + * @return string + */ + public function url_access_token() + { + return 'https://api.linkedin.com/uas/oauth/accessToken'; + } + +} // End Kohana_OAuth_Provider_Linkedin diff --git a/classes/oauth/provider/linkedin.php b/classes/oauth/provider/linkedin.php new file mode 100644 index 0000000..9a764e8 --- /dev/null +++ b/classes/oauth/provider/linkedin.php @@ -0,0 +1,3 @@ + Date: Thu, 16 Jun 2011 13:34:56 +0300 Subject: [PATCH 19/35] Fixing typo --- classes/kohana/oauth/provider/linkedin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/kohana/oauth/provider/linkedin.php b/classes/kohana/oauth/provider/linkedin.php index 5360001..5ecd8d9 100644 --- a/classes/kohana/oauth/provider/linkedin.php +++ b/classes/kohana/oauth/provider/linkedin.php @@ -2,7 +2,7 @@ /** * OAuth Linkedin Provider * - * Documents for implementing Twitter OAuth can be found at + * Documents for implementing Linkedin OAuth can be found at * . * * [!!] This class does not implement the Linkedin API. It is only an From 4eb273443595657961fe959767bae2f64b1e6249 Mon Sep 17 00:00:00 2001 From: Dave Widmer Date: Thu, 14 Jul 2011 09:04:26 -0400 Subject: [PATCH 20/35] Adding Flickr as a Service Provider. --- classes/kohana/oauth/provider/flickr.php | 39 ++++++++++++++++++++++++ classes/oauth/provider/flickr.php | 3 ++ 2 files changed, 42 insertions(+) create mode 100644 classes/kohana/oauth/provider/flickr.php create mode 100644 classes/oauth/provider/flickr.php diff --git a/classes/kohana/oauth/provider/flickr.php b/classes/kohana/oauth/provider/flickr.php new file mode 100644 index 0000000..bbb2f4d --- /dev/null +++ b/classes/kohana/oauth/provider/flickr.php @@ -0,0 +1,39 @@ +. + * + * [!!] This class does not implement the Flickr API. It is only an + * implementation of standard OAuth with Flickr as the service provider. + * + * @package Kohana/OAuth + * @category Provider + * @author Kohana Team + * @copyright (c) 2011 Kohana Team + * @license http://kohanaframework.org/license + * @since 3.1.0 + */ +class Kohana_OAuth_Provider_Flickr extends OAuth_Provider { + + public $name = 'flickr'; + + protected $signature = 'HMAC-SHA1'; + + public function url_request_token() + { + return 'http://www.flickr.com/services/oauth/request_token'; + } + + public function url_authorize() + { + return 'http://www.flickr.com/services/oauth/authorize'; + } + + public function url_access_token() + { + return 'http://www.flickr.com/services/oauth/access_token'; + } + +} // End OAuth_Provider_Flickr diff --git a/classes/oauth/provider/flickr.php b/classes/oauth/provider/flickr.php new file mode 100644 index 0000000..b74cdcb --- /dev/null +++ b/classes/oauth/provider/flickr.php @@ -0,0 +1,3 @@ + Date: Fri, 22 Jul 2011 13:55:56 +0200 Subject: [PATCH 21/35] Add Tumblr to providers. --- classes/kohana/oauth/provider/tumblr.php | 39 ++++++++++++++++++++++++ classes/oauth/provider/tumblr.php | 3 ++ 2 files changed, 42 insertions(+) create mode 100644 classes/kohana/oauth/provider/tumblr.php create mode 100644 classes/oauth/provider/tumblr.php diff --git a/classes/kohana/oauth/provider/tumblr.php b/classes/kohana/oauth/provider/tumblr.php new file mode 100644 index 0000000..7b20a2d --- /dev/null +++ b/classes/kohana/oauth/provider/tumblr.php @@ -0,0 +1,39 @@ +. + * + * [!!] This class does not implement the Tumblr API. It is only an + * implementation of standard OAuth with Tumblr as the service provider. + * + * @package Kohana/OAuth + * @category Provider + * @author Kohana Team + * @copyright (c) 2011 Kohana Team + * @license http://kohanaframework.org/license + * @since 3.1.4 + */ +class Kohana_OAuth_Provider_Tumblr extends OAuth_Provider { + + public $name = 'tumblr'; + + protected $signature = 'HMAC-SHA1'; + + public function url_request_token() + { + return 'http://www.tumblr.com/oauth/request_token'; + } + + public function url_authorize() + { + return 'http://www.tumblr.com/oauth/authorize'; + } + + public function url_access_token() + { + return 'http://www.tumblr.com/oauth/access_token'; + } + +} // End Kohana_OAuth_Provider_Tumblr diff --git a/classes/oauth/provider/tumblr.php b/classes/oauth/provider/tumblr.php new file mode 100644 index 0000000..bdc2644 --- /dev/null +++ b/classes/oauth/provider/tumblr.php @@ -0,0 +1,3 @@ + Date: Tue, 2 Aug 2011 16:38:23 -0500 Subject: [PATCH 22/35] Added optional header realm="". See http://dev.kohanaframework.org/issues/4171. --- classes/kohana/oauth/consumer.php | 10 ++++++++++ classes/kohana/oauth/provider.php | 1 + classes/kohana/oauth/request.php | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/kohana/oauth/consumer.php b/classes/kohana/oauth/consumer.php index f8791da..11bf029 100644 --- a/classes/kohana/oauth/consumer.php +++ b/classes/kohana/oauth/consumer.php @@ -39,6 +39,11 @@ public static function factory(array $options = NULL) */ protected $callback; + /** + * @var string optional realm for the OAuth request + */ + protected $realm; + /** * Sets the consumer key and secret. * @@ -67,6 +72,11 @@ public function __construct(array $options = NULL) { $this->callback = $options['callback']; } + + if (isset($options['realm'])) + { + $this->realm = $options['realm']; + } } /** diff --git a/classes/kohana/oauth/provider.php b/classes/kohana/oauth/provider.php index d1ebbd1..b882989 100644 --- a/classes/kohana/oauth/provider.php +++ b/classes/kohana/oauth/provider.php @@ -126,6 +126,7 @@ public function request_token(OAuth_Consumer $consumer, array $params = NULL) { // Create a new GET request for a request token with the required parameters $request = OAuth_Request::factory('token', 'GET', $this->url_request_token(), array( + 'realm' => $consumer->realm, 'oauth_consumer_key' => $consumer->key, 'oauth_callback' => $consumer->callback, )); diff --git a/classes/kohana/oauth/request.php b/classes/kohana/oauth/request.php index d9c5edf..3732c0b 100644 --- a/classes/kohana/oauth/request.php +++ b/classes/kohana/oauth/request.php @@ -334,7 +334,7 @@ public function as_header() foreach ($this->params as $name => $value) { - if (strpos($name, 'oauth_') === 0) + if (strpos($name, 'oauth_') === 0 || ($name == "realm" && !empty($value))) { // OAuth Spec 5.4.1 // "Parameter names and values are encoded per Parameter Encoding [RFC 3986]." From 22d633b599eb29015d608d61fbea5f0ff2735768 Mon Sep 17 00:00:00 2001 From: Austin Bischoff Date: Wed, 3 Aug 2011 15:14:19 -0500 Subject: [PATCH 23/35] Added missing realm to Provider::access_token(). Changed to insert realm first and pulled it out of the loop to save work. --- classes/kohana/oauth/provider.php | 1 + classes/kohana/oauth/request.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/classes/kohana/oauth/provider.php b/classes/kohana/oauth/provider.php index b882989..692daef 100644 --- a/classes/kohana/oauth/provider.php +++ b/classes/kohana/oauth/provider.php @@ -189,6 +189,7 @@ public function access_token(OAuth_Consumer $consumer, OAuth_Token_Request $toke { // Create a new GET request for a request token with the required parameters $request = OAuth_Request::factory('access', 'GET', $this->url_access_token(), array( + 'realm' => $consumer->realm, 'oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->token, 'oauth_verifier' => $token->verifier, diff --git a/classes/kohana/oauth/request.php b/classes/kohana/oauth/request.php index 3732c0b..3a726cc 100644 --- a/classes/kohana/oauth/request.php +++ b/classes/kohana/oauth/request.php @@ -332,9 +332,17 @@ public function as_header() { $header = array(); + // Check for the existance of "realm" + if(array_key_exists('realm', $this->params) and ! empty($this->params['realm'])) + { + // OAuth Spec 5.4.1 + // "Parameter names and values are encoded per Parameter Encoding [RFC 3986]." + $header[] = OAuth::urlencode('realm').'="'.OAuth::urlencode($this->params['realm']).'"'; + } + foreach ($this->params as $name => $value) { - if (strpos($name, 'oauth_') === 0 || ($name == "realm" && !empty($value))) + if (strpos($name, 'oauth_') === 0) { // OAuth Spec 5.4.1 // "Parameter names and values are encoded per Parameter Encoding [RFC 3986]." From 0f145b0679f99ba58cd400d7f2cee420cba6359e Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Sun, 6 Nov 2011 08:02:05 -0600 Subject: [PATCH 24/35] Replaced Kohana::config() calls for 3.2 compatibility --- classes/controller/demo/oauth.php | 2 +- classes/controller/demo/oauth2.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/controller/demo/oauth.php b/classes/controller/demo/oauth.php index 5b377b3..e4eacbe 100644 --- a/classes/controller/demo/oauth.php +++ b/classes/controller/demo/oauth.php @@ -42,7 +42,7 @@ public function before() $this->provider = OAuth_Provider::factory($provider); // Load the consumer - $this->consumer = OAuth_Consumer::factory(Kohana::config("oauth.{$provider}")); + $this->consumer = OAuth_Consumer::factory(Kohana::$config->load("oauth.{$provider}")); if ($token = $this->session->get($this->key('access'))) { diff --git a/classes/controller/demo/oauth2.php b/classes/controller/demo/oauth2.php index 44fb261..cdcc961 100644 --- a/classes/controller/demo/oauth2.php +++ b/classes/controller/demo/oauth2.php @@ -42,7 +42,7 @@ public function before() $this->provider = OAuth2_Provider::factory($provider); // Load the client - $this->client = OAuth2_Client::factory(Kohana::config("oauth.{$provider}")); + $this->client = OAuth2_Client::factory(Kohana::$config->load("oauth.{$provider}")); if ($token = $this->session->get($this->key('access'))) { From 2feb3aec6f337a87f221b707637007024084b8f0 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Sun, 6 Nov 2011 08:25:47 -0600 Subject: [PATCH 25/35] Upgraded OAuth for Kohana 3.2 compatibility --- classes/controller/demo/oauth.php | 11 +++++++---- classes/controller/demo/oauth2.php | 13 ++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/classes/controller/demo/oauth.php b/classes/controller/demo/oauth.php index e4eacbe..93a68fd 100644 --- a/classes/controller/demo/oauth.php +++ b/classes/controller/demo/oauth.php @@ -41,8 +41,11 @@ public function before() // Load the provider $this->provider = OAuth_Provider::factory($provider); - // Load the consumer - $this->consumer = OAuth_Consumer::factory(Kohana::$config->load("oauth.{$provider}")); + // Load provider configuration + $config = Kohana::$config->load('oauth')->$provider; + + // Load the consumer for this provider + $this->consumer = OAuth_Consumer::factory($config); if ($token = $this->session->get($this->key('access'))) { @@ -83,13 +86,13 @@ public function demo_login() $this->session->delete($this->key('request')); // Refresh the page to prevent errors - $this->request->redirect($this->request->uri); + $this->request->redirect($this->request->uri()); } if ($this->token) { // Login succesful - $this->content = Kohana::debug('Access token granted:', $this->token); + $this->content = Debug::vars('Access token granted:', $this->token); } else { diff --git a/classes/controller/demo/oauth2.php b/classes/controller/demo/oauth2.php index cdcc961..62a42f0 100644 --- a/classes/controller/demo/oauth2.php +++ b/classes/controller/demo/oauth2.php @@ -41,8 +41,11 @@ public function before() // Load the provider $this->provider = OAuth2_Provider::factory($provider); - // Load the client - $this->client = OAuth2_Client::factory(Kohana::$config->load("oauth.{$provider}")); + // Load provider configuration + $config = Kohana::$config->load('oauth')->$provider; + + // Load the client for this provider + $this->client = OAuth2_Client::factory($config); if ($token = $this->session->get($this->key('access'))) { @@ -68,13 +71,13 @@ public function demo_login() $this->session->set($this->key('access'), $token); // Refresh the page to prevent errors - $this->request->redirect($this->request->uri); + $this->request->redirect($this->request->uri()); } if ($this->token) { // Login succesful - $this->content = Kohana::debug('Access token granted:', $this->token); + $this->content = Debug::vars('Access token granted:', $this->token); } else { @@ -103,7 +106,7 @@ public function demo_logout() $this->request->redirect($this->request->uri(array('action' => FALSE, 'id' => FALSE))); } - $this->content = HTML::anchor("{$this->request->uri}?confirm=yes", "Logout of {$this->api}"); + $this->content = HTML::anchor($this->request->uri().'?confirm=yes', "Logout of {$this->api}"); } } // End Demo From 966ae0b90308bc6c6fb833a9ff7b843971a8cd6e Mon Sep 17 00:00:00 2001 From: biakaveron Date: Sat, 30 Jul 2011 00:19:54 +0400 Subject: [PATCH 26/35] OAuth(2) Response can be in a JSON format. Signed-off-by: Woody Gilk --- classes/kohana/oauth/response.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/classes/kohana/oauth/response.php b/classes/kohana/oauth/response.php index 1fa1db7..80700e4 100644 --- a/classes/kohana/oauth/response.php +++ b/classes/kohana/oauth/response.php @@ -25,7 +25,16 @@ public function __construct($body = NULL) { if ($body) { - $this->params = OAuth::parse_params($body); + if ($params = json_decode($body, TRUE)) + { + // its a JSON string + $this->params = $params; + } + else + { + // parse as GET string + $this->params = OAuth::parse_params($body); + } } } @@ -48,4 +57,9 @@ public function param($name, $default = NULL) return Arr::get($this->params, $name, $default); } + public function params() + { + return $this->params; + } + } // End OAuth_Response From 7073ded95985110e86971b247224cb66ff39e28b Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Thu, 17 Nov 2011 15:43:34 -0600 Subject: [PATCH 27/35] Added OAuth2_Provider::__get(), same as OAuth_Provider::__get() --- classes/kohana/oauth2/provider.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/kohana/oauth2/provider.php b/classes/kohana/oauth2/provider.php index c1a50fb..6b8a2da 100644 --- a/classes/kohana/oauth2/provider.php +++ b/classes/kohana/oauth2/provider.php @@ -9,6 +9,20 @@ public static function factory($name, array $options = NULL) return new $class($options); } + /** + * Return the value of any protected class variable. + * + * // Get the provider signature + * $signature = $provider->signature; + * + * @param string variable name + * @return mixed + */ + public function __get($key) + { + return $this->$key; + } + abstract public function url_authorize(); abstract public function url_access_token(); From 0e9e162474cbe06835e95c510530bc3adb18d1e6 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Thu, 17 Nov 2011 15:44:15 -0600 Subject: [PATCH 28/35] Added OAuth2_Request_Resouce --- classes/kohana/oauth2/request/resource.php | 7 +++++++ classes/oauth2/request/resource.php | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 classes/kohana/oauth2/request/resource.php create mode 100644 classes/oauth2/request/resource.php diff --git a/classes/kohana/oauth2/request/resource.php b/classes/kohana/oauth2/request/resource.php new file mode 100644 index 0000000..4301aa9 --- /dev/null +++ b/classes/kohana/oauth2/request/resource.php @@ -0,0 +1,7 @@ + Date: Sun, 6 Jan 2013 23:58:30 +0400 Subject: [PATCH 29/35] renaming classes with v3.3 conventions --- classes/{controller/demo/oauth.php => Controller/Demo/Oauth.php} | 0 .../{controller/demo/oauth2.php => Controller/Demo/Oauth2.php} | 0 classes/{kohana/oauth.php => Kohana/Oauth.php} | 0 classes/{kohana/oauth/consumer.php => Kohana/Oauth/Consumer.php} | 0 .../{kohana/oauth/exception.php => Kohana/Oauth/Exception.php} | 0 classes/{kohana/oauth/provider.php => Kohana/Oauth/Provider.php} | 0 .../provider/flickr.php => Kohana/Oauth/Provider/Flickr.php} | 0 .../provider/google.php => Kohana/Oauth/Provider/Google.php} | 0 .../provider/linkedin.php => Kohana/Oauth/Provider/Linkedin.php} | 0 .../provider/tumblr.php => Kohana/Oauth/Provider/Tumblr.php} | 0 .../provider/twitter.php => Kohana/Oauth/Provider/Twitter.php} | 0 classes/{kohana/oauth/request.php => Kohana/Oauth/Request.php} | 0 .../oauth/request/access.php => Kohana/Oauth/Request/Access.php} | 0 .../request/authorize.php => Kohana/Oauth/Request/Authorize.php} | 0 .../credentials.php => Kohana/Oauth/Request/Credentials.php} | 0 .../request/resource.php => Kohana/Oauth/Request/Resource.php} | 0 .../oauth/request/token.php => Kohana/Oauth/Request/Token.php} | 0 classes/{kohana/oauth/response.php => Kohana/Oauth/Response.php} | 0 classes/{kohana/oauth/server.php => Kohana/Oauth/Server.php} | 0 .../{kohana/oauth/signature.php => Kohana/Oauth/Signature.php} | 0 .../hmac/sha1.php => Kohana/Oauth/Signature/HMAC/SHA1.php} | 0 .../plaintext.php => Kohana/Oauth/Signature/PLAINTEXT.php} | 0 classes/{kohana/oauth/token.php => Kohana/Oauth/Token.php} | 0 .../oauth/token/access.php => Kohana/Oauth/Token/Access.php} | 0 .../oauth/token/request.php => Kohana/Oauth/Token/Request.php} | 0 classes/{kohana/oauth2.php => Kohana/Oauth2.php} | 0 classes/{kohana/oauth2/client.php => Kohana/Oauth2/Client.php} | 0 .../{kohana/oauth2/provider.php => Kohana/Oauth2/Provider.php} | 0 .../provider/facebook.php => Kohana/Oauth2/Provider/Facebook.php} | 0 .../provider/github.php => Kohana/Oauth2/Provider/Github.php} | 0 classes/{kohana/oauth2/request.php => Kohana/Oauth2/Request.php} | 0 .../request/authorize.php => Kohana/Oauth2/Request/Authorize.php} | 0 .../credentials.php => Kohana/Oauth2/Request/Credentials.php} | 0 .../request/resource.php => Kohana/Oauth2/Request/Resource.php} | 0 .../oauth2/request/token.php => Kohana/Oauth2/Request/Token.php} | 0 classes/{kohana/oauth2/token.php => Kohana/Oauth2/Token.php} | 0 .../oauth2/token/access.php => Kohana/Oauth2/Token/Access.php} | 0 classes/{oauth.php => Oauth.php} | 0 classes/{oauth/consumer.php => Oauth/Consumer.php} | 0 classes/{oauth/provider.php => Oauth/Provider.php} | 0 classes/{oauth/provider/flickr.php => Oauth/Provider/Flickr.php} | 0 classes/{oauth/provider/google.php => Oauth/Provider/Google.php} | 0 .../{oauth/provider/linkedin.php => Oauth/Provider/Linkedin.php} | 0 classes/{oauth/provider/tumblr.php => Oauth/Provider/Tumblr.php} | 0 .../{oauth/provider/twitter.php => Oauth/Provider/Twitter.php} | 0 classes/{oauth/request.php => Oauth/Request.php} | 0 classes/{oauth/request/access.php => Oauth/Request/Access.php} | 0 .../{oauth/request/authorize.php => Oauth/Request/Authorize.php} | 0 .../request/credentials.php => Oauth/Request/Credentials.php} | 0 .../{oauth/request/resource.php => Oauth/Request/Resource.php} | 0 classes/{oauth/request/token.php => Oauth/Request/Token.php} | 0 classes/{oauth/response.php => Oauth/Response.php} | 0 classes/{oauth/signature.php => Oauth/Signature.php} | 0 .../signature/hmac/sha1.php => Oauth/Signature/HMAC/SHA1.php} | 0 .../signature/plaintext.php => Oauth/Signature/PLAINTEXT.php} | 0 classes/{oauth/token.php => Oauth/Token.php} | 0 classes/{oauth/token/access.php => Oauth/Token/Access.php} | 0 classes/{oauth/token/request.php => Oauth/Token/Request.php} | 0 classes/{oauth2.php => Oauth2.php} | 0 classes/{oauth2/client.php => Oauth2/Client.php} | 0 classes/{oauth2/provider.php => Oauth2/Provider.php} | 0 .../provider/facebook.php => Oauth2/Provider/Facebook.php} | 0 .../{oauth2/provider/github.php => Oauth2/Provider/Github.php} | 0 classes/{oauth2/request.php => Oauth2/Request.php} | 0 .../request/authorize.php => Oauth2/Request/Authorize.php} | 0 .../request/credentials.php => Oauth2/Request/Credentials.php} | 0 .../{oauth2/request/resource.php => Oauth2/Request/Resource.php} | 0 classes/{oauth2/request/token.php => Oauth2/Request/Token.php} | 0 classes/{oauth2/token.php => Oauth2/Token.php} | 0 classes/{oauth2/token/access.php => Oauth2/Token/Access.php} | 0 70 files changed, 0 insertions(+), 0 deletions(-) rename classes/{controller/demo/oauth.php => Controller/Demo/Oauth.php} (100%) rename classes/{controller/demo/oauth2.php => Controller/Demo/Oauth2.php} (100%) rename classes/{kohana/oauth.php => Kohana/Oauth.php} (100%) rename classes/{kohana/oauth/consumer.php => Kohana/Oauth/Consumer.php} (100%) rename classes/{kohana/oauth/exception.php => Kohana/Oauth/Exception.php} (100%) rename classes/{kohana/oauth/provider.php => Kohana/Oauth/Provider.php} (100%) rename classes/{kohana/oauth/provider/flickr.php => Kohana/Oauth/Provider/Flickr.php} (100%) rename classes/{kohana/oauth/provider/google.php => Kohana/Oauth/Provider/Google.php} (100%) rename classes/{kohana/oauth/provider/linkedin.php => Kohana/Oauth/Provider/Linkedin.php} (100%) rename classes/{kohana/oauth/provider/tumblr.php => Kohana/Oauth/Provider/Tumblr.php} (100%) rename classes/{kohana/oauth/provider/twitter.php => Kohana/Oauth/Provider/Twitter.php} (100%) rename classes/{kohana/oauth/request.php => Kohana/Oauth/Request.php} (100%) rename classes/{kohana/oauth/request/access.php => Kohana/Oauth/Request/Access.php} (100%) rename classes/{kohana/oauth/request/authorize.php => Kohana/Oauth/Request/Authorize.php} (100%) rename classes/{kohana/oauth/request/credentials.php => Kohana/Oauth/Request/Credentials.php} (100%) rename classes/{kohana/oauth/request/resource.php => Kohana/Oauth/Request/Resource.php} (100%) rename classes/{kohana/oauth/request/token.php => Kohana/Oauth/Request/Token.php} (100%) rename classes/{kohana/oauth/response.php => Kohana/Oauth/Response.php} (100%) rename classes/{kohana/oauth/server.php => Kohana/Oauth/Server.php} (100%) rename classes/{kohana/oauth/signature.php => Kohana/Oauth/Signature.php} (100%) rename classes/{kohana/oauth/signature/hmac/sha1.php => Kohana/Oauth/Signature/HMAC/SHA1.php} (100%) rename classes/{kohana/oauth/signature/plaintext.php => Kohana/Oauth/Signature/PLAINTEXT.php} (100%) rename classes/{kohana/oauth/token.php => Kohana/Oauth/Token.php} (100%) rename classes/{kohana/oauth/token/access.php => Kohana/Oauth/Token/Access.php} (100%) rename classes/{kohana/oauth/token/request.php => Kohana/Oauth/Token/Request.php} (100%) rename classes/{kohana/oauth2.php => Kohana/Oauth2.php} (100%) rename classes/{kohana/oauth2/client.php => Kohana/Oauth2/Client.php} (100%) rename classes/{kohana/oauth2/provider.php => Kohana/Oauth2/Provider.php} (100%) rename classes/{kohana/oauth2/provider/facebook.php => Kohana/Oauth2/Provider/Facebook.php} (100%) rename classes/{kohana/oauth2/provider/github.php => Kohana/Oauth2/Provider/Github.php} (100%) rename classes/{kohana/oauth2/request.php => Kohana/Oauth2/Request.php} (100%) rename classes/{kohana/oauth2/request/authorize.php => Kohana/Oauth2/Request/Authorize.php} (100%) rename classes/{kohana/oauth2/request/credentials.php => Kohana/Oauth2/Request/Credentials.php} (100%) rename classes/{kohana/oauth2/request/resource.php => Kohana/Oauth2/Request/Resource.php} (100%) rename classes/{kohana/oauth2/request/token.php => Kohana/Oauth2/Request/Token.php} (100%) rename classes/{kohana/oauth2/token.php => Kohana/Oauth2/Token.php} (100%) rename classes/{kohana/oauth2/token/access.php => Kohana/Oauth2/Token/Access.php} (100%) rename classes/{oauth.php => Oauth.php} (100%) rename classes/{oauth/consumer.php => Oauth/Consumer.php} (100%) rename classes/{oauth/provider.php => Oauth/Provider.php} (100%) rename classes/{oauth/provider/flickr.php => Oauth/Provider/Flickr.php} (100%) rename classes/{oauth/provider/google.php => Oauth/Provider/Google.php} (100%) rename classes/{oauth/provider/linkedin.php => Oauth/Provider/Linkedin.php} (100%) rename classes/{oauth/provider/tumblr.php => Oauth/Provider/Tumblr.php} (100%) rename classes/{oauth/provider/twitter.php => Oauth/Provider/Twitter.php} (100%) rename classes/{oauth/request.php => Oauth/Request.php} (100%) rename classes/{oauth/request/access.php => Oauth/Request/Access.php} (100%) rename classes/{oauth/request/authorize.php => Oauth/Request/Authorize.php} (100%) rename classes/{oauth/request/credentials.php => Oauth/Request/Credentials.php} (100%) rename classes/{oauth/request/resource.php => Oauth/Request/Resource.php} (100%) rename classes/{oauth/request/token.php => Oauth/Request/Token.php} (100%) rename classes/{oauth/response.php => Oauth/Response.php} (100%) rename classes/{oauth/signature.php => Oauth/Signature.php} (100%) rename classes/{oauth/signature/hmac/sha1.php => Oauth/Signature/HMAC/SHA1.php} (100%) rename classes/{oauth/signature/plaintext.php => Oauth/Signature/PLAINTEXT.php} (100%) rename classes/{oauth/token.php => Oauth/Token.php} (100%) rename classes/{oauth/token/access.php => Oauth/Token/Access.php} (100%) rename classes/{oauth/token/request.php => Oauth/Token/Request.php} (100%) rename classes/{oauth2.php => Oauth2.php} (100%) rename classes/{oauth2/client.php => Oauth2/Client.php} (100%) rename classes/{oauth2/provider.php => Oauth2/Provider.php} (100%) rename classes/{oauth2/provider/facebook.php => Oauth2/Provider/Facebook.php} (100%) rename classes/{oauth2/provider/github.php => Oauth2/Provider/Github.php} (100%) rename classes/{oauth2/request.php => Oauth2/Request.php} (100%) rename classes/{oauth2/request/authorize.php => Oauth2/Request/Authorize.php} (100%) rename classes/{oauth2/request/credentials.php => Oauth2/Request/Credentials.php} (100%) rename classes/{oauth2/request/resource.php => Oauth2/Request/Resource.php} (100%) rename classes/{oauth2/request/token.php => Oauth2/Request/Token.php} (100%) rename classes/{oauth2/token.php => Oauth2/Token.php} (100%) rename classes/{oauth2/token/access.php => Oauth2/Token/Access.php} (100%) diff --git a/classes/controller/demo/oauth.php b/classes/Controller/Demo/Oauth.php similarity index 100% rename from classes/controller/demo/oauth.php rename to classes/Controller/Demo/Oauth.php diff --git a/classes/controller/demo/oauth2.php b/classes/Controller/Demo/Oauth2.php similarity index 100% rename from classes/controller/demo/oauth2.php rename to classes/Controller/Demo/Oauth2.php diff --git a/classes/kohana/oauth.php b/classes/Kohana/Oauth.php similarity index 100% rename from classes/kohana/oauth.php rename to classes/Kohana/Oauth.php diff --git a/classes/kohana/oauth/consumer.php b/classes/Kohana/Oauth/Consumer.php similarity index 100% rename from classes/kohana/oauth/consumer.php rename to classes/Kohana/Oauth/Consumer.php diff --git a/classes/kohana/oauth/exception.php b/classes/Kohana/Oauth/Exception.php similarity index 100% rename from classes/kohana/oauth/exception.php rename to classes/Kohana/Oauth/Exception.php diff --git a/classes/kohana/oauth/provider.php b/classes/Kohana/Oauth/Provider.php similarity index 100% rename from classes/kohana/oauth/provider.php rename to classes/Kohana/Oauth/Provider.php diff --git a/classes/kohana/oauth/provider/flickr.php b/classes/Kohana/Oauth/Provider/Flickr.php similarity index 100% rename from classes/kohana/oauth/provider/flickr.php rename to classes/Kohana/Oauth/Provider/Flickr.php diff --git a/classes/kohana/oauth/provider/google.php b/classes/Kohana/Oauth/Provider/Google.php similarity index 100% rename from classes/kohana/oauth/provider/google.php rename to classes/Kohana/Oauth/Provider/Google.php diff --git a/classes/kohana/oauth/provider/linkedin.php b/classes/Kohana/Oauth/Provider/Linkedin.php similarity index 100% rename from classes/kohana/oauth/provider/linkedin.php rename to classes/Kohana/Oauth/Provider/Linkedin.php diff --git a/classes/kohana/oauth/provider/tumblr.php b/classes/Kohana/Oauth/Provider/Tumblr.php similarity index 100% rename from classes/kohana/oauth/provider/tumblr.php rename to classes/Kohana/Oauth/Provider/Tumblr.php diff --git a/classes/kohana/oauth/provider/twitter.php b/classes/Kohana/Oauth/Provider/Twitter.php similarity index 100% rename from classes/kohana/oauth/provider/twitter.php rename to classes/Kohana/Oauth/Provider/Twitter.php diff --git a/classes/kohana/oauth/request.php b/classes/Kohana/Oauth/Request.php similarity index 100% rename from classes/kohana/oauth/request.php rename to classes/Kohana/Oauth/Request.php diff --git a/classes/kohana/oauth/request/access.php b/classes/Kohana/Oauth/Request/Access.php similarity index 100% rename from classes/kohana/oauth/request/access.php rename to classes/Kohana/Oauth/Request/Access.php diff --git a/classes/kohana/oauth/request/authorize.php b/classes/Kohana/Oauth/Request/Authorize.php similarity index 100% rename from classes/kohana/oauth/request/authorize.php rename to classes/Kohana/Oauth/Request/Authorize.php diff --git a/classes/kohana/oauth/request/credentials.php b/classes/Kohana/Oauth/Request/Credentials.php similarity index 100% rename from classes/kohana/oauth/request/credentials.php rename to classes/Kohana/Oauth/Request/Credentials.php diff --git a/classes/kohana/oauth/request/resource.php b/classes/Kohana/Oauth/Request/Resource.php similarity index 100% rename from classes/kohana/oauth/request/resource.php rename to classes/Kohana/Oauth/Request/Resource.php diff --git a/classes/kohana/oauth/request/token.php b/classes/Kohana/Oauth/Request/Token.php similarity index 100% rename from classes/kohana/oauth/request/token.php rename to classes/Kohana/Oauth/Request/Token.php diff --git a/classes/kohana/oauth/response.php b/classes/Kohana/Oauth/Response.php similarity index 100% rename from classes/kohana/oauth/response.php rename to classes/Kohana/Oauth/Response.php diff --git a/classes/kohana/oauth/server.php b/classes/Kohana/Oauth/Server.php similarity index 100% rename from classes/kohana/oauth/server.php rename to classes/Kohana/Oauth/Server.php diff --git a/classes/kohana/oauth/signature.php b/classes/Kohana/Oauth/Signature.php similarity index 100% rename from classes/kohana/oauth/signature.php rename to classes/Kohana/Oauth/Signature.php diff --git a/classes/kohana/oauth/signature/hmac/sha1.php b/classes/Kohana/Oauth/Signature/HMAC/SHA1.php similarity index 100% rename from classes/kohana/oauth/signature/hmac/sha1.php rename to classes/Kohana/Oauth/Signature/HMAC/SHA1.php diff --git a/classes/kohana/oauth/signature/plaintext.php b/classes/Kohana/Oauth/Signature/PLAINTEXT.php similarity index 100% rename from classes/kohana/oauth/signature/plaintext.php rename to classes/Kohana/Oauth/Signature/PLAINTEXT.php diff --git a/classes/kohana/oauth/token.php b/classes/Kohana/Oauth/Token.php similarity index 100% rename from classes/kohana/oauth/token.php rename to classes/Kohana/Oauth/Token.php diff --git a/classes/kohana/oauth/token/access.php b/classes/Kohana/Oauth/Token/Access.php similarity index 100% rename from classes/kohana/oauth/token/access.php rename to classes/Kohana/Oauth/Token/Access.php diff --git a/classes/kohana/oauth/token/request.php b/classes/Kohana/Oauth/Token/Request.php similarity index 100% rename from classes/kohana/oauth/token/request.php rename to classes/Kohana/Oauth/Token/Request.php diff --git a/classes/kohana/oauth2.php b/classes/Kohana/Oauth2.php similarity index 100% rename from classes/kohana/oauth2.php rename to classes/Kohana/Oauth2.php diff --git a/classes/kohana/oauth2/client.php b/classes/Kohana/Oauth2/Client.php similarity index 100% rename from classes/kohana/oauth2/client.php rename to classes/Kohana/Oauth2/Client.php diff --git a/classes/kohana/oauth2/provider.php b/classes/Kohana/Oauth2/Provider.php similarity index 100% rename from classes/kohana/oauth2/provider.php rename to classes/Kohana/Oauth2/Provider.php diff --git a/classes/kohana/oauth2/provider/facebook.php b/classes/Kohana/Oauth2/Provider/Facebook.php similarity index 100% rename from classes/kohana/oauth2/provider/facebook.php rename to classes/Kohana/Oauth2/Provider/Facebook.php diff --git a/classes/kohana/oauth2/provider/github.php b/classes/Kohana/Oauth2/Provider/Github.php similarity index 100% rename from classes/kohana/oauth2/provider/github.php rename to classes/Kohana/Oauth2/Provider/Github.php diff --git a/classes/kohana/oauth2/request.php b/classes/Kohana/Oauth2/Request.php similarity index 100% rename from classes/kohana/oauth2/request.php rename to classes/Kohana/Oauth2/Request.php diff --git a/classes/kohana/oauth2/request/authorize.php b/classes/Kohana/Oauth2/Request/Authorize.php similarity index 100% rename from classes/kohana/oauth2/request/authorize.php rename to classes/Kohana/Oauth2/Request/Authorize.php diff --git a/classes/kohana/oauth2/request/credentials.php b/classes/Kohana/Oauth2/Request/Credentials.php similarity index 100% rename from classes/kohana/oauth2/request/credentials.php rename to classes/Kohana/Oauth2/Request/Credentials.php diff --git a/classes/kohana/oauth2/request/resource.php b/classes/Kohana/Oauth2/Request/Resource.php similarity index 100% rename from classes/kohana/oauth2/request/resource.php rename to classes/Kohana/Oauth2/Request/Resource.php diff --git a/classes/kohana/oauth2/request/token.php b/classes/Kohana/Oauth2/Request/Token.php similarity index 100% rename from classes/kohana/oauth2/request/token.php rename to classes/Kohana/Oauth2/Request/Token.php diff --git a/classes/kohana/oauth2/token.php b/classes/Kohana/Oauth2/Token.php similarity index 100% rename from classes/kohana/oauth2/token.php rename to classes/Kohana/Oauth2/Token.php diff --git a/classes/kohana/oauth2/token/access.php b/classes/Kohana/Oauth2/Token/Access.php similarity index 100% rename from classes/kohana/oauth2/token/access.php rename to classes/Kohana/Oauth2/Token/Access.php diff --git a/classes/oauth.php b/classes/Oauth.php similarity index 100% rename from classes/oauth.php rename to classes/Oauth.php diff --git a/classes/oauth/consumer.php b/classes/Oauth/Consumer.php similarity index 100% rename from classes/oauth/consumer.php rename to classes/Oauth/Consumer.php diff --git a/classes/oauth/provider.php b/classes/Oauth/Provider.php similarity index 100% rename from classes/oauth/provider.php rename to classes/Oauth/Provider.php diff --git a/classes/oauth/provider/flickr.php b/classes/Oauth/Provider/Flickr.php similarity index 100% rename from classes/oauth/provider/flickr.php rename to classes/Oauth/Provider/Flickr.php diff --git a/classes/oauth/provider/google.php b/classes/Oauth/Provider/Google.php similarity index 100% rename from classes/oauth/provider/google.php rename to classes/Oauth/Provider/Google.php diff --git a/classes/oauth/provider/linkedin.php b/classes/Oauth/Provider/Linkedin.php similarity index 100% rename from classes/oauth/provider/linkedin.php rename to classes/Oauth/Provider/Linkedin.php diff --git a/classes/oauth/provider/tumblr.php b/classes/Oauth/Provider/Tumblr.php similarity index 100% rename from classes/oauth/provider/tumblr.php rename to classes/Oauth/Provider/Tumblr.php diff --git a/classes/oauth/provider/twitter.php b/classes/Oauth/Provider/Twitter.php similarity index 100% rename from classes/oauth/provider/twitter.php rename to classes/Oauth/Provider/Twitter.php diff --git a/classes/oauth/request.php b/classes/Oauth/Request.php similarity index 100% rename from classes/oauth/request.php rename to classes/Oauth/Request.php diff --git a/classes/oauth/request/access.php b/classes/Oauth/Request/Access.php similarity index 100% rename from classes/oauth/request/access.php rename to classes/Oauth/Request/Access.php diff --git a/classes/oauth/request/authorize.php b/classes/Oauth/Request/Authorize.php similarity index 100% rename from classes/oauth/request/authorize.php rename to classes/Oauth/Request/Authorize.php diff --git a/classes/oauth/request/credentials.php b/classes/Oauth/Request/Credentials.php similarity index 100% rename from classes/oauth/request/credentials.php rename to classes/Oauth/Request/Credentials.php diff --git a/classes/oauth/request/resource.php b/classes/Oauth/Request/Resource.php similarity index 100% rename from classes/oauth/request/resource.php rename to classes/Oauth/Request/Resource.php diff --git a/classes/oauth/request/token.php b/classes/Oauth/Request/Token.php similarity index 100% rename from classes/oauth/request/token.php rename to classes/Oauth/Request/Token.php diff --git a/classes/oauth/response.php b/classes/Oauth/Response.php similarity index 100% rename from classes/oauth/response.php rename to classes/Oauth/Response.php diff --git a/classes/oauth/signature.php b/classes/Oauth/Signature.php similarity index 100% rename from classes/oauth/signature.php rename to classes/Oauth/Signature.php diff --git a/classes/oauth/signature/hmac/sha1.php b/classes/Oauth/Signature/HMAC/SHA1.php similarity index 100% rename from classes/oauth/signature/hmac/sha1.php rename to classes/Oauth/Signature/HMAC/SHA1.php diff --git a/classes/oauth/signature/plaintext.php b/classes/Oauth/Signature/PLAINTEXT.php similarity index 100% rename from classes/oauth/signature/plaintext.php rename to classes/Oauth/Signature/PLAINTEXT.php diff --git a/classes/oauth/token.php b/classes/Oauth/Token.php similarity index 100% rename from classes/oauth/token.php rename to classes/Oauth/Token.php diff --git a/classes/oauth/token/access.php b/classes/Oauth/Token/Access.php similarity index 100% rename from classes/oauth/token/access.php rename to classes/Oauth/Token/Access.php diff --git a/classes/oauth/token/request.php b/classes/Oauth/Token/Request.php similarity index 100% rename from classes/oauth/token/request.php rename to classes/Oauth/Token/Request.php diff --git a/classes/oauth2.php b/classes/Oauth2.php similarity index 100% rename from classes/oauth2.php rename to classes/Oauth2.php diff --git a/classes/oauth2/client.php b/classes/Oauth2/Client.php similarity index 100% rename from classes/oauth2/client.php rename to classes/Oauth2/Client.php diff --git a/classes/oauth2/provider.php b/classes/Oauth2/Provider.php similarity index 100% rename from classes/oauth2/provider.php rename to classes/Oauth2/Provider.php diff --git a/classes/oauth2/provider/facebook.php b/classes/Oauth2/Provider/Facebook.php similarity index 100% rename from classes/oauth2/provider/facebook.php rename to classes/Oauth2/Provider/Facebook.php diff --git a/classes/oauth2/provider/github.php b/classes/Oauth2/Provider/Github.php similarity index 100% rename from classes/oauth2/provider/github.php rename to classes/Oauth2/Provider/Github.php diff --git a/classes/oauth2/request.php b/classes/Oauth2/Request.php similarity index 100% rename from classes/oauth2/request.php rename to classes/Oauth2/Request.php diff --git a/classes/oauth2/request/authorize.php b/classes/Oauth2/Request/Authorize.php similarity index 100% rename from classes/oauth2/request/authorize.php rename to classes/Oauth2/Request/Authorize.php diff --git a/classes/oauth2/request/credentials.php b/classes/Oauth2/Request/Credentials.php similarity index 100% rename from classes/oauth2/request/credentials.php rename to classes/Oauth2/Request/Credentials.php diff --git a/classes/oauth2/request/resource.php b/classes/Oauth2/Request/Resource.php similarity index 100% rename from classes/oauth2/request/resource.php rename to classes/Oauth2/Request/Resource.php diff --git a/classes/oauth2/request/token.php b/classes/Oauth2/Request/Token.php similarity index 100% rename from classes/oauth2/request/token.php rename to classes/Oauth2/Request/Token.php diff --git a/classes/oauth2/token.php b/classes/Oauth2/Token.php similarity index 100% rename from classes/oauth2/token.php rename to classes/Oauth2/Token.php diff --git a/classes/oauth2/token/access.php b/classes/Oauth2/Token/Access.php similarity index 100% rename from classes/oauth2/token/access.php rename to classes/Oauth2/Token/Access.php From 6818ab103a680665c21679e7f4a13b306d92e268 Mon Sep 17 00:00:00 2001 From: biakaveron Date: Mon, 7 Jan 2013 00:02:13 +0400 Subject: [PATCH 30/35] Add vk (vkontakte) to providers --- classes/Kohana/Oauth2/Provider/Vk.php | 18 ++++++++++++++++++ classes/Oauth2/Provider/Vk.php | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 classes/Kohana/Oauth2/Provider/Vk.php create mode 100644 classes/Oauth2/Provider/Vk.php diff --git a/classes/Kohana/Oauth2/Provider/Vk.php b/classes/Kohana/Oauth2/Provider/Vk.php new file mode 100644 index 0000000..87a30b7 --- /dev/null +++ b/classes/Kohana/Oauth2/Provider/Vk.php @@ -0,0 +1,18 @@ + Date: Mon, 7 Jan 2013 00:02:55 +0400 Subject: [PATCH 31/35] Add Google OAuth2 to providers --- classes/Kohana/Oauth2/Provider/Google.php | 17 +++++++++++++++++ classes/Oauth2/Provider/Google.php | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 classes/Kohana/Oauth2/Provider/Google.php create mode 100644 classes/Oauth2/Provider/Google.php diff --git a/classes/Kohana/Oauth2/Provider/Google.php b/classes/Kohana/Oauth2/Provider/Google.php new file mode 100644 index 0000000..f7fdd37 --- /dev/null +++ b/classes/Kohana/Oauth2/Provider/Google.php @@ -0,0 +1,17 @@ + Date: Mon, 7 Jan 2013 00:03:24 +0400 Subject: [PATCH 32/35] Add Yandex (ya.ru) to providers --- classes/Kohana/Oauth2/Provider/Yandex.php | 17 +++++++++++++++++ classes/Oauth2/Provider/Yandex.php | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 classes/Kohana/Oauth2/Provider/Yandex.php create mode 100644 classes/Oauth2/Provider/Yandex.php diff --git a/classes/Kohana/Oauth2/Provider/Yandex.php b/classes/Kohana/Oauth2/Provider/Yandex.php new file mode 100644 index 0000000..38b0bb1 --- /dev/null +++ b/classes/Kohana/Oauth2/Provider/Yandex.php @@ -0,0 +1,17 @@ + Date: Tue, 8 Jan 2013 03:23:35 +0400 Subject: [PATCH 33/35] =?UTF-8?q?=D0=98=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B4=20ko3.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Kohana/Oauth/Provider.php | 4 +++- classes/Kohana/Oauth/Request.php | 2 +- classes/Kohana/Oauth/Request/Authorize.php | 2 +- classes/Kohana/Oauth/Signature.php | 2 +- classes/Kohana/Oauth/Token.php | 8 ++++++-- classes/Kohana/Oauth2/Provider.php | 9 +++++---- classes/Kohana/Oauth2/Provider/Vk.php | 18 ------------------ classes/Kohana/Oauth2/Request.php | 2 +- classes/Kohana/Oauth2/Request/Authorize.php | 2 +- classes/Kohana/Oauth2/Token.php | 2 +- 10 files changed, 20 insertions(+), 31 deletions(-) delete mode 100644 classes/Kohana/Oauth2/Provider/Vk.php diff --git a/classes/Kohana/Oauth/Provider.php b/classes/Kohana/Oauth/Provider.php index 692daef..e21455b 100644 --- a/classes/Kohana/Oauth/Provider.php +++ b/classes/Kohana/Oauth/Provider.php @@ -11,6 +11,8 @@ */ abstract class Kohana_OAuth_Provider { + protected $signature = 'PLAINTEXT'; + /** * Create a new provider. * @@ -23,7 +25,7 @@ abstract class Kohana_OAuth_Provider { */ public static function factory($name, array $options = NULL) { - $class = 'OAuth_Provider_'.$name; + $class = 'OAuth_Provider_'.UTF8::ucfirst($name); return new $class($options); } diff --git a/classes/Kohana/Oauth/Request.php b/classes/Kohana/Oauth/Request.php index 3a726cc..ef3f528 100644 --- a/classes/Kohana/Oauth/Request.php +++ b/classes/Kohana/Oauth/Request.php @@ -24,7 +24,7 @@ class Kohana_OAuth_Request { */ public static function factory($type, $method, $url = NULL, array $params = NULL) { - $class = 'OAuth_Request_'.$type; + $class = 'OAuth_Request_'.UTF8::ucfirst($type); return new $class($method, $url, $params); } diff --git a/classes/Kohana/Oauth/Request/Authorize.php b/classes/Kohana/Oauth/Request/Authorize.php index 2ce9037..a90b8d4 100644 --- a/classes/Kohana/Oauth/Request/Authorize.php +++ b/classes/Kohana/Oauth/Request/Authorize.php @@ -20,7 +20,7 @@ class Kohana_OAuth_Request_Authorize extends OAuth_Request { public function execute(array $options = NULL) { - return Request::current()->redirect($this->as_url()); + HTTP::redirect($this->as_url()); } } // End OAuth_Request_Authorize diff --git a/classes/Kohana/Oauth/Signature.php b/classes/Kohana/Oauth/Signature.php index 52cf171..482127a 100644 --- a/classes/Kohana/Oauth/Signature.php +++ b/classes/Kohana/Oauth/Signature.php @@ -23,7 +23,7 @@ abstract class Kohana_OAuth_Signature { public static function factory($name, array $options = NULL) { // Create the class name as a base of this class - $class = 'OAuth_Signature_'.str_replace('-', '_', $name); + $class = 'OAuth_Signature_'.UTF8::ucfirst(str_replace('-', '_', $name)); return new $class($options); } diff --git a/classes/Kohana/Oauth/Token.php b/classes/Kohana/Oauth/Token.php index fadf830..268059c 100644 --- a/classes/Kohana/Oauth/Token.php +++ b/classes/Kohana/Oauth/Token.php @@ -22,7 +22,7 @@ abstract class Kohana_OAuth_Token { */ public static function factory($name, array $options = NULL) { - $class = 'OAuth_Token_'.$name; + $class = 'OAuth_Token_'.UTF8::ucfirst($name); return new $class($options); } @@ -44,6 +44,8 @@ public static function factory($name, array $options = NULL) 'token', ); + protected $data = array(); + /** * Sets the token and secret values. * @@ -62,6 +64,8 @@ public function __construct(array $options = NULL) $this->$key = $options[$key]; } + + $this->data = $options; } /** @@ -75,7 +79,7 @@ public function __construct(array $options = NULL) */ public function __get($key) { - return $this->$key; + return isset($this->$key) ? $this->$key : $this->data[$key]; } /** diff --git a/classes/Kohana/Oauth2/Provider.php b/classes/Kohana/Oauth2/Provider.php index 6b8a2da..a3aa29c 100644 --- a/classes/Kohana/Oauth2/Provider.php +++ b/classes/Kohana/Oauth2/Provider.php @@ -4,7 +4,7 @@ abstract class Kohana_OAuth2_Provider { public static function factory($name, array $options = NULL) { - $class = 'OAuth2_Provider_'.$name; + $class = 'OAuth2_Provider_'.UTF8::ucfirst($name); return new $class($options); } @@ -75,9 +75,10 @@ public function access_token(OAuth2_Client $client, $code, array $params = NULL) $response = $request->execute(); - return OAuth2_Token::factory('access', array( - 'token' => $response->param('access_token') - )); + $params = $response->params(); + $params['token'] = $response->param('access_token'); + + return OAuth2_Token::factory('access', $params); } } diff --git a/classes/Kohana/Oauth2/Provider/Vk.php b/classes/Kohana/Oauth2/Provider/Vk.php deleted file mode 100644 index 87a30b7..0000000 --- a/classes/Kohana/Oauth2/Provider/Vk.php +++ /dev/null @@ -1,18 +0,0 @@ -redirect($this->as_url()); + HTTP::redirect($this->as_url()); } } diff --git a/classes/Kohana/Oauth2/Token.php b/classes/Kohana/Oauth2/Token.php index fc640f8..5bec13d 100644 --- a/classes/Kohana/Oauth2/Token.php +++ b/classes/Kohana/Oauth2/Token.php @@ -13,7 +13,7 @@ abstract class Kohana_OAuth2_Token extends OAuth_Token { */ public static function factory($name, array $options = NULL) { - $class = 'OAuth2_Token_'.$name; + $class = 'OAuth2_Token_'.UTF8::ucfirst($name); return new $class($options); } From f86d54a00cdb068401fc9c2a4eb9f108cda644e6 Mon Sep 17 00:00:00 2001 From: aktuba Date: Tue, 8 Jan 2013 03:26:23 +0400 Subject: [PATCH 34/35] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=92=D0=9A?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Kohana/Oauth2/Provider/Vkontakte.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 classes/Kohana/Oauth2/Provider/Vkontakte.php diff --git a/classes/Kohana/Oauth2/Provider/Vkontakte.php b/classes/Kohana/Oauth2/Provider/Vkontakte.php new file mode 100644 index 0000000..87a30b7 --- /dev/null +++ b/classes/Kohana/Oauth2/Provider/Vkontakte.php @@ -0,0 +1,18 @@ + Date: Tue, 8 Jan 2013 04:47:39 +0400 Subject: [PATCH 35/35] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Kohana/Oauth2/Provider/Odnoklassniki.php | 18 ++++++++++++++++++ classes/Kohana/Oauth2/Provider/Vkontakte.php | 4 ++-- classes/Oauth2/Provider/Odnoklassniki.php | 3 +++ .../Oauth2/Provider/{Vk.php => Vkontakte.php} | 0 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 classes/Kohana/Oauth2/Provider/Odnoklassniki.php create mode 100644 classes/Oauth2/Provider/Odnoklassniki.php rename classes/Oauth2/Provider/{Vk.php => Vkontakte.php} (100%) diff --git a/classes/Kohana/Oauth2/Provider/Odnoklassniki.php b/classes/Kohana/Oauth2/Provider/Odnoklassniki.php new file mode 100644 index 0000000..5ea7748 --- /dev/null +++ b/classes/Kohana/Oauth2/Provider/Odnoklassniki.php @@ -0,0 +1,18 @@ +