diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a8d546..fe1ab8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,65 @@ +# v2.0.0 +## 07/14/2016 + +1. [](#improved) + * Optimized nonce creation + * Point account path to core's account stream [#85](https://github.com/getgrav/grav-plugin-login/issues/85) + +# v2.0.0-rc.2 +## 06/21/2016 + +1. [](#new) + * Add an option to login protect a login-protected page media accessed through the page route [#45](https://github.com/getgrav/grav-plugin-login/issues/45) +1. [](#improved) + * Fixed some language keys +1. [](#bugfix) + * Correctly show an error message when the reset password form does not provide the correct nonce + +# v2.0.0-rc.1 +## 06/01/2016 + +1. [](#improved) + * French updated +1. [](#bugfix) + * Enable twig processing in a page #75 + * Deny access to registration when user registration is disabled #72 + +# v2.0.0-beta.3 +## 05/23/2016 + +1. [](#improved) + * Added a redirect after activation + * Changed hardcoded redirect routes to config-based +1. [](#bugfix) + * Fix a redirect issue #74 + * Don't error if missing a HTTP_USER_AGENT browser string + +# v2.0.0-beta.2 +## 05/03/2016 + +1. [](#improved) + * Improved the login form page once logged in + * Translate welcome and logout strings +1. [](#bugfix) + * Fixed logging out on the homepage + * Fixed an issue in processing user registration + +# v2.0.0-beta.1 +## 04/20/2016 + +1. [](#new) + * Introduce a more flexible Login plugin architecture, which allows separate authentication plugins to hook into the Login events. Separated OAuth to its own plugin. + * OAuth has been separated to its own plugin, needs to be installed separately and configured. The users account filename format has changed too, to fix an issue that involved people with the same name on a service. + * The `redirect` option has been changed to `redirect_after_login`. Make sure you update your configuration file. +1. [](#improved) + * Add a proper 'Access levels' config section for Login. + * Various underlying improvements + * Updated french, added german +1. [](#bugfix) + * Make username field autofocus + * Add validation to the password reset form + * Fixed an issue that allowed a user logged in, without access to the actual permissions set to view a page, to see its content, and the login form again even if already logged in. + # v1.3.1 ## 02/05/2016 @@ -9,7 +71,7 @@ * Add the correct message type when raising a form processing error 1. [](#bugfix) * Show the correct error message when the user is not authorized to view a page - * Fix showing the OAuth links in the login form + * Fix showing the OAuth links in the login form # v1.3.0 ## 01/06/2016 @@ -60,7 +122,132 @@ * Check page exists so as not to fail hard * Fix for static Inflector references #17 - + +# v1.0.1 +## 11/23/2015 + +1. [](#improved) + * Hardening cookies with user-agent and system cache key instead of deprecated system hash + * Set a custom route for login only if it's not an admin path + +# v1.0.0 +## 11/21/2015 + +1. [](#new) + * Added OAuth login support for _Facebook_, _Google_, _GitHub_ and _Twitter_ + * Added **Nonce** form security support + * Added option to "redirect after login" + * Added "remember me" functionality + * Added Hungarian translation +2. [](#improved) + * Added blueprints for Grav Admin plugin (multi-language support!) + +# v0.3.3 +## 09/11/2015 + +1. [](#improved) + * Changed authorise to authorize +1. [](#bugfix) + * Fix denied string + +# v0.3.2 +## 09/01/2015 + +1. [](#improved) + * Broke out login form into its own partial + +# v0.3.1 +## 08/31/2015 + +1. [](#improved) + * Added username field autofocus + +# v0.3.0 +## 08/24/2015 + +1. [](#new) + * Added simple CSS styling + * Added simple login status with logout +1. [](#improved) + * Improved README documentation + * More strings translated + * Updated blueprints + +# v0.2.0 +## 08/11/2015 + +1. [](#improved) + * Disable `enable` in admin + +# v0.1.0 +## 08/04/2015 + +1. [](#new) + * ChangeLog started... + +# v1.3.1 +## 02/05/2016 + +1. [](#new) + * Add translations for Username and Password (placeholders are not translated) +1. [](#improved) + * Improve registration, forgot, reset and login forms accessibility by setting the id attribute + * Improved french translation + * Add the correct message type when raising a form processing error +1. [](#bugfix) + * Show the correct error message when the user is not authorized to view a page + * Fix showing the OAuth links in the login form + +# v1.3.0 +## 01/06/2016 + +1. [](#new) + * Added a new CLI command to change a user's password + * Added a new CLI command to edit the user state +1. [](#improved) + * Improved french translation + +# v1.2.1 +## 12/18/2015 + +1. [](#new) + * Croatian translation +1. [](#improved) + * Use type `email` in registration form + * Drop manual validation in registration + +# v1.2.0 +## 12/11/2015 + +1. [](#new) + * Added account activation email upon registration + * Added forgot password functionality + * Support ACL from parent page + * Allow login immediately after account activation +1. [](#improved) + * Handle admin login page if available + * Example registration form now provided by plugin + * Better error handling of registration + * Tab-based plugin configuration + * Updated translations +1. [](#bugfix) + * Prevent failing when no default values are set + +# v1.1.0 +## 12/01/2015 + +1. [](#new) + * Support new **User Registration** +1. [](#improved) + * Use new security salt for newer and fallback otherwise + * Composer update of libraries + * Check for session existence else throw a runtime error +1. [](#bugfix) + * Fix remember-me functionality + * Check page exists so as not to fail hard + * Fix for static Inflector references #17 + + # v1.0.1 ## 11/23/2015 diff --git a/LICENSE b/LICENSE index 0e788c6..4bb7092 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Grav +Copyright (c) 2016 Grav Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fec5656..a3c7ed3 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,15 @@ These are available via GPM, and because the plugin has dependencies you just ne $ bin/gpm install login ``` +# Changes in version 2.0 (STILL TO BE RELEASED) + +The Login Plugin 2.0 has the following changes compared to 1.0: + +- OAuth has been separated to its own plugin, needs to be installed separately and configured. The users account filename format has changed too, to fix an issue that involved people with the same name on a service. +- The `redirect` option has been changed to `redirect_after_login`. +- The Remember Me session minimum length is now 1 week. +- Removed the option to login from oauth without creating the corresponding user file under `user/accounts/`. + # Creating Users You can either use the built-in CLI capabilities, or you create a user manually by creating a new YAML file in your `user/acounts` folder. @@ -332,60 +341,6 @@ You can set the "Redirect after registration" option in the Login plugin, or as ``` -# OAuth - -You can add OAuth providers to the login plugin as another method to have users on your site. To enable OAuth change `oauth.enabled` to `true` in `login.yaml`. By default OAuth allows users to login though they do not create an account file for the user. If you want an account file created (ex: for tracking purposes) change `oauth.user.autocreate` to `true` in `login.yaml`. ->Note: OAuth has not been tested with Grav's multilang feature! Due to this, certain OAuth providers may not function properly on multilang sites - ->IMPORTANT: `localhost` may NOT be used for callback and allowed URLs when creating OAuth provider applications due to certificate verification issues. Some services allow other URLs and it may be possible to add custom domains pointing to 127.0.0.1 in your hosts file and point applications there. - -## Facebook - -Visit https://developers.facebook.com/quickstarts/?platform=web and create an app name then click **Create New Facebook App ID.** - -Choose a category most similar to your business then click **Create App ID.** - -Scroll down on the next screen to the section titled **Tell us about your website.** Input a URL for the site (no need to include the protocol). Click **Next** - -Click **Skip Quick Start** Copy the **App ID** and **App Secret** into `login.yaml` - -On the left hand side click **Settings** -In the **Basic** tab add your domain into the **App Domains** section as well as enter a contact email (required for facebook developer program). In the **Advanced** tab scroll down to the **Client OAuth Settings** Make sure that **Client OAuth Login** is enabled as well as **Web OAuth Login** is enabled. In the **Valid OAuth redirect URIs** section add the routes of all pages that are protected by login. This includes the domains. EX: `http://getgrav.org/`, `http://getgrav.org/login`, `http://getgrav.org/en/login`, and `http://getgrav.org/protected/page/route` - - -## Github - -Visit Github's [Developer Applications Console](https://github.com/settings/developers) and press button **Register new application** (login if necesarry). ![](assets/github/github.png) - -Fill out the name and the URL (can be anything) and fill in the **callback**, which must be equal to where your grav site is located, generally just the host, i.e. `http://getgrav.org`. ![](assets/github/github_2.png) - -Copy **Client ID** and **client secret** into login.yaml under Github. ![](assets/github/github_3.png)Be sure to change `Github.enabled` to `true` - -## Google - -Visit the [Google Developers Console](https://console.developers.google.com) (sign in with a google account, preferably your businesses gmail). - -Select **Create Project** and give the project a name (can be anything). Click **Create**. ![](assets/google/google.png) - -When it's finished creating in the left hand menu choose **Credentials** under **APIs & Auth** (you may need to click **APIs & Auth** in order to display **Credntials**). ![](assets/google/google_3.png) - -Under **Add credentials** (center of screen) select **OAuth 2.0 client ID**.![](assets/google/google_4.png) - -Then select **Configure consent screen** in the top right corner. ![](assets/google/google_5.png) - -The only requirement is **Product name** which should be the name of your website/business (not a url). You may fill in the other options as you want on the consent screen. (The consent screen can also be changed later). ![](assets/google/google_6.png) - -Then once you save the consent screen select **Web application** from the radio buttons and fill in the fields. **Name** being name of product/business. **Authorized Javascript origins** is the root domain name of the login page (no routes or wildcards) such as `http://getgrav.org`. - -If needed, enter multiple sub domains, creating an entry for each. **Authorized redirect URIs** include the **same** Authorized Javascript origins used along with the **route** to the login page such as `http://getgrav.org/login`. Click **create**. - -![](assets/google/google_7.png) - -Copy **Client ID** and **client secret** into login.yaml under Google. ![](assets/google/google_8.png)Be sure to change `Google.enabled` to `true` - -## Twitter - -Login if necessary. Create a [new Twitter App](https://apps.twitter.com/app/new) , fill out name, application website, choose "Browser" as application type, choose the callback URL like above, default access type can be set to read-only, click on "Register application" and then you should be directed to your new application with the Client ID and secret ready to be copied and pasted into the YAML file. # Known issues diff --git a/assets/github/github.png b/assets/github/github.png deleted file mode 100644 index a8595d8..0000000 Binary files a/assets/github/github.png and /dev/null differ diff --git a/assets/github/github_2.png b/assets/github/github_2.png deleted file mode 100644 index ff84e98..0000000 Binary files a/assets/github/github_2.png and /dev/null differ diff --git a/assets/github/github_3.png b/assets/github/github_3.png deleted file mode 100644 index ee9fd76..0000000 Binary files a/assets/github/github_3.png and /dev/null differ diff --git a/assets/google/google.png b/assets/google/google.png deleted file mode 100644 index 189c490..0000000 Binary files a/assets/google/google.png and /dev/null differ diff --git a/assets/google/google_2.png b/assets/google/google_2.png deleted file mode 100644 index 0d2b116..0000000 Binary files a/assets/google/google_2.png and /dev/null differ diff --git a/assets/google/google_3.png b/assets/google/google_3.png deleted file mode 100644 index 822ffab..0000000 Binary files a/assets/google/google_3.png and /dev/null differ diff --git a/assets/google/google_4.png b/assets/google/google_4.png deleted file mode 100644 index bba7305..0000000 Binary files a/assets/google/google_4.png and /dev/null differ diff --git a/assets/google/google_5.png b/assets/google/google_5.png deleted file mode 100644 index 966e45d..0000000 Binary files a/assets/google/google_5.png and /dev/null differ diff --git a/assets/google/google_6.png b/assets/google/google_6.png deleted file mode 100644 index 694bb33..0000000 Binary files a/assets/google/google_6.png and /dev/null differ diff --git a/assets/google/google_7.png b/assets/google/google_7.png deleted file mode 100644 index 5a164c5..0000000 Binary files a/assets/google/google_7.png and /dev/null differ diff --git a/assets/google/google_8.png b/assets/google/google_8.png deleted file mode 100644 index 8fffa27..0000000 Binary files a/assets/google/google_8.png and /dev/null differ diff --git a/blueprints.yaml b/blueprints.yaml index 4ccda16..fe5f9a0 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Login -version: 1.3.1 +version: 2.0.0 description: Enables user authentication and login screen. icon: sign-in author: @@ -23,6 +23,7 @@ form: tabs: type: tabs active: 1 + class: subtle fields: login: @@ -33,7 +34,7 @@ form: enabled: type: hidden - label: PLUGIN_ADMIN.PLUGIN_STATUS + label: PLUGIN_LOGIN.PLUGIN_STATUS highlight: 1 default: 1 options: @@ -61,7 +62,7 @@ form: help: PLUGIN_LOGIN.ROUTE_HELP placeholder: "/my-custom-login" - redirect: + redirect_after_login: type: text label: PLUGIN_LOGIN.REDIRECT_AFTER_LOGIN help: PLUGIN_LOGIN.REDIRECT_AFTER_LOGIN_HELP @@ -69,10 +70,22 @@ form: parent_acl: type: toggle - label: Use parent access rules + label: PLUGIN_LOGIN.USE_PARENT_ACL_LABEL highlight: 1 default: 0 - help: "Check for parent access rules if no rules are defined" + help: PLUGIN_LOGIN.USE_PARENT_ACL_HELP + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + protect_protected_page_media: + type: toggle + label: PLUGIN_LOGIN.PROTECT_PROTECTED_PAGE_MEDIA_LABEL + highlight: 1 + default: 0 + help: PLUGIN_LOGIN.PROTECT_PROTECTED_PAGE_MEDIA_HELP options: 1: PLUGIN_ADMIN.ENABLED 0: PLUGIN_ADMIN.DISABLED @@ -81,7 +94,7 @@ form: rememberme: type: section - title: PLUGIN_LOGIN.SESSION + title: PLUGIN_LOGIN.REMEMBER_ME fields: rememberme.enabled: @@ -98,8 +111,9 @@ form: rememberme.timeout: type: text size: small + default: 604800 label: PLUGIN_ADMIN.TIMEOUT - help: PLUGIN_ADMIN.TIMEOUT_HELP + help: PLUGIN_LOGIN.TIMEOUT_HELP validate: type: number min: 1 @@ -137,7 +151,13 @@ form: type: text label: PLUGIN_LOGIN.REDIRECT_AFTER_REGISTRATION help: PLUGIN_LOGIN.REDIRECT_AFTER_REGISTRATION_HELP - placeholder: "/my-page" + placeholder: "/page-to-show-after-registration" + + user_registration.redirect_after_activation: + type: text + label: PLUGIN_LOGIN.REDIRECT_AFTER_ACTIVATION + help: PLUGIN_LOGIN.REDIRECT_AFTER_ACTIVATION_HELP + placeholder: "/page-to-show-after-activation" registration_fields: type: section @@ -159,6 +179,30 @@ form: placeholder_key: PLUGIN_LOGIN.ADDITIONAL_PARAM_KEY placeholder_value: PLUGIN_LOGIN.ADDITIONAL_PARAM_VALUE + access_levels: + title: PLUGIN_ADMIN.ACCESS_LEVELS + type: section + security: admin.super + + fields: + user_registration.groups: + type: selectize + size: large + label: PLUGIN_ADMIN.GROUPS + '@data-options': '\Grav\User\Groups::groups' + classes: fancy + help: PLUGIN_LOGIN.GROUPS_HELP + validate: + type: commalist + + user_registration.access.site: + type: array + label: PLUGIN_ADMIN.SITE_ACCESS + help: PLUGIN_LOGIN.SITE_ACCESS_HELP + multiple: false + validate: + type: array + options: type: section title: PLUGIN_LOGIN.OPTIONS @@ -229,155 +273,3 @@ form: 1: PLUGIN_ADMIN.YES 0: PLUGIN_ADMIN.NO validate: - type: bool - - oauth: - type: tab - title: PLUGIN_LOGIN.OAUTH_SECTION - - fields: - oauth.enabled: - type: toggle - label: PLUGIN_LOGIN.OAUTH_ENABLE - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - oauth.user.autocreate: - type: toggle - label: PLUGIN_LOGIN.OAUTH_USER_AUTOCREATE - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - oauth.user.access: - type: array - label: PLUGIN_LOGIN.OAUTH_ACCESS - placeholder_key: signin.login - placeholder_value: true - - oauth.providers: - type: section - title: PLUGIN_LOGIN.OAUTH_PROVIDER_SECTION - underline: true - - fields: - oauth.providers.Facebook: - type: section - title: PLUGIN_LOGIN.FACEBOOK - - fields: - oauth.providers.Facebook.enabled: - type: toggle - label: PLUGIN_LOGIN.OAUTH_PROVIDER_FACEBOOK - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - oauth.providers.Facebook.credentials.key: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_ID - validate: - type: string - - oauth.providers.Facebook.credentials.secret: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_SECRET - validate: - type: string - - oauth.providers.Google: - type: section - title: PLUGIN_LOGIN.GOOGLE - - fields: - oauth.providers.Google.enabled: - type: toggle - label: PLUGIN_LOGIN.OAUTH_PROVIDER_GOOGLE - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - oauth.providers.Google.credentials.key: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_ID - validate: - type: string - - oauth.providers.Google.credentials.secret: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_SECRET - validate: - type: string - - oauth.providers.GitHub: - type: section - title: PLUGIN_LOGIN.GITHUB - - fields: - oauth.providers.GitHub.enabled: - type: toggle - label: PLUGIN_LOGIN.OAUTH_PROVIDER_GITHUB - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - oauth.providers.GitHub.credentials.key: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_ID - validate: - type: string - - oauth.providers.GitHub.credentials.secret: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_SECRET - validate: - type: string - - oauth.providers.Twitter: - type: section - title: PLUGIN_LOGIN.TWITTER - - fields: - oauth.providers.Twitter.enabled: - type: toggle - label: PLUGIN_LOGIN.OAUTH_PROVIDER_TWITTER - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - oauth.providers.Twitter.credentials.key: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_ID - validate: - type: string - - oauth.providers.Twitter.credentials.secret: - type: text - label: PLUGIN_LOGIN.OAUTH_CLIENT_SECRET - validate: - type: string diff --git a/classes/Controller.php b/classes/Controller.php index a626893..dbca281 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -2,13 +2,23 @@ namespace Grav\Plugin\Login; +use Grav\Common\Config\Config; use Grav\Common\Grav; -use Grav\Common\Utils; use Grav\Plugin\Login\RememberMe; +use Grav\Plugin\Login\Login; +use Grav\Common\Language\Language; +use Grav\Common\User\User; +use Grav\Common\Utils; +use Grav\Plugin\Login\Utils as LoginUtils; use Birke\Rememberme\Cookie; +use RocketTheme\Toolbox\Session\Message; -class Controller implements ControllerInterface +/** + * Class Controller + * @package Grav\Plugin\Login + */ +class Controller { /** * @var \Grav\Common\Grav @@ -38,13 +48,18 @@ class Controller implements ControllerInterface /** * @var string */ - protected $prefix = 'do'; + protected $prefix = 'task'; /** * @var \Birke\Rememberme\Authenticator */ protected $rememberMe; + /** + * @var Login + */ + protected $login; + /** * @param Grav $grav * @param string $action @@ -54,6 +69,7 @@ public function __construct(Grav $grav, $action, $post = null) { $this->grav = $grav; $this->action = $action; + $this->login = isset($this->grav['login']) ? $this->grav['login'] : ''; $this->post = $this->getPost($post); $this->rememberMe(); @@ -78,7 +94,7 @@ public function execute() } try { - $success = call_user_func(array($this, $method)); + $success = call_user_func([$this, $method]); } catch (\RuntimeException $e) { $this->setMessage($e->getMessage(), 'error'); } @@ -90,6 +106,245 @@ public function execute() return $success; } + /** + * Handle login. + * + * @return bool True if the action was performed. + */ + public function taskLogin() + { + /** @var Language $t */ + $t = $this->grav['language']; + if ($this->authenticate($this->post)) { + $this->login->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_SUCCESSFUL')); + + $redirect = $this->grav['config']->get('plugins.login.redirect_after_login'); + if (!$redirect) { + $redirect = $this->grav['uri']->referrer('/'); + } + $this->setRedirect($redirect); + } else { + $user = $this->grav['user']; + if ($user->username) { + $this->setMessage($t->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'error'); + } else { + $this->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_FAILED'), 'error'); + } + } + + return true; + } + + /** + * Handle logout. + * + * @return bool True if the action was performed. + */ + public function taskLogout() + { + /** @var User $user */ + $user = $this->grav['user']; + + if (!$this->rememberMe->login()) { + $credentials = $user->get('username'); + $this->rememberMe->getStorage()->cleanAllTriplets($credentials); + } + $this->rememberMe->clearCookie(); + + $this->grav['session']->invalidate()->start(); + $this->setRedirect('/'); + + return true; + } + + /** + * Handle the email password recovery procedure. + * + * @return bool True if the action was performed. + */ + protected function taskForgot() + { + $param_sep = $this->grav['config']->get('system.param_sep', ':'); + $data = $this->post; + + $username = isset($data['username']) ? $data['username'] : ''; + $user = !empty($username) ? User::load($username) : null; + + /** @var Language $l */ + $language = $this->grav['language']; + $messages = $this->grav['messages']; + + if (!isset($this->grav['Email'])) { + $messages->add($language->translate('PLUGIN_LOGIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); + $this->setRedirect('/'); + + return true; + } + + if (!$user || !$user->exists()) { + $messages->add($language->translate(['PLUGIN_LOGIN.FORGOT_USERNAME_DOES_NOT_EXIST', $username]), 'error'); + $this->setRedirect($this->grav['config']->get('plugins.login.route_forgot')); + + return true; + } + + if (empty($user->email)) { + $messages->add($language->translate(['PLUGIN_LOGIN.FORGOT_CANNOT_RESET_EMAIL_NO_EMAIL', $username]), + 'error'); + $this->setRedirect($this->grav['config']->get('plugins.login.route_forgot')); + + return true; + } + + $token = md5(uniqid(mt_rand(), true)); + $expire = time() + 604800; // next week + + $user->reset = $token . '::' . $expire; + $user->save(); + + $author = $this->grav['config']->get('site.author.name', ''); + $fullname = $user->fullname ?: $username; + + $reset_link = $this->grav['base_url_absolute'] . $this->grav['config']->get('plugins.login.route_reset') . '/task:login.reset/token' . $param_sep . $token . '/user' . $param_sep . $username . '/nonce' . $param_sep . Utils::getNonce('reset-form'); + + $sitename = $this->grav['config']->get('site.title', 'Website'); + $from = $this->grav['config']->get('plugins.email.from'); + + if (empty($from)) { + $messages->add($language->translate('PLUGIN_LOGIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); + $this->setRedirect($this->grav['config']->get('plugins.login.route_forgot')); + + return true; + } + + $to = $user->email; + + $subject = $language->translate(['PLUGIN_LOGIN.FORGOT_EMAIL_SUBJECT', $sitename]); + $content = $language->translate(['PLUGIN_LOGIN.FORGOT_EMAIL_BODY', $fullname, $reset_link, $author, $sitename]); + + $sent = LoginUtils::sendEmail($subject, $content, $to); + + if ($sent < 1) { + $messages->add($language->translate('PLUGIN_LOGIN.FORGOT_FAILED_TO_EMAIL'), 'error'); + } else { + $messages->add($language->translate(['PLUGIN_LOGIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL', $to]), 'info'); + } + + $this->setRedirect('/'); + + return true; + } + + /** + * Handle the reset password action. + * + * @return bool True if the action was performed. + */ + public function taskReset() + { + $data = $this->post; + $language = $this->grav['language']; + $messages = $this->grav['messages']; + + if (isset($data['password'])) { + $username = isset($data['username']) ? $data['username'] : null; + $user = !empty($username) ? User::load($username) : null; + $password = isset($data['password']) ? $data['password'] : null; + $token = isset($data['token']) ? $data['token'] : null; + + if (!empty($user) && $user->exists() && !empty($user->reset)) { + list($good_token, $expire) = explode('::', $user->reset); + + if ($good_token === $token) { + if (time() > $expire) { + $messages->add($language->translate('PLUGIN_LOGIN.RESET_LINK_EXPIRED'), 'error'); + $this->grav->redirect($this->grav['config']->get('plugins.login.route_forgot')); + + return true; + } + + unset($user->hashed_password); + unset($user->reset); + $user->password = $password; + + $user->validate(); + $user->filter(); + $user->save(); + + $messages->add($language->translate('PLUGIN_LOGIN.RESET_PASSWORD_RESET'), 'info'); + $this->grav->redirect('/'); + + return true; + } + } + + $messages->add($language->translate('PLUGIN_LOGIN.RESET_INVALID_LINK'), 'error'); + $this->grav->redirect($this->grav['config']->get('plugins.login.route_forgot')); + + return true; + + } else { + $user = $this->grav['uri']->param('user'); + $token = $this->grav['uri']->param('token'); + + if (empty($user) || empty($token)) { + $messages->add($language->translate('PLUGIN_LOGIN.RESET_INVALID_LINK'), 'error'); + $this->grav->redirect($this->grav['config']->get('plugins.login.route_forgot')); + + return true; + } + } + + return true; + } + + /** + * Authenticate user. + * + * @param array $form Form fields. + * + * @return bool + */ + protected function authenticate($form) + { + /** @var User $user */ + $user = $this->grav['user']; + + if (!$user->authenticated) { + $username = isset($form['username']) ? $form['username'] : $this->rememberMe->login(); + + // Normal login process + $user = User::load($username); + if ($user->exists()) { + if (!empty($form['username']) && !empty($form['password'])) { + // Authenticate user + $user->authenticated = $user->authenticate($form['password']); + + if ($user->authenticated) { + $this->grav['session']->user = $user; + + unset($this->grav['user']); + $this->grav['user'] = $user; + + // If the user wants to be remembered, create Rememberme cookie + if (!empty($form['rememberme'])) { + $this->rememberMe->createCookie($form['username']); + } else { + $this->rememberMe->clearCookie(); + $this->rememberMe->getStorage()->cleanAllTriplets($user->get('username')); + } + } + } + } + } + + // Authorize against user ACL + $user_authorized = $user->authorize('site.login'); + $user->authenticated = ($user->authenticated && $user_authorized); + + return $user->authenticated; + } + /** * Redirects an action */ @@ -97,21 +352,19 @@ public function redirect() { if ($this->redirect) { $this->grav->redirect($this->redirect, $this->redirectCode); - } else if ($redirect = $this->grav['config']->get('plugins.login.redirect')) { - $this->grav->redirect($redirect, $this->redirectCode); } } /** * Set redirect. * - * @param $path + * @param $path * @param int $code */ public function setRedirect($path, $code = 303) { $this->redirect = $path; - $this->code = $code; + $this->redirectCode = $code; } /** @@ -130,15 +383,16 @@ public function setMessage($msg, $type = 'info') /** * Gets and sets the RememberMe class * - * @param mixed $var A rememberMe instance to set + * @param mixed $var A rememberMe instance to set * - * @return Authenticator Returns the current rememberMe instance + * @return RememberMe\RememberMe Returns the current rememberMe instance */ public function rememberMe($var = null) { if ($var !== null) { $this->rememberMe = $var; } + if (!$this->rememberMe) { /** @var Config $config */ $config = $this->grav['config']; @@ -151,7 +405,8 @@ public function rememberMe($var = null) // Hardening cookies with user-agent and random salt or // fallback to use system based cache key - $data = $_SERVER['HTTP_USER_AGENT'] . $config->get('security.salt', $this->grav['cache']->getKey()); + $server_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'unknown'; + $data = $server_agent . $config->get('security.salt', $this->grav['cache']->getKey()); $this->rememberMe->setSalt(hash('sha512', $data)); // Set cookie with correct base path of Grav install @@ -167,6 +422,7 @@ public function rememberMe($var = null) * Prepare and return POST data. * * @param array $post + * * @return array */ protected function &getPost($post) @@ -178,6 +434,7 @@ protected function &getPost($post) $post = array_merge_recursive($post, $this->jsonDecode($post['_json'])); unset($post['_json']); } + return $post; } @@ -185,6 +442,7 @@ protected function &getPost($post) * Recursively JSON decode data. * * @param array $data + * * @return array */ protected function jsonDecode(array $data) @@ -196,6 +454,7 @@ protected function jsonDecode(array $data) $value = json_decode($value, true); } } + return $data; } } diff --git a/classes/ControllerInterface.php b/classes/ControllerInterface.php deleted file mode 100644 index a80e14d..0000000 --- a/classes/ControllerInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -grav = $grav; + $this->config = $this->grav['config']; + //$this->route = $route; + $this->session = $this->grav['session']; + $this->user = $this->grav['user']; + + $this->uri = $this->grav['uri']; + } + + /** + * Add message into the session queue. + * + * @param string $msg + * @param string $type + */ + public function setMessage($msg, $type = 'info') + { + /** @var Message $messages */ + $messages = $this->grav['messages']; + $messages->add($msg, $type); + } + + /** + * Fetch and delete messages from the session queue. + * + * @param string $type + * + * @return array + */ + public function messages($type = null) + { + /** @var Message $messages */ + $messages = $this->grav['messages']; + + return $messages->fetch($type); + } + + /** + * Authenticate user. + * + * @param array $form Form fields. + * + * @return bool + */ + public function authenticate($form) + { + if (!$this->user->authenticated && isset($form['username']) && isset($form['password'])) { + $user = User::load($form['username']); + + //default to english if language not set + if (empty($user->language)) { + $user->set('language', 'en'); + } + + if ($user->exists()) { + $user->authenticated = true; + + // Authenticate user. + $result = $user->authenticate($form['password']); + + if ($result) { + $this->user = $this->session->user = $user; + + /** @var Grav $grav */ + $grav = $this->grav; + + $this->setMessage($this->grav['language']->translate('PLUGIN_LOGIN.LOGIN_SUCCESSFUL', + [$this->user->language]), 'info'); + + $redirect_route = $this->uri->route(); + $grav->redirect($redirect_route); + } + } + } + + return $this->authorize(); + } + + /** + * Checks user authorisation to the action. + * + * @param string $action + * + * @return bool + */ + public function authorize($action = 'admin.login') + { + $action = (array)$action; + + foreach ($action as $a) { + if ($this->user->authorize($a)) { + return true; + } + } + + return false; + } + + /** + * Create a new user file + * + * @param array $data + * + * @return User + */ + public function register($data) + { + //Add new user ACL settings + $groups = $this->config->get('plugins.login.user_registration.groups', []); + + if (count($groups) > 0) { + $data['groups'] = $groups; + } + + $access = $this->config->get('plugins.login.user_registration.access.site', []); + if (count($access) > 0) { + $data['access']['site'] = $access; + } + + $username = $data['username']; + $file = CompiledYamlFile::instance($this->grav['locator']->findResource('account://' . $username . YAML_EXT, + true, true)); + + // Create user object and save it + $user = new User($data); + $user->file($file); + $user->save(); + + if (isset($data['state']) && $data['state'] == 'enabled' && $this->config->get('plugins.login.user_registration.options.login_after_registration', false)) { + //Login user + $this->grav['session']->user = $user; + unset($this->grav['user']); + $this->grav['user'] = $user; + $user->authenticated = $user->authorize('site.login'); + } + + return $user; + } + + + /** + * Handle the email to notificate the user account creation to the site admin. + * + * @param $user + * + * @return bool True if the action was performed. + */ + public function sendNotificationEmail($user) + { + if (empty($user->email)) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_NEEDS_EMAIL_FIELD')); + } + + $sitename = $this->grav['config']->get('site.title', 'Website'); + + $subject = $this->grav['language']->translate(['PLUGIN_LOGIN.NOTIFICATION_EMAIL_SUBJECT', $sitename]); + $content = $this->grav['language']->translate([ + 'PLUGIN_LOGIN.NOTIFICATION_EMAIL_BODY', + $sitename, + $user->username, + $user->email + ]); + $to = $this->grav['config']->get('plugins.email.from'); + + if (empty($to)) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_NOT_CONFIGURED')); + } + + $sent = LoginUtils::sendEmail($subject, $content, $to); + + if ($sent < 1) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_SENDING_FAILURE')); + } + + return true; + } + + /** + * Handle the email to welcome the new user + * + * @param $user + * + * @return bool True if the action was performed. + */ + public function sendWelcomeEmail($user) + { + if (empty($user->email)) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_NEEDS_EMAIL_FIELD')); + } + + $sitename = $this->grav['config']->get('site.title', 'Website'); + + $subject = $this->grav['language']->translate(['PLUGIN_LOGIN.WELCOME_EMAIL_SUBJECT', $sitename]); + $content = $this->grav['language']->translate(['PLUGIN_LOGIN.WELCOME_EMAIL_BODY', $user->username, $sitename]); + $to = $user->email; + + $sent = LoginUtils::sendEmail($subject, $content, $to); + + if ($sent < 1) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_SENDING_FAILURE')); + } + + return true; + } + + /** + * Handle the email to activate the user account. + * + * @param User $user + * + * @return bool True if the action was performed. + */ + public function sendActivationEmail($user) + { + if (empty($user->email)) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_NEEDS_EMAIL_FIELD')); + } + + $token = md5(uniqid(mt_rand(), true)); + $expire = time() + 604800; // next week + $user->activation_token = $token . '::' . $expire; + $user->save(); + + $param_sep = $this->grav['config']->get('system.param_sep', ':'); + $activation_link = $this->grav['base_url_absolute'] . $this->config->get('plugins.login.route_activate') . '/token' . $param_sep . $token . '/username' . $param_sep . $user->username . '/nonce' . $param_sep . Utils::getNonce('user-activation'); + + $site_name = $this->grav['config']->get('site.title', 'Website'); + + $subject = $this->grav['language']->translate(['PLUGIN_LOGIN.ACTIVATION_EMAIL_SUBJECT', $site_name]); + $content = $this->grav['language']->translate([ + 'PLUGIN_LOGIN.ACTIVATION_EMAIL_BODY', + $user->username, + $activation_link, + $site_name + ]); + $to = $user->email; + + $sent = LoginUtils::sendEmail($subject, $content, $to); + + if ($sent < 1) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_SENDING_FAILURE')); + } + + return true; + } +} diff --git a/classes/LoginController.php b/classes/LoginController.php deleted file mode 100644 index a0ff8b2..0000000 --- a/classes/LoginController.php +++ /dev/null @@ -1,242 +0,0 @@ -grav['language']; - if ($this->authenticate($this->post)) { - $this->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_SUCCESSFUL')); - $referrer = $this->grav['uri']->referrer('/'); - $this->setRedirect($referrer); - } else { - $user = $this->grav['user']; - if ($user->username) { - $this->setMessage($t->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'error'); - } else { - $this->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_FAILED'), 'error'); - } - } - - return true; - } - - /** - * Handle logout. - * - * @return bool True if the action was performed. - */ - public function taskLogout() - { - /** @var User $user */ - $user = $this->grav['user']; - - if (!$this->rememberMe->login()) { - $credentials = $user->get('username'); - $this->rememberMe->getStorage()->cleanAllTriplets($credentials); - } - $this->rememberMe->clearCookie(); - - $this->grav['session']->invalidate()->start(); - $this->setRedirect('/'); - - return true; - } - - /** - * Handle the email password recovery procedure. - * - * @return bool True if the action was performed. - */ - protected function taskForgot() - { - $param_sep = $this->grav['config']->get('system.param_sep', ':'); - $data = $this->post; - - $username = isset($data['username']) ? $data['username'] : ''; - $user = !empty($username) ? User::load($username) : null; - - /** @var Language $l */ - $language = $this->grav['language']; - $messages = $this->grav['messages']; - - if (!isset($this->grav['Email'])) { - $messages->add($language->translate('PLUGIN_ADMIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); - $this->setRedirect('/'); - return true; - } - - if (!$user || !$user->exists()) { - $messages->add($language->translate(['PLUGIN_ADMIN.FORGOT_USERNAME_DOES_NOT_EXIST', $username]), 'error'); - $this->setRedirect('/forgot'); - return true; - } - - if (empty($user->email)) { - $messages->add($language->translate(['PLUGIN_ADMIN.FORGOT_CANNOT_RESET_EMAIL_NO_EMAIL', $username]), 'error'); - $this->setRedirect('/forgot'); - return true; - } - - $token = md5(uniqid(mt_rand(), true)); - $expire = time() + 604800; // next week - - $user->reset = $token . '::' . $expire; - $user->save(); - - $author = $this->grav['config']->get('site.author.name', ''); - $fullname = $user->fullname ?: $username; - - $reset_link = $this->grav['base_url_absolute'] . $this->grav['config']->get('plugins.login.route_reset') . '/task:login.reset/token' . $param_sep . $token . '/user' . $param_sep . $username . '/nonce' . $param_sep . Utils::getNonce('reset-form'); - - $sitename = $this->grav['config']->get('site.title', 'Website'); - $from = $this->grav['config']->get('plugins.email.from'); - - if (empty($from)) { - $messages->add($language->translate('PLUGIN_ADMIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); - $this->setRedirect('/forgot'); - return true; - } - - $to = $user->email; - - $subject = $language->translate(['PLUGIN_ADMIN.FORGOT_EMAIL_SUBJECT', $sitename]); - $content = $language->translate(['PLUGIN_ADMIN.FORGOT_EMAIL_BODY', $fullname, $reset_link, $author, $sitename]); - - $sent = LoginUtils::sendEmail($subject, $content, $to); - - if ($sent < 1) { - $messages->add($language->translate('PLUGIN_ADMIN.FORGOT_FAILED_TO_EMAIL'), 'error'); - } else { - $messages->add($language->translate(['PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL', $to]), 'info'); - } - - $this->setRedirect('/'); - return true; - } - - /** - * Handle the reset password action. - * - * @return bool True if the action was performed. - */ - public function taskReset() - { - $data = $this->post; - $language = $this->grav['language']; - $messages = $this->grav['messages']; - - if (isset($data['password'])) { - $username = isset($data['username']) ? $data['username'] : null; - $user = !empty($username) ? User::load($username) : null; - $password = isset($data['password']) ? $data['password'] : null; - $token = isset($data['token']) ? $data['token'] : null; - - if (!empty($user) && $user->exists() && !empty($user->reset)) { - list($good_token, $expire) = explode('::', $user->reset); - - if ($good_token === $token) { - if (time() > $expire) { - $messages->add($language->translate('PLUGIN_ADMIN.RESET_LINK_EXPIRED'), 'error'); - $this->grav->redirect($this->grav['config']->get('plugins.login.route_forgot')); - return true; - } - - unset($user->hashed_password); - unset($user->reset); - $user->password = $password; - - $user->validate(); - $user->filter(); - $user->save(); - - $messages->add($language->translate('PLUGIN_ADMIN.RESET_PASSWORD_RESET'), 'info'); - $this->grav->redirect('/'); - return true; - } - } - - $messages->add($language->translate('PLUGIN_ADMIN.RESET_INVALID_LINK'), 'error'); - $this->grav->redirect($this->grav['config']->get('plugins.login.route_forgot')); - return true; - - } else { - $user = $this->grav['uri']->param('user'); - $token = $this->grav['uri']->param('token'); - - if (empty($user) || empty($token)) { - $messages->add($language->translate('PLUGIN_ADMIN.RESET_INVALID_LINK'), 'error'); - $this->grav->redirect($this->grav['config']->get('plugins.login.route_forgot')); - return true; - } - } - - return true; - } - - /** - * Authenticate user. - * - * @param array $form Form fields. - * @return bool - */ - protected function authenticate($form) - { - /** @var User $user */ - $user = $this->grav['user']; - - if (!$user->authenticated) { - $username = isset($form['username']) ? $form['username'] : $this->rememberMe->login(); - - // Normal login process - $user = User::load($username); - if ($user->exists()) { - if (!empty($form['username']) && !empty($form['password'])) { - // Authenticate user. - $user->authenticated = $user->authenticate($form['password']); - - if ($user->authenticated) { - $this->grav['session']->user = $user; - - unset($this->grav['user']); - $this->grav['user'] = $user; - - // If the user wants to be remembered, create - // Rememberme cookie - if (!empty($form['rememberme'])) { - $this->rememberMe->createCookie($form['username']); - } else { - $this->rememberMe->clearCookie(); - $this->rememberMe->getStorage()->cleanAllTriplets($user->get('username')); - } - } - } - } - } - - // Authorize against user ACL - $user_authorized = $user->authorize('site.login'); - $user->authenticated = ($user->authenticated && $user_authorized); - - return $user->authenticated; - } -} diff --git a/classes/OAuthLoginController.php b/classes/OAuthLoginController.php deleted file mode 100644 index ec13795..0000000 --- a/classes/OAuthLoginController.php +++ /dev/null @@ -1,433 +0,0 @@ - - */ -class OAuthLoginController extends Controller -{ - /** - * @var string - */ - public $provider; - - /** - * @var \OAuth\Common\Storage\Session - */ - protected $storage; - - /** - * @var \OAuth\ServiceFactory - */ - protected $factory; - - /** - * @var \OAuth\Common\Service\AbstractService - */ - protected $service; - - /** - * @var string - */ - protected $prefix = 'oauth'; - - /** - * @var array - */ - protected $scopes = [ - 'github' => ['user'], - 'google' => ['userinfo_email', 'userinfo_profile'], - 'facebook' => ['public_profile'] - ]; - - /** - * Constructor. - * - * @param Grav $grav Grav instance - * @param string $action The name of the action - * @param array $post An array of values passed to the action - */ - public function __construct(Grav $grav, $action, $post = null) - { - parent::__construct($grav, ucfirst($action), $post); - - // Session storage - $this->storage = new Session(false, 'oauth_token', 'oauth_state'); - - /** @var $serviceFactory \OAuth\ServiceFactory */ - $this->factory = new ServiceFactory(); - - // Use curl client instead of fopen stream - if (extension_loaded('curl')) { - $this->factory->setHttpClient(new CurlCLient()); - } - } - - /** - * Performs an OAuth authentication - */ - public function execute() - { - /** @var \Grav\Common\Language\Language */ - $t = $this->grav['language']; - - $provider = strtolower($this->action); - $config = $this->grav['config']->get('plugins.login.oauth.providers.' . $this->action, []); - - if (isset($config['credentials'])) { - // Setup the credentials for the requests - $credentials = new Credentials( - $config['credentials']['key'], $config['credentials']['secret'], $this->grav['uri']->url(true) - ); - - // Instantiate service using the credentials, http client - // and storage mechanism for the token - $scope = isset($this->scopes[$provider]) ? $this->scopes[$provider] : []; - $this->service = $this->factory->createService($this->action, $credentials, $this->storage, $scope); - } - - if (!$this->service || empty($config)) { - $this->setMessage($t->translate(['PLUGIN_LOGIN.OAUTH_PROVIDER_NOT_SUPPORTED', $this->action]), 'error'); - return true; - } - - // Check OAuth authentication status - $authenticated = parent::execute(); - if (is_bool($authenticated)) { - $this->reset(); - if ($authenticated) { - $this->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_SUCCESSFUL')); - } else { - $this->setMessage($t->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'error'); - } - - // Redirect to current URI - $referrer = $this->grav['uri']->url(true); - $this->setRedirect($referrer); - } elseif (!$this->grav['session']->oauth) { - $this->setMessage($t->translate(['PLUGIN_LOGIN.OAUTH_PROVIDER_NOT_SUPPORTED', $this->action]), 'error'); - } - - return true; - } - - /** - * Reset state of OAuth authentication. - */ - public function reset() { - /** @var Grav\Common\Session */ - $session = $this->grav['session']; - - unset($session->oauth); - $this->storage->clearAllTokens(); - $this->storage->clearAllAuthorizationStates(); - } - - /** - * Implements a generic OAuth service provider authentication - * - * @param callable $callback A callable to call when OAuth authentication - * starts - * @param string $oauth OAuth version to be used for authentication - * - * @return null|User Returns a Grav user instance on success. - */ - protected function genericOAuthProvider($callback, $oauth = 'oauth2') - { - /** @var Grav\Common\Session */ - $session = $this->grav['session']; - - switch ($oauth) { - case 'oauth1': - if (empty($_GET['oauth_token']) && empty($_GET['oauth_verifier'])) { - // Extra request needed for OAuth1 to request a request token :-) - $token = $this->service->requestRequestToken(); - - // Create a state token to prevent request forgery. - // Store it in the session for later validation. - $redirect = $this->service->getAuthorizationUri([ - 'oauth_token' => $token->getRequestToken() - ]); - $this->setRedirect($redirect); - - // Update OAuth session - $session->oauth = $this->action; - } else { - $token = $this->storage->retrieveAccessToken($session->oauth); - - // This was a callback request from OAuth1 service, get the token - $this->service->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - return $callback(); - } - break; - - case 'oauth2': - default: - if (empty($_GET['code'])) { - // Create a state token to prevent request forgery (CSRF). - $state = sha1($this->getRandomBytes(1024, false)); - $redirect = $this->service->getAuthorizationUri([ - 'state' => $state - ]); - $this->setRedirect($redirect); - - // Update OAuth session - $session->oauth = $this->action; - - // Store CSRF in the session for later validation. - $this->storage->storeAuthorizationState($this->action, $state); - } else { - // Retrieve the CSRF state parameter - $state = isset($_GET['state']) ? $_GET['state'] : null; - - // This was a callback request from the OAuth2 service, get the token - $this->service->requestAccessToken($_GET['code'], $state); - - return $callback(); - } - break; - } - } - - /** - * Implements OAuth authentication for Facebook - * - * @return null|bool Returns a boolean on finished authentication. - */ - public function oauthFacebook() - { - return $this->genericOAuthProvider(function() { - // Send a request now that we have access token - $data = json_decode($this->service->request('/me'), true); - $email = isset($data['email']) ? $data['email'] : ''; - - // Authenticate OAuth user against Grav system. - return $this->authenticate($data['name'], $data['id'], $email); - }); - } - - /** - * Implements OAuth authentication for Google - * - * @return null|bool Returns a boolean on finished authentication. - */ - public function oauthGoogle() - { - return $this->genericOAuthProvider(function() { - // Get username, email and language - $data = json_decode($this->service->request('userinfo'), true); - - $username = $data['given_name'] . ' ' . $data['family_name']; - if (preg_match('~[\w\s]+\((\w+)\)~i', $data['name'], $matches)) { - $username = $matches[1]; - } - $lang = isset($data['lang']) ? $data['lang'] : ''; - - // Authenticate OAuth user against Grav system. - return $this->authenticate($username, $data['id'], $data['email'], $lang); - }); - } - - /** - * Implements OAuth authentication for GitHub - * - * @return null|bool Returns a boolean on finished authentication. - */ - public function oauthGithub() - { - return $this->genericOAuthProvider(function() { - // Get username, email and language - $user = json_decode($this->service->request('user'), true); - $emails = json_decode($this->service->request('user/emails'), true); - - // Authenticate OAuth user against Grav system. - return $this->authenticate($user['login'], $user['id'], reset($emails)); - }); - } - - /** - * Implements OAuth authentication for Twitter - * - * @return null|bool Returns a boolean on finished authentication. - */ - public function oauthTwitter() - { - return $this->genericOAuthProvider(function() { - // Get username, email and language - $data = json_decode( - $this->service->request('account/verify_credentials.json?include_email=true'), - true); - $lang = isset($data['lang']) ? $data['lang'] : ''; - - // Authenticate OAuth user against Grav system. - return $this->authenticate($data['screen_name'], $data['id'], '', $lang); - }, 'oauth1'); - } - - /** - * Authenticate user. - * - * @param string $username The username of the OAuth user - * @param string $email The email of the OAuth user - * @param string $language Language - * - * @return bool True if user was authenticated - */ - protected function authenticate($username, $id, $email, $language = '') - { - $accountFile = $this->grav['inflector']->underscorize($username); - $user = User::load(strtolower("$accountFile.{$this->action}")); - - if ($user->exists()) { - // Update username (hide OAuth from user) - $user->set('username', $username); - - $password = md5($id); - $authenticated = $user->authenticate($password); - } else { - /** @var User $user */ - $user = $this->grav['user']; - - // Check user rights - if (!$user->authenticated) { - $oauthUser = $this->grav['config']->get('plugins.login.oauth.user', []); - - // Create new user from OAuth request - $user = $this->createUser([ - 'id' => $id, - 'username' => $username, - 'email' => $email, - 'lang' => $language, - 'access' => $oauthUser['access'] - ], $oauthUser['autocreate']); - } - - // Authenticate user against oAuth rules - $authenticated = $user->authenticated; - } - - // Store user in session - if ($authenticated) { - $this->grav['session']->user = $user; - - unset($this->grav['user']); - $this->grav['user'] = $user; - } - - return $authenticated; - } - - /** - * Create user. - * - * @param string $data['username'] The username of the OAuth user - * @param string $data['password'] The unique id of the Oauth user - * setting as password - * @param string $data['email'] The email of the OAuth user - * @param string $data['language'] Language - * @param bool $save Save user - * - * @return User A user object - */ - protected function createUser($data, $save = false) - { - /** @var User $user */ - $user = $this->grav['user']; - - $accountFile = $this->grav['inflector']->underscorize($data['username']); - $accountFile = $this->grav['locator']->findResource('user://accounts/' . strtolower("$accountFile.{$this->action}") . YAML_EXT, true, true); - - $user->set('username', $data['username']); - $user->set('password', md5($data['id'])); - $user->set('email', $data['email']); - $user->set('lang', $data['lang']); - - // Set access rights - $user->set('access', $this->grav['config']->get('plugins.login.oauth.user.access', [])); - - // Authorize OAuth user to access page(s) - $user->authenticated = $user->authorize('site.login'); - - if ($save) { - $user->file(CompiledYamlFile::instance($accountFile)); - $user->save(); - } - - return $user; - } - - /** - * Generates Random Bytes for the given $length. - * - * @param int $length The number of bytes to generate - * @param bool $secure Return cryptographic secure string or not - * - * @return string - * - * @throws InvalidArgumentException when an invalid length is specified. - * @throws RuntimeException when no secure way of making bytes is posible - */ - protected function getRandomBytes($length = 0, $secure = true) - { - if ($length < 1) { - throw new \InvalidArgumentException('The length parameter must be a number greater than zero!'); - } - - /** - * Our primary choice for a cryptographic strong randomness function is - * openssl_random_pseudo_bytes. - */ - if (function_exists('openssl_random_pseudo_bytes')) { - $bytes = openssl_random_pseudo_bytes($length, $sec); - if ($sec === true) { - return $bytes; - } - } - - /** - * If mcrypt extension is available then we use it to gather entropy from - * the operating system's PRNG. This is better than reading /dev/urandom - * directly since it avoids reading larger blocks of data than needed. - * Older versions of mcrypt_create_iv may be broken or take too much time - * to finish so we only use this function with PHP 5.3.7 and above. - * @see https://bugs.php.net/bug.php?id=55169 - */ - if (function_exists('mcrypt_create_iv') && - (strtolower(substr(PHP_OS, 0, 3)) !== 'win' || - version_compare(PHP_VERSION, '5.3.7') >= 0)) { - $bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); - if ($bytes !== false) { - return $bytes; - } - } - - if ($secure) { - throw new \RuntimeException('There is no possible way of making secure bytes'); - } - - /** - * Fallback (not really secure, but better than nothing) - */ - return hex2bin(substr(str_shuffle(str_repeat('0123456789abcdef', $length*16)), 0, $length)); - } -} diff --git a/classes/Utils.php b/classes/Utils.php index ab47ee3..f12a3a6 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -4,11 +4,16 @@ use Grav\Common\Grav; +/** + * Class Utils + * @package Grav\Plugin\Login + */ class Utils { /** * Handle sending an email. * + * @param $subject * @param string $content * @param string $to * diff --git a/cli/ChangePasswordCommand.php b/cli/ChangePasswordCommand.php index 1fc8604..d15abb7 100644 --- a/cli/ChangePasswordCommand.php +++ b/cli/ChangePasswordCommand.php @@ -97,7 +97,7 @@ protected function serve() $username = strtolower($username); // Grab the account file and read in the information before setting the file (prevent setting erase) - $oldUserFile = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('user://accounts/' . $username . YAML_EXT, true, true)); + $oldUserFile = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('account://' . $username . YAML_EXT, true, true)); $oldData = $oldUserFile->content(); //Set the password feild to new password @@ -105,7 +105,7 @@ protected function serve() // Create user object and save it using oldData (with updated password) $user = new User($oldData); - $file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('user://accounts/' . $username . YAML_EXT, true, true)); + $file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('account://' . $username . YAML_EXT, true, true)); $user->file($file); $user->save(); @@ -137,7 +137,7 @@ protected function validate($type, $value, $extra = '') if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) { throw new \RuntimeException('Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'); } - if (!file_exists(self::getGrav()['locator']->findResource('user://accounts/' . $value . YAML_EXT))) { + if (!file_exists(self::getGrav()['locator']->findResource('account://' . $value . YAML_EXT))) { throw new \RuntimeException('Username "' . $value . '" does not exist, please pick another username'); } diff --git a/cli/ChangeUserStateCommand.php b/cli/ChangeUserStateCommand.php index a14b639..40f9dc6 100644 --- a/cli/ChangeUserStateCommand.php +++ b/cli/ChangeUserStateCommand.php @@ -96,7 +96,7 @@ protected function serve() $username = strtolower($username); // Grab the account file and read in the information before setting the file (prevent setting erase) - $oldUserFile = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('user://accounts/' . $username . YAML_EXT, true, true)); + $oldUserFile = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('account://' . $username . YAML_EXT, true, true)); $oldData = $oldUserFile->content(); //Set the state feild to new state @@ -104,7 +104,7 @@ protected function serve() // Create user object and save it using oldData (with updated state) $user = new User($oldData); - $file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('user://accounts/' . $username . YAML_EXT, true, true)); + $file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('account://' . $username . YAML_EXT, true, true)); $user->file($file); $user->save(); @@ -136,7 +136,7 @@ protected function validate($type, $value, $extra = '') if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) { throw new \RuntimeException('Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'); } - if (!file_exists(self::getGrav()['locator']->findResource('user://accounts/' . $value . YAML_EXT))) { + if (!file_exists(self::getGrav()['locator']->findResource('account://' . $value . YAML_EXT))) { throw new \RuntimeException('Username "' . $value . '" does not exist, please pick another username'); } diff --git a/cli/NewUserCommand.php b/cli/NewUserCommand.php index 1b595ef..17dbf48 100644 --- a/cli/NewUserCommand.php +++ b/cli/NewUserCommand.php @@ -4,6 +4,7 @@ use Grav\Console\ConsoleCommand; use Grav\Common\File\CompiledYamlFile; use Grav\Common\User\User; +use Grav\Common\Grav; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Question\ChoiceQuestion; @@ -207,7 +208,7 @@ protected function serve() // Create user object and save it $user = new User($data); - $file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource('user://accounts/' . $username . YAML_EXT, true, true)); + $file = CompiledYamlFile::instance(Grav::instance()['locator']->findResource('account://' . $username . YAML_EXT, true, true)); $user->file($file); $user->save(); @@ -239,7 +240,7 @@ protected function validate($type, $value, $extra = '') if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) { throw new \RuntimeException('Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'); } - if (file_exists(self::getGrav()['locator']->findResource('user://accounts/' . $value . YAML_EXT))) { + if (file_exists(Grav::instance()['locator']->findResource('account://' . $value . YAML_EXT))) { throw new \RuntimeException('Username "' . $value . '" already exists, please pick another username'); } diff --git a/composer.json b/composer.json index 181805a..78751cc 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ }, "require": { "php": ">=5.4.0", - "lusitanian/oauth": "0.8.*", "birke/rememberme": "1.*" }, "autoload": { diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..b4eee9e --- /dev/null +++ b/composer.lock @@ -0,0 +1,63 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "468b7385e7f02c35396a205864c36ceb", + "content-hash": "540c2e320c9819de1b7c90b59f17263d", + "packages": [ + { + "name": "birke/rememberme", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/gbirke/rememberme.git", + "reference": "4e71b0d9c692db28ae78c7eea752c4599b87dc2c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/gbirke/rememberme/zipball/4e71b0d9c692db28ae78c7eea752c4599b87dc2c", + "reference": "4e71b0d9c692db28ae78c7eea752c4599b87dc2c", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Birke\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gabriel Birke", + "email": "gb@birke-software.de" + } + ], + "description": "Secure \"Remember Me\" functionality", + "homepage": "https://github.com/gbirke/rememberme", + "keywords": [ + "cookie", + "remember", + "security" + ], + "time": "2015-07-22 18:26:14" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.4.0" + }, + "platform-dev": [] +} diff --git a/css/login.css b/css/login.css index 0e2ca53..6b7f3c4 100644 --- a/css/login.css +++ b/css/login.css @@ -31,77 +31,9 @@ #grav-login .form-actions p { margin-bottom: 0; } -#grav-login .form-oauth .oauth-provider, -#grav-login .form-oauth .oauth-provider-extra { - list-style: outside none none; - margin: 0.5rem 0; - padding: 0; -} -#grav-login .oauth-provider li { - display: inline-block; - padding: 0.25rem; -} -#grav-login .oauth-provider .button { - height: 5rem; - width: 5rem; - opacity: 1; -} - -#grav-login .form-oauth .button:hover { - opacity: 0.75; -} - -#grav-login .form-oauth button.facebook { - background-color: #4c699e; -} -#grav-login .form-oauth button.google { - background-color: #da573b; -} -#grav-login .form-oauth button.twitter { - background-color: #1daee3; -} -#grav-login .form-oauth button.github { - background-color: #5c5853; -} -#grav-login .form-oauth button.bitbucket { - background-color: #205081; -} -#grav-login .form-oauth button.flickr { - background-color: #400090; -} -#grav-login .form-oauth button.microsoft { - background-color: #2672ec; -} -#grav-login .form-oauth > input { - display: none; -} - -#grav-login .oauth-provider .button { - display: block; - font-size: 0.8rem; - font-weight: bold; - height: 5rem; - line-height: 8rem; - margin: 0; - padding: 0; - position: relative; - text-align: center; - width: 5rem; - color: white; - border: none; -} - -#grav-login .oauth-provider .button i { - bottom: 0; - content: " "; - display: block; - font-size: 3rem; - left: 0; - margin-top: .5rem; - position: absolute; - right: 0; - top: 0; +#grav-login .button { + vertical-align: middle; } #grav-login .delimiter { @@ -132,86 +64,6 @@ right: 0; } -#grav-login .form-oauth { - position: relative; -} - -#grav-login .oauth-provider-extra { - background: #eee; - border: 4px solid #eee; - border-radius: 4px; - opacity: 0; - position: absolute; - z-index: 1; - right: -9999px; - top: 1.6rem; - - -webkit-transition: opacity 0.3s ease-in-out 0s, right 0s linear 0.3s; - -moz-transition: opacity 0.3s ease-in-out 0s, right 0s linear 0.3s; - -ms-transition: opacity 0.3s ease-in-out 0s, right 0s linear 0.3s; - -o-transition: opacity 0.3s ease-in-out 0s, right 0s linear 0.3s; - transition: opacity 0.3s ease-in-out 0s, right 0s linear 0.3s; -} - -#grav-login .oauth-provider-extra::before { - background-color: ; - border: 1em solid transparent; - border-bottom-color: #eee; - bottom: 100%; - content: " "; - display: block; - height: 0; - left: 0; - margin: 0 auto; - position: absolute; - right: 0; - width: 0; -} - -#grav-login .oauth-provider-extra .button { - border: none; - border-radius: 0; - display: inline-block; - text-align: left; - width: 100%; - color: white; - font-weight: bold; - font-size: 0.9rem; -} - -#grav-login .oauth-provider-extra i[class~="fa"] { - display: inline-block; - font-size: 2rem; - margin-right: 0.5rem; - vertical-align: middle; -} - -#grav-login .form-oauth label { - color: #1bb3e9; - cursor: pointer; - display: inline; - font-weight: inherit; - position: relative; - z-index: 2; - - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - - -#grav-login #oauth-input:checked + .oauth-provider-extra { - opacity: 1; - right: 0; - - -webkit-transition: opacity 0.3s ease-in-out 0s; - -moz-transition: opacity 0.3s ease-in-out 0s; - -ms-transition: opacity 0.3s ease-in-out 0s; - -o-transition: opacity 0.3s ease-in-out 0s; - transition: opacity 0.3s ease-in-out 0s; -} - #grav-login .rememberme { display: inline-block; float: left; diff --git a/languages.yaml b/languages.yaml old mode 100644 new mode 100755 index 4d3bd2c..7752415 --- a/languages.yaml +++ b/languages.yaml @@ -2,80 +2,56 @@ en: PLUGIN_LOGIN: USERNAME: Username PASSWORD: Password - ACCESS_DENIED: Access denied... LOGIN_FAILED: Login failed... LOGIN_SUCCESSFUL: You have been successfully logged in. - BTN_LOGIN: Login BTN_LOGOUT: Logout BTN_FORGOT: Forgot BTN_REGISTER: Register - + BTN_RESET: "Reset Password" + BTN_SEND_INSTRUCTIONS: "Send Reset Instructions" + RESET_LINK_EXPIRED: "Reset link has expired, please try again" + RESET_PASSWORD_RESET: "Password has been reset" + RESET_INVALID_LINK: "Invalid reset link used, please try again" + FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL: "Instructions to reset your password have been sent via email to %s" + FORGOT_FAILED_TO_EMAIL: "Failed to email instructions, please try again later" + FORGOT_CANNOT_RESET_EMAIL_NO_EMAIL: "Cannot reset password for %s, no email address is set" + FORGOT_USERNAME_DOES_NOT_EXIST: "User with username %s does not exist" + FORGOT_EMAIL_NOT_CONFIGURED: "Cannot reset password. This site is not configured to send emails" + FORGOT_EMAIL_SUBJECT: "%s Password Reset Request" + FORGOT_EMAIL_BODY: "

Password Reset

Dear %1$s,

A request was made on %4$s to reset your password.


Click this to reset your password

Alternatively, copy the following URL into your browser's address bar:

%2$s


Kind regards,

%3$s

" SESSION: "“Remember Me”-Session" REMEMBER_ME: Remember Me REMEMBER_ME_HELP: "Sets a persistent cookie on your browser to allow persistent-login authentication between sessions." REMEMBER_ME_STOLEN_COOKIE: "Someone else has used your login information to access this page! All sessions were logged out. Please log in with your credentials and check your data." - - OAUTH_LOGIN: Sign in with %s - OAUTH_SIGNIN: Sign in with your username and password - OAUTH_CONNECT_MESSAGE: Connect with a social network - OAUTH_CONNECT_MESSAGE_EXTRA: other social networks - OAUTH_PROVIDER_NOT_SUPPORTED: OAuth provider "%s" is not supported - OR: or - BUILTIN_CSS: Use built in CSS BUILTIN_CSS_HELP: Include the CSS provided by the admin plugin ROUTE: Login path ROUTE_HELP: Custom route to a custom login page that your theme provides ROUTE_REGISTER: Registration path ROUTE_REGISTER_HELP: Route to the registration page. Set this if you want to use the built-in registration page. Leave it empty if you have your own registration form - - OAUTH_SECTION: OAuth - OAUTH_ENABLE: Enable OAuth - OAUTH_USER_AUTOCREATE: Auto-create user account - OAUTH_ACCESS: OAuth user access rights - OAUTH_PROVIDER_SECTION: OAuth providers - OAUTH_PROVIDER_FACEBOOK: Enable Facebook OAuth - OAUTH_PROVIDER_GOOGLE: Enable Google OAuth - OAUTH_PROVIDER_GITHUB: Enable GitHub OAuth - OAUTH_PROVIDER_TWITTER: Enable Twitter OAuth - OAUTH_CLIENT_ID: Client ID - OAUTH_CLIENT_SECRET: Client secret - - FACEBOOK: Facebook - GOOGLE: Google - GITHUB: GitHub - TWITTER: Twitter - USERNAME_NOT_VALID: "Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed" USERNAME_NOT_AVAILABLE: "Username %s already exists, please pick another username" PASSWORD_NOT_VALID: "Password must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" PASSWORDS_DO_NOT_MATCH: "Passwords do not match. Double-check you entered the same password twice" - EMAIL_NOT_CONFIGURED: "Email not configured" USER_NEEDS_EMAIL_FIELD: "The user needs an email field" EMAIL_SENDING_FAILURE: "An error occurred while sending the email" - ACTIVATION_EMAIL_SUBJECT: "Activate your account on %s" - ACTIVATION_EMAIL_BODY: "Hi %s, click %s to activate your account on %s" + ACTIVATION_EMAIL_BODY: "Hi %s, click here to activate your account on %s" WELCOME_EMAIL_SUBJECT: "Welcome to %s" WELCOME_EMAIL_BODY: "Hi %s, welcome to %s!" - NOTIFICATION_EMAIL_SUBJECT: "New user on %s" NOTIFICATION_EMAIL_BODY: "Hi, a new user registered on %s. Username: %s, email: %s" - EMAIL_FOOTER: "GetGrav.org" ACTIVATION_LINK_EXPIRED: "Activation link expired" USER_ACTIVATED_SUCCESSFULLY: "User activated successfully" INVALID_REQUEST: "Invalid request" - USER_REGISTRATION: "User Registration" USER_REGISTRATION_ENABLED_HELP: "Enable the user registration" - VALIDATE_PASSWORD1_AND_PASSWORD2: "Validate double entered password" VALIDATE_PASSWORD1_AND_PASSWORD2_HELP: "Validate and compare two different fields for the passwords, named `password1` and `password2`. Enable this if you have two password fields in the registration form" - SET_USER_DISABLED: "Set the user as disabled" SET_USER_DISABLED_HELP: "Best used along with the `Send activation email` email. Adds the user to Grav, but sets it as disabled" LOGIN_AFTER_REGISTRATION: "Login the user after registration" @@ -86,177 +62,197 @@ en: SEND_NOTIFICATION_EMAIL_HELP: "Notifies the site admin that a new user has registered. The email will be sent to the `To` field in the Email Plugin configuration" SEND_WELCOME_EMAIL: "Send welcome email" SEND_WELCOME_EMAIL_HELP: "Sends an email to the newly registered user" - DEFAULT_VALUES: "Default values" DEFAULT_VALUES_HELP: "List of field names and values associated, that will be added to the user profile (yaml file) by default, without being configurable by the user. Separate multiple values with a comma, with no spaces between the values" ADDITIONAL_PARAM_KEY: "Parameter" ADDITIONAL_PARAM_VALUE: "Value" - REGISTRATION_FIELDS: "Registration fields" REGISTRATION_FIELDS_HELP: "Add the fields that will be added to the user yaml file. Fields not listed here will not be added even if present in the registration form" REGISTRATION_FIELD_KEY: "Field name" - REDIRECT_AFTER_LOGIN: "Redirect after login" REDIRECT_AFTER_LOGIN_HELP: "Custom route to redirect after login" REDIRECT_AFTER_REGISTRATION: "Redirect after registration" REDIRECT_AFTER_REGISTRATION_HELP: "Custom route to redirect after the registration" - OPTIONS: Options EMAIL_VALIDATION_MESSAGE: "Must be a valid email address" PASSWORD_VALIDATION_MESSAGE: "Password must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" + TIMEOUT_HELP: "Sets the session timeout in seconds when Remember Me is enabled and checked by the user. Minimum is 604800 which means 1 week" + GROUPS_HELP: "List of groups the new registered user will be part of, if any" + SITE_ACCESS_HELP: "List of site access levels the new registered user will have. Example: `login` -> `true` " + WELCOME: "Welcome" + REDIRECT_AFTER_ACTIVATION: "Redirect after the user activation" + REDIRECT_AFTER_ACTIVATION_HELP: "Used if the user is required to activate the account via email. Once activated, this route will be shown" + REGISTRATION_DISABLED: "Registration disabled" + USE_PARENT_ACL_LABEL: "Use parent access rules" + USE_PARENT_ACL_HELP: "Check for parent access rules if no rules are defined" + PROTECT_PROTECTED_PAGE_MEDIA_LABEL: "Protect a login-protected page media" + PROTECT_PROTECTED_PAGE_MEDIA_HELP: "If enabled, media of a login protected page is login protected as well and cannot be seen unless logged in" + +de: + PLUGIN_LOGIN: + USERNAME: Benutzername + PASSWORD: Passwort + ACCESS_DENIED: Zugang verweigert + LOGIN_FAILED: Login fehlgeschlagen... + LOGIN_SUCCESSFUL: Du wurdest erfolgreich eingeloggt. + BTN_LOGIN: Anmelden + BTN_LOGOUT: Ausloggen + BTN_FORGOT: Vergessen + BTN_REGISTER: Registrieren + REMEMBER_ME: Angemeldet bleiben + REMEMBER_ME_HELP: "Speichert einen Cookie im Browser, welcher eine fortwährende Anmeldung sicherstellt." + BUILTIN_CSS: "Nutze das integrierte CSS" + BUILTIN_CSS_HELP: "Nutze das CSS, welches vom Admin Plugin bereitgestellt werden" + ROUTE: "Anmeldepfad" + ROUTE_REGISTER: "Registrierungspfad" + USERNAME_NOT_AVAILABLE: "Der Nutzername %s existiert bereits, bitte wähle einen Anderen" + EMAIL_NOT_CONFIGURED: "E-Mail ist nicht konfiguriert" + USER_NEEDS_EMAIL_FIELD: "Der Nutzer benötigt ein E-Mail Feld" + EMAIL_SENDING_FAILURE: "Ein Fehler ist beim senden der E-Mail aufgetreten" + ACTIVATION_EMAIL_SUBJECT: "Aktiviere dein Account auf %s" + ACTIVATION_EMAIL_BODY: "Hi %s, click %s to activate your account on %s" + WELCOME_EMAIL_SUBJECT: "Willkommen zu %s" + WELCOME_EMAIL_BODY: "Hi %s, willkommen zu %s!" + NOTIFICATION_EMAIL_SUBJECT: "Neuer Nutzer auf %s" + NOTIFICATION_EMAIL_BODY: "Hi, ein neuer Nutzer hat sich auf %s registriert. Nutzername: %s, E-Mail: %s" + EMAIL_FOOTER: "GetGrav.org" + ACTIVATION_LINK_EXPIRED: "Aktivierungslink ist abgelaufen" + USER_ACTIVATED_SUCCESSFULLY: "Nutzer erfolgreich aktiviert" + INVALID_REQUEST: "Ungültige Anfrage" + USER_REGISTRATION: "Nutzer Registrierung" + USER_REGISTRATION_ENABLED_HELP: "Aktiviere die Nutzer Registrierung" + VALIDATE_PASSWORD1_AND_PASSWORD2: "Überprüfe das doppelt eingegebene Passwort" + SEND_ACTIVATION_EMAIL: "Aktivierungs E-Mail senden" + SEND_NOTIFICATION_EMAIL: "Benachtichtigungs E-Mail senden" + SEND_WELCOME_EMAIL: "Sende eine Willkommens E-Mail" + DEFAULT_VALUES: "Standard Werte" + ADDITIONAL_PARAM_KEY: "Parameter" + ADDITIONAL_PARAM_VALUE: "Wert" + REGISTRATION_FIELDS: "Registrierungsfelder" + REGISTRATION_FIELD_KEY: "Feldname" + REDIRECT_AFTER_LOGIN: "Umleitung nach Login" + REDIRECT_AFTER_REGISTRATION: "Umleitung nach Registrierung" + OPTIONS: Optionen + EMAIL_VALIDATION_MESSAGE: "Muss eine gültige E-Mail Adresse sein" fr: PLUGIN_LOGIN: - USERNAME: "Nom d'utilisateur" + USERNAME: "Nom d’utilisateur" PASSWORD: "Mot de passe" - ACCESS_DENIED: Accès refusé... - LOGIN_FAILED: Échec de la connexion... - LOGIN_SUCCESSFUL: Vous vous êtes connecté avec succès. - - BTN_LOGIN: Connexion - BTN_LOGOUT: Déconnexion - BTN_FORGOT: Mot de passe oublié - BTN_REGISTER: S'enregister - - SESSION: "“Se souvenir de moi” - Session" - REMEMBER_ME: Se souvenir de moi - REMEMBER_ME_HELP: "Définit un cookie sur votre navigateur pour permettant l'authentification par connexion persistante entre les sessions." - REMEMBER_ME_STOLEN_COOKIE: "Quelqu'un d'autre a utilisé vos informations de connexion pour accéder à cette page ! Toutes les sessions ont été déconnectées. Veuillez vous connecter avec vos identifiants et vérifier vos données." - - OAUTH_LOGIN: Se connecter avec %s - OAUTH_SIGNIN: Se connecter avec votre identifiant et mot de passe - OAUTH_CONNECT_MESSAGE: Se connecter avec un réseau social - OAUTH_CONNECT_MESSAGE_EXTRA: d'autres réseaux sociaux - OAUTH_PROVIDER_NOT_SUPPORTED: Le fournisseur OAuth "%s" n'est pas pris en charge - OR: ou - - BUILTIN_CSS: Utiliser les CSS intégrés - BUILTIN_CSS_HELP: Utiliser les CSS fournis dans le plugin d'administration - ROUTE: Chemin de connexion - ROUTE_HELP: Chemin personnalisé vers une page de connexion personnalisée proposée par votre thème - ROUTE_REGISTER: "Chemin vers l'inscription" - ROUTE_REGISTER_HELP: "Chemin vers la page d'inscription. A définir si vous souhaitez utiliser la page d'inscription intégrée. Laisser vide si vous disposez de votre propre formulaire d'inscription." - - OAUTH_SECTION: OAuth - OAUTH_ENABLE: Activer OAuth - OAUTH_USER_AUTOCREATE: Création automatique d'un compte utilisateur - OAUTH_ACCESS: Droits d'accès OAuth de l'utilisateur - OAUTH_PROVIDER_SECTION: Fournisseurs OAuth - OAUTH_PROVIDER_FACEBOOK: OAuth Facebook activé - OAUTH_PROVIDER_GOOGLE: OAuth Google activé - OAUTH_PROVIDER_GITHUB: OAuth GitHub activé - OAUTH_PROVIDER_TWITTER: OAuth Twitter activé - OAUTH_CLIENT_ID: ID Client - OAUTH_CLIENT_SECRET: Secret client - - FACEBOOK: Facebook - GOOGLE: Google - GITHUB: GitHub - TWITTER: Twitter - - USERNAME_NOT_VALID: "Le nom d'utilisateur doit comporter entre 3 et 16 caractères et peut être composé de lettres minuscules, de chiffres et de tirets de soulignement (underscores) et des traits d'union. Les lettres majuscules, les espaces et les caractères spéciaux ne sont pas autorisés." - USERNAME_NOT_AVAILABLE: "Le nom d'utilisateur %s existe déjà, veuillez en choisir un autre." - PASSWORD_NOT_VALID: "Le mot de passe doit-être composé d'au moins un chiffre, une majuscule et une minuscule, et au moins 8 caractères" + ACCESS_DENIED: "Accès refusé..." + LOGIN_FAILED: "Échec de la connexion..." + LOGIN_SUCCESSFUL: "Vous vous êtes connecté avec succès." + BTN_LOGIN: "Connexion" + BTN_LOGOUT: "Déconnexion" + BTN_FORGOT: "Mot de passe oublié" + BTN_REGISTER: "S’enregister" + BTN_RESET: "Réinitialiser le mot de passe" + BTN_SEND_INSTRUCTIONS: "Envoyer les instructions de Réinitialisation" + RESET_LINK_EXPIRED: "Le lien de réinitialisation a expiré, veuillez réessayer" + RESET_PASSWORD_RESET: "Le mot de passe a été réinitialisé" + RESET_INVALID_LINK: "Le lien de réinitialisation utilisé n’est pas valide, veuillez réessayer" + FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL: "Les instructions pour la réinitialisation de votre mot de passe ont été envoyées par e-mail à %s" + FORGOT_FAILED_TO_EMAIL: "Impossible d’envoyer les instructions, veuillez réessayer ultérieurement" + FORGOT_CANNOT_RESET_EMAIL_NO_EMAIL: "Impossible de réinitialiser le mot de passe pour %s, aucune adresse e-mail n’a été paramétrée" + FORGOT_USERNAME_DOES_NOT_EXIST: "L’utilisateur avec le nom d’utilisateur %s n’existe pas" + FORGOT_EMAIL_NOT_CONFIGURED: "Impossible de réinitialiser le mot de passe. Ce site n’est pas configuré pour envoyer des e-mails" + FORGOT_EMAIL_SUBJECT: "Demande de réinitialisation de mot de passe %s" + FORGOT_EMAIL_BODY: "

Réinitialisation de mot de passe

%1$s,

Une demande a été faite sur %4$s pour la réinitialisation de votre mot de passe.


Cliquez ici pour réinitialiser votre mot de passe

Vous pouvez également copier l’URL suivante dans la barre d’adresse de votre navigateur :

%2$s


Cordialement,

%3$s

" + SESSION: "Session - “Se souvenir de moi”" + REMEMBER_ME: "Se souvenir de moi" + REMEMBER_ME_HELP: "Définit un cookie persistant sur votre navigateur autorisant l’authentification par connexion persistante entre les sessions." + REMEMBER_ME_STOLEN_COOKIE: "Quelqu’un d’autre a utilisé vos informations de connexion pour accéder à cette page ! Toutes les sessions ont été déconnectées. Veuillez vous connecter avec vos identifiants et vérifier vos données." + BUILTIN_CSS: "Utiliser les CSS intégrés" + BUILTIN_CSS_HELP: "Utiliser les CSS fournis dans le plugin d’administration" + ROUTE: "Chemin de connexion" + ROUTE_HELP: "Chemin personnalisé vers une page de connexion personnalisée proposée par votre thème" + ROUTE_REGISTER: "Chemin vers l’inscription" + ROUTE_REGISTER_HELP: "Chemin vers la page d’inscription. A définir si vous souhaitez utiliser la page d’inscription intégrée. Laisser vide si vous disposez de votre propre formulaire d’inscription." + USERNAME_NOT_VALID: "Le nom d’utilisateur doit comporter entre 3 et 16 caractères et peut être composé de lettres minuscules, de chiffres et de tirets de soulignement (underscores) et des traits d’union. Les lettres majuscules, les espaces et les caractères spéciaux ne sont pas autorisés." + USERNAME_NOT_AVAILABLE: "Le nom d’utilisateur %s existe déjà, veuillez en choisir un autre." + PASSWORD_NOT_VALID: "Le mot de passe doit contenir au moins un chiffre, une majuscule et une minuscule et être composé d’au moins 8 caractères" PASSWORDS_DO_NOT_MATCH: "Les mots de passe sont différents. Réessayez de saisir le même mot de passe deux fois." - - EMAIL_NOT_CONFIGURED: "L'e-mail n'est pas configuré" - USER_NEEDS_EMAIL_FIELD: "L'utilisateur a besoin d'un champ pour e-mail" - EMAIL_SENDING_FAILURE: "Une erreur est survenue lors de l'envoi de l'e-mail." - + EMAIL_NOT_CONFIGURED: "L’e-mail n’est pas configuré" + USER_NEEDS_EMAIL_FIELD: "L’utilisateur a besoin d’un champ pour e-mail" + EMAIL_SENDING_FAILURE: "Une erreur est survenue lors de l’envoi de l’e-mail." ACTIVATION_EMAIL_SUBJECT: "Activer votre compte sur %s" - ACTIVATION_EMAIL_BODY: "Bonjour %s, cliquez sur %s pour activer votre compte sur %s" + ACTIVATION_EMAIL_BODY: "Bonjour %s, cliquez pour activer votre compte sur %s" WELCOME_EMAIL_SUBJECT: "Bienvenue sur %s" WELCOME_EMAIL_BODY: "Bonjour %s, bienvenue sur %s!" - NOTIFICATION_EMAIL_SUBJECT: "Nouvel utilisateur sur %s" - NOTIFICATION_EMAIL_BODY: "Bonjour, un nouvel utilisateur s'est inscrit sur %s. Nom d'utilisateur : %s, e-mail : %s" - + NOTIFICATION_EMAIL_BODY: "Bonjour, un nouvel utilisateur s’est inscrit sur %s. Nom d’utilisateur : %s, e-mail : %s" EMAIL_FOOTER: "GetGrav.org" - ACTIVATION_LINK_EXPIRED: "Le lien d'activation a expiré" + ACTIVATION_LINK_EXPIRED: "Le lien d’activation a expiré" USER_ACTIVATED_SUCCESSFULLY: "Utilisateur activé avec succès" INVALID_REQUEST: "Requête invalide" - - USER_REGISTRATION: "Inscription de l'utilisateur" - USER_REGISTRATION_ENABLED_HELP: "Activer l'inscription des utilisateurs" - - VALIDATE_PASSWORD1_AND_PASSWORD2: "Validate double entered password" - VALIDATE_PASSWORD1_AND_PASSWORD2_HELP: "Validate and compare two different fields for the passwords, named `password1` and `password2`. Enable this if you have two password fields in the registration form" - - SET_USER_DISABLED: "Définir l'utilisateur comme désactivé" - SET_USER_DISABLED_HELP: "Best used along with the `Send activation email` email. Adds the user to Grav, but sets it as disabled" - LOGIN_AFTER_REGISTRATION: "Connecte l'utilisateur après son inscription" - LOGIN_AFTER_REGISTRATION_HELP: "Identifier immédiatement l'utilisateur après l'inscription. Si l'email d'activation est demandé, l'utilisateur sera connecté immédiatement après l'activation du compte" - SEND_ACTIVATION_EMAIL: "Envoyer un e-mail d'activation" - SEND_ACTIVATION_EMAIL_HELP: "Sends an email to the user to activate his account. Enable the `Set the user as disabled` option when using this feature, so the user will be set as disabled and an email will be sent to activate the account" + USER_REGISTRATION: "Inscription de l’utilisateur" + USER_REGISTRATION_ENABLED_HELP: "Activer l’inscription des utilisateurs" + VALIDATE_PASSWORD1_AND_PASSWORD2: "Valider la double saisie du mot de passe" + VALIDATE_PASSWORD1_AND_PASSWORD2_HELP: "Comparer et valider deux champs pour les mots de passe `Mot de passe 1` et `Mot de passe 2`. Activez cette option si vous avez deux champs de mots de passe dans le formulaire d’inscription." + SET_USER_DISABLED: "Définir l’utilisateur comme désactivé" + SET_USER_DISABLED_HELP: "La meilleure pratique si vous utilisez l’option `Envoyer un e-mail d’activation`. Ajoute l’utilisateur à Grav, mais le défini comme étant désactivé." + LOGIN_AFTER_REGISTRATION: "Connecte l’utilisateur après son inscription" + LOGIN_AFTER_REGISTRATION_HELP: "Identifier immédiatement l’utilisateur après l’inscription. Si l’e-mail d’activation est demandé, l’utilisateur sera connecté immédiatement après l’activation du compte." + SEND_ACTIVATION_EMAIL: "Envoyer un e-mail d’activation" + SEND_ACTIVATION_EMAIL_HELP: "Envoyer un e-mail à l’utilisateur pour l’activation son compte. Lorsque vous utilisez cette fonction, activez l’option `Définir l’utilisateur comme désactivé` afin que l’utilisateur soit désactivé et qu’un e-mail lui soit envoyé pour activer son compte." SEND_NOTIFICATION_EMAIL: "Envoyer un e-mail de notification" - SEND_NOTIFICATION_EMAIL_HELP: "Notifies the site admin that a new user has registered. The email will be sent to the `To` field in the Email Plugin configuration" + SEND_NOTIFICATION_EMAIL_HELP: "Informe l’administrateur du site qu’un nouvel utilisateur s’est enregistré. L’e-mail sera envoyé à la personne renseignée dans le champ `À` dans la configuration du plugin e-mail." SEND_WELCOME_EMAIL: "Envoyer un e-mail de bienvenue" SEND_WELCOME_EMAIL_HELP: "Envoyer un e-mail à un nouvel utilisateur enregistré." - DEFAULT_VALUES: "Valeurs par défaut" - DEFAULT_VALUES_HELP: "Liste des noms et valeurs associés pour les champs. Ils seront ajoutés au profil utilisateur par défaut (fichier yaml), sans pouvoir être configurables par l'utilisateur. Séparez les différentes valeurs par une virgule, sans espaces entre les valeurs." + DEFAULT_VALUES_HELP: "Liste des noms et valeurs associés pour les champs. Ils seront ajoutés au profil utilisateur par défaut (fichier yaml), sans pouvoir être configurables par l’utilisateur. Séparez les différentes valeurs par une virgule, sans espaces entre les valeurs." ADDITIONAL_PARAM_KEY: "Paramètre" ADDITIONAL_PARAM_VALUE: "Valeur" - - REGISTRATION_FIELDS: "Champs d'inscription" - REGISTRATION_FIELDS_HELP: "Ajouter les champs qui seront ajoutés au fichier yaml de l'utilisateur. Les champs non listés ne seront pas ajoutés même s'ils sont présent sur le formulaire d'inscription" + REGISTRATION_FIELDS: "Champs d’inscription" + REGISTRATION_FIELDS_HELP: "Ajouter les champs qui seront ajoutés au fichier yaml de l’utilisateur. Les champs non listés ne seront pas ajoutés même s’ils sont présent sur le formulaire d’inscription" REGISTRATION_FIELD_KEY: "Nom du champ" - REDIRECT_AFTER_LOGIN: "Redirection après connexion" REDIRECT_AFTER_LOGIN_HELP: "Chemin personnalisé de redirection après la connexion" REDIRECT_AFTER_REGISTRATION: "Redirection après inscription" - REDIRECT_AFTER_REGISTRATION_HELP: "Chemin personnalisé de redirection après l'inscription" - - OPTIONS: Options + REDIRECT_AFTER_REGISTRATION_HELP: "Chemin personnalisé de redirection après l’inscription" + OPTIONS: "Options" EMAIL_VALIDATION_MESSAGE: "Doit-être une adresse e-mail valide" - PASSWORD_VALIDATION_MESSAGE: "Le mot de passe doit-être composé d'au moins un chiffre, une majuscule et une minuscule, et au moins 8 caractères" - + PASSWORD_VALIDATION_MESSAGE: "Le mot de passe doit-être composé d’au moins un chiffre, une majuscule et une minuscule, et au moins 8 caractères" + TIMEOUT_HELP: "Définit le délai d’expiration de la session en secondes lorsque `Se souvenir de moi` est activé et coché par l’utilisateur. Minimum de 604800 ce qui correspond à 1 semaine." + GROUPS_HELP: "Liste des groupes auxquels le nouvel utilisateur enregistré fera partie, le cas échéant." + SITE_ACCESS_HELP: "Liste des niveaux d’accès au site attribués au nouvel utilisateur enregistré. Exemple : `login` -> `true` " + WELCOME: "Bienvenue" + REDIRECT_AFTER_ACTIVATION: "Redirection après l’activation de l’utilisateur" + REDIRECT_AFTER_ACTIVATION_HELP: "Utilisé s’il est nécessaire pour l’utilisateur d’activer le compte par e-mail. Une fois activé, ce chemin s’affichera" + REGISTRATION_DISABLED: "Inscription désactivée" + USE_PARENT_ACL_LABEL: "Appliquer les règles d’accès parentes" + USE_PARENT_ACL_HELP: "Utiliser les règles d’accès parentes si aucune règle n’a été définie" + PROTECT_PROTECTED_PAGE_MEDIA_LABEL: "Protéger le média d'une page par une protection par connexion" + PROTECT_PROTECTED_PAGE_MEDIA_HELP: "Si activé, les médias d'une page protégée par connexion sera également protégé par un système de connexion et ne pourra pas être visible à moins d'être connecté." + hr: PLUGIN_LOGIN: ACCESS_DENIED: Pristup odbijen... LOGIN_FAILED: Prijava nije uspjela... - BTN_LOGIN: Prijava BTN_LOGOUT: Odjava BTN_FORGOT: Zaboravih BTN_REGISTER: Registriraj - REMEMBER_ME: Zapamti me - - OAUTH_LOGIN: Prijavi se sa %s - OAUTH_SIGNIN: Prijavi se sa svojim korisničkim imenom i lozinkom - OAUTH_CONNECT_MESSAGE: Poveži se preko socijalnih mreža - OAUTH_CONNECT_MESSAGE_EXTRA: druge socijalne mreže - OAUTH_PROVIDER_NOT_SUPPORTED: OAuth provider "%s" nije podržan - OR: ili - BUILTIN_CSS: Koristi ugrađeni CSS BUILTIN_CSS_HELP: Uključi CSS koji dolazi sa admin pluginom ROUTE: Putanja prijave - ROUTE_REGISTER: Putanja registracije - - USERNAME_NOT_VALID: "Korisničko ime bi trebalo biti između 3 i 16 znakova, uključujući mala slova, brojeve, _, i crtice. VELIKA SLOVA, razmaci, i posebni znakovi nisu dopušteni" USERNAME_NOT_AVAILABLE: "Korisničko ime %s već postoji, odaberi neko drugo" PASSWORD_NOT_VALID: "Lozinka mora sadržavati bar jedan broj i jedno veliko i malo slovo, i bar još 8 ili više znakova" PASSWORDS_DO_NOT_MATCH: "Lozinke se ne slažu. Poonovo provjeri da li si unio istu lozinku dva puta" - EMAIL_NOT_CONFIGURED: "Email nije konfiguriran" USER_NEEDS_EMAIL_FIELD: "Korisnik treba email polje" EMAIL_SENDING_FAILURE: "Došlo je do greške pri slanju emaila" - EMAIL_FOOTER: "GetGrav.org" ACTIVATION_LINK_EXPIRED: "Aktivacijski link je istekao" USER_ACTIVATED_SUCCESSFULLY: "Korisnik je uspješno aktiviran" INVALID_REQUEST: "Nevaljani zahtjev" - USER_REGISTRATION: "Registracija korisnika" USER_REGISTRATION_ENABLED_HELP: "Omogući registraciju korisnika" - VALIDATE_PASSWORD1_AND_PASSWORD2: "Validiraj duplo unesenu lozinku" VALIDATE_PASSWORD1_AND_PASSWORD2_HELP: "Validiraj i usporedi dva različčita polja za lozinke, imenovana `lozinka1` i `lozinka2`. Omogući ovo ako imaš dva polja za lozinke u formularu registracije" - LOGIN_AFTER_REGISTRATION: "Ulogiraj korisnika nakon reegistracije" LOGIN_AFTER_REGISTRATION_HELP: "Ulogiraj korisnika odmah nakon registracije. Ako je potrebna email aktivacija, korisnik će biti ulogiran odmah nakon aktiviranja računa" SEND_ACTIVATION_EMAIL: "Pošalji aktivacijski email" @@ -265,16 +261,13 @@ hr: SEND_NOTIFICATION_EMAIL_HELP: "Obavještava administratora da se novi korisnik registrirao. Email će biti poslan na `To` polje u Email Plugin konfiguraciji" SEND_WELCOME_EMAIL: "Pošalji email dobrodošlice" SEND_WELCOME_EMAIL_HELP: "Šalje email novoregistriranom korisniku" - DEFAULT_VALUES: "Određene vrijednosti" DEFAULT_VALUES_HELP: "List of field names and values associated, that will be added to the user profile (yaml file) by default, without being configurable by the user. Separate multiple values with a comma, with no spaces between the values" ADDITIONAL_PARAM_KEY: "Parametar" ADDITIONAL_PARAM_VALUE: "Vrijednost" - REGISTRATION_FIELDS: "Registracijska polja" REGISTRATION_FIELDS_HELP: "Add the fields that will be added to the user yaml file. Fields not listed here will not be added even if present in the registration form" REGISTRATION_FIELD_KEY: "Ime polja" - OPTIONS: Opcije hu: @@ -286,43 +279,15 @@ hu: BTN_LOGOUT: Kilépés BTN_FORGOT: Elfelejtettem BTN_REGISTER: Regisztráció - SESSION: "Munkamenet Megjegyzése" - REMEMBER_ME: Jegyezz Meg REMEMBER_ME_HELP: "Elhelyezünk egy hosszú lejáratú sütit a böngésződben, hogy belépve maradhass két munkamenet között." REMEMBER_ME_STOLEN_COOKIE: "Valaki a belépési adataid felhasználásával látogatta meg ezt az oldalt! Minden munkamenetet kiléptettünk. Kérlek, jelentkezz be ismét és ellenőrizd az adataidat." - - OAUTH_LOGIN: Belépés %s használatával - OAUTH_SIGNIN: Belépés felhasználóneved és jelszavad megadásával - OAUTH_CONNECT_MESSAGE: Összekapcsolás egy közösségi oldallal - OAUTH_CONNECT_MESSAGE_EXTRA: más közösségi oldalak - OAUTH_PROVIDER_NOT_SUPPORTED: A(z) "%s" OAuth szolgáltató nem használható - OR: vagy - BUILTIN_CSS: Beépített CSS használata BUILTIN_CSS_HELP: Az admin plugin által biztosított CSS beillesztése ROUTE: Belépés útvonala ROUTE_HELP: Egyedi útvonal egy egyedi belépő oldalhoz, melyet az aktuális téma biztosít ROUTE_REGISTER: Regisztráció útvonala ROUTE_REGISTER_HELP: A regisztrációs oldal elérési útja. Akkor állítsd be, ha a beépített regisztrációs oldalt szeretnéd használni - - OAUTH_SECTION: OAuth - OAUTH_ENABLE: OAuth engedélyezése - OAUTH_USER_AUTOCREATE: Felhasználói fiók automatikus létrehozása - OAUTH_ACCESS: OAuth felhasználók jogai - OAUTH_PROVIDER_SECTION: OAuth szolgáltatók - OAUTH_PROVIDER_FACEBOOK: Facebook OAuth Enegdélyezése - OAUTH_PROVIDER_GOOGLE: Google OAuth Engedélyezése - OAUTH_PROVIDER_GITHUB: GitHub OAuth Engedélyezése - OAUTH_PROVIDER_TWITTER: Twitter OAuth Engeédlyezése - OAUTH_CLIENT_ID: Client ID - OAUTH_CLIENT_SECRET: Client secret - - FACEBOOK: Facebook - GOOGLE: Google - GITHUB: GitHub - TWITTER: Twitter - USERNAME_NOT_VALID: "A felhasználónév 3-16 karakter hosszú legyen, tartalmazhat kisbetűket, számokat, aláhúzást és kötőjelet. Nagybetűk, szóköz és speciális karakterek használata nem megengedett" USERNAME_NOT_AVAILABLE: "%s nevű felhasználó már létezik, kérlek válassz más felhasználónevet" PASSWORD_NOT_VALID: "A jelszónak tartalmaznia kell legalább egy számot, egy kisbetűt és egy nagybetűt, valamint legalább 8 karakter hosszú kell, hogy legyen" diff --git a/login.php b/login.php old mode 100644 new mode 100755 index bd44b5e..1a9a673 --- a/login.php +++ b/login.php @@ -2,43 +2,45 @@ namespace Grav\Plugin; use Grav\Plugin\Admin; -use Grav\Common\File\CompiledYamlFile; -use Grav\Common\Plugin; +use Grav\Common\Grav; +use Grav\Common\Language\Language; use Grav\Common\Page\Page; +use Grav\Common\Page\Pages; +use Grav\Common\Plugin; +use Grav\Common\Twig\Twig; use Grav\Common\User\User; use Grav\Common\Utils; -use Grav\Plugin\Login\Utils as LoginUtils; - +use Grav\Common\Uri; +use Grav\Plugin\Login\Login; +use Grav\Plugin\Login\Controller; +use Grav\Plugin\Form; use RocketTheme\Toolbox\Event\Event; use RocketTheme\Toolbox\Session\Message; +/** + * Class LoginPlugin + * @package Grav\Plugin + */ class LoginPlugin extends Plugin { - /** - * @var string - */ + /** @var string */ protected $route; - /** - * @var string - */ + /** @var string */ protected $route_register; - /** - * @var string - */ + /** @var string */ protected $route_forgot; - /** - * @var bool - */ + /** @var bool */ protected $authenticated = true; - /** - * @var bool - */ + /** @var bool */ protected $authorized = true; + /** @var Login */ + protected $login; + /** * @return array */ @@ -46,14 +48,15 @@ public static function getSubscribedEvents() { return [ 'onPluginsInitialized' => ['initialize', 10000], - 'onTask.login.login' => ['loginController', 0], - 'onTask.login.forgot' => ['loginController', 0], - 'onTask.login.logout' => ['loginController', 0], - 'onTask.login.reset' => ['loginController', 0], - 'onPageInitialized' => ['authorizePage', 0], - 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], - 'onTwigSiteVariables' => ['onTwigSiteVariables', -100000], - 'onFormProcessed' => ['onFormProcessed', 0] + 'onTask.login.login' => ['loginController', 0], + 'onTask.login.forgot' => ['loginController', 0], + 'onTask.login.logout' => ['loginController', 0], + 'onTask.login.reset' => ['loginController', 0], + 'onPageInitialized' => ['authorizePage', 0], + 'onPageFallBackUrl' => ['authorizeFallBackUrl', 0], + 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], + 'onTwigSiteVariables' => ['onTwigSiteVariables', -100000], + 'onFormProcessed' => ['onFormProcessed', 0] ]; } @@ -70,9 +73,6 @@ public function initialize() throw new \RuntimeException('The Login plugin requires "system.session" to be enabled'); } - /** @var Grav\Common\Session */ - $session = $this->grav['session']; - // Autoload classes $autoload = __DIR__ . '/vendor/autoload.php'; if (!is_file($autoload)) { @@ -93,13 +93,15 @@ public function initialize() // Define current user service. $this->grav['user'] = function ($c) { + /** @var Grav $c */ + $session = $c['session']; if (!isset($session->user)) { $session->user = new User; if ($c['config']->get('plugins.login.rememberme.enabled')) { - $controller = new Login\Controller($c, ''); + $controller = new Controller($c, ''); $rememberMe = $controller->rememberMe(); // If we can present the correct tokens from the cookie, we are logged in @@ -127,14 +129,11 @@ public function initialize() return $session->user; }; - // Manage OAuth login - $task = !empty($_POST['task']) ? $_POST['task'] : $uri->param('task'); - if (!$task && isset($_POST['oauth']) || (!empty($_GET) && $session->oauth)) { - $this->oauthController(); - } + //Initialize Login Object + $this->login = new Login($this->grav); - // Aborted OAuth authentication (invalidate it) - unset($session->oauth); + //Store Login Object in Grav + $this->grav['login'] = $this->login; $admin_route = $this->config->get('plugins.admin.route'); @@ -162,9 +161,14 @@ public function initialize() } if ($uri->path() == $this->config->get('plugins.login.route_register')) { - $this->enable([ - 'onPagesInitialized' => ['addRegisterPage', 0], - ]); + if ($this->config->get('plugins.login.user_registration.enabled')) { + $this->enable([ + 'onPagesInitialized' => ['addRegisterPage', 0], + ]); + } else { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.REGISTRATION_DISABLED'), 404); + } + } if ($uri->path() == $this->config->get('plugins.login.route_activate')) { @@ -204,7 +208,7 @@ public function addForgotPage() $page = $pages->dispatch($route); if (!$page) { - // Only add login page if it hasn't already been defined. + // Only add forgot page if it hasn't already been defined. $page = new Page; $page->init(new \SplFileInfo(__DIR__ . "/pages/forgot.md")); $page->slug(basename($route)); @@ -278,6 +282,7 @@ public function handleUserActivation() $message = $this->grav['language']->translate('PLUGIN_LOGIN.INVALID_REQUEST'); $messages->add($message, 'error'); $this->grav->redirect('/'); + return; } @@ -301,10 +306,10 @@ public function handleUserActivation() $messages->add($message, 'info'); if ($this->config->get('plugins.login.user_registration.options.send_welcome_email', false)) { - $this->sendWelcomeEmail($user); + $this->login->sendWelcomeEmail($user); } if ($this->config->get('plugins.login.user_registration.options.send_notification_email', false)) { - $this->sendNotificationEmail($user); + $this->login->sendNotificationEmail($user); } if ($this->config->get('plugins.login.user_registration.options.login_after_registration', false)) { @@ -318,11 +323,11 @@ public function handleUserActivation() } else { $message = $this->grav['language']->translate('PLUGIN_LOGIN.INVALID_REQUEST'); $messages->add($message, 'error'); - } } - $this->grav->redirect('/'); + $redirect_route = $this->config->get('plugins.login.user_registration.redirect_after_activation', '/'); + $this->grav->redirect($redirect_route); } /** @@ -337,51 +342,58 @@ public function loginController() $post = !empty($_POST) ? $_POST : []; if (method_exists('Grav\Common\Utils', 'getNonce')) { - if ($task == 'login') { - if (!isset($post['login-form-nonce']) || !Utils::verifyNonce($post['login-form-nonce'], 'login-form')) { - $this->grav['messages']->add($this->grav['language']->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'info'); - $this->authenticated = false; - $twig = $this->grav['twig']; - $twig->twig_vars['notAuthorized'] = true; - return; - } - } else if ($task == 'logout') { - $nonce = $this->grav['uri']->param('logout-nonce'); - if (!isset($nonce) || !Utils::verifyNonce($nonce, 'logout-form')) { - return; - } - } else if ($task == 'forgot') { - if (!isset($post['forgot-form-nonce']) || !Utils::verifyNonce($post['forgot-form-nonce'], 'forgot-form')) { - $this->grav['messages']->add($this->grav['language']->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'info'); - return; - } - } else if ($task == 'reset') { - if (!isset($post['reset-form-nonce']) || !Utils::verifyNonce($post['reset-form-nonce'], 'reset-form')) { - //$this->grav['messages']->add($this->grav['language']->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'info'); - //return; - } + switch ($task) { + case 'login': + if (!isset($post['login-form-nonce']) || !Utils::verifyNonce($post['login-form-nonce'], 'login-form')) { + $this->grav['messages']->add($this->grav['language']->translate('PLUGIN_LOGIN.ACCESS_DENIED'), + 'info'); + $this->authenticated = false; + $twig = $this->grav['twig']; + $twig->twig_vars['notAuthorized'] = true; + + return; + } + break; + + case 'logout': + $nonce = $this->grav['uri']->param('logout-nonce'); + if (!isset($nonce) || !Utils::verifyNonce($nonce, 'logout-form')) { + return; + } + break; + + case 'forgot': + if (!isset($post['forgot-form-nonce']) || !Utils::verifyNonce($post['forgot-form-nonce'], 'forgot-form')) { + $this->grav['messages']->add($this->grav['language']->translate('PLUGIN_LOGIN.ACCESS_DENIED'),'info'); + return; + } + break; + + case 'reset': + if(!isset($post['reset-form-nonce']) || !Utils::verifyNonce($post['reset-form-nonce'], 'reset-form')) { + //$this->grav['messages']->add($this->grav['language']->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'info'); + //return; + } + break; } } - $controller = new Login\LoginController($this->grav, $task, $post); + $controller = new Controller($this->grav, $task, $post); $controller->execute(); $controller->redirect(); } /** - * Initialize OAuth login controller + * Authorize the Page fallback url (page media accessed through the page route) */ - public function oauthController() + public function authorizeFallBackUrl() { - /** @var Uri $uri */ - $uri = $this->grav['uri']; - $oauth = !empty($_POST['oauth']) ? $_POST['oauth'] : $uri->param('oauth'); - $oauth = $oauth ?: $this->grav['session']->oauth; - $post = !empty($_POST) ? $_POST : []; - - $controller = new Login\OAuthLoginController($this->grav, $oauth, $post); - $controller->execute(); - $controller->redirect(); + if ($this->config->get('plugins.login.protect_protected_page_media', false)) { + $page_url = dirname($this->grav['uri']->path()); + $page = $this->grav['pages']->find($page_url); + $this->grav['page'] = $page; + $this->authorizePage(); + } } /** @@ -391,6 +403,9 @@ public function authorizePage() { /** @var User $user */ $user = $this->grav['user']; + if (!$user->get('access')) { + $user = User::load($user->get('username')); + } /** @var Page $page */ $page = $this->grav['page']; @@ -400,20 +415,20 @@ public function authorizePage() } $header = $page->header(); - $rules = isset($header->access) ? (array) $header->access : []; + $rules = isset($header->access) ? (array)$header->access : []; $config = $this->mergeConfig($page); if ($config->get('parent_acl')) { - // If page has no ACL rules, use its parent's rules - if (!$rules) { - $parent = $page->parent(); - while (!$rules and $parent) { - $header = $parent->header(); - $rules = isset($header->access) ? (array) $header->access : []; - $parent = $parent->parent(); + // If page has no ACL rules, use its parent's rules + if (!$rules) { + $parent = $page->parent(); + while (!$rules and $parent) { + $header = $parent->header(); + $rules = isset($header->access) ? (array)$header->access : []; + $parent = $parent->parent(); + } } - } } // Continue to the page if it has no ACL rules. @@ -440,6 +455,8 @@ public function authorizePage() if (!$user->authenticated) { $page = new Page; + $this->grav['session']->redirect_after_login = $this->grav['uri']->path(); + // Get the admin Login page is needed, else teh default if ($this->isAdmin()) { $login_file = $this->grav['locator']->findResource("plugins://admin/pages/admin/login.md"); @@ -454,7 +471,7 @@ public function authorizePage() unset($this->grav['page']); $this->grav['page'] = $page; } else { - $this->grav['messages']->add($l->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'info'); + $this->grav['messages']->add($l->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'error'); $this->authenticated = false; $twig = $this->grav['twig']; @@ -480,8 +497,7 @@ public function onTwigSiteVariables() /** @var Twig $twig */ $twig = $this->grav['twig']; - /** @var User $user */ - $user = $this->grav['user']; + $this->grav->fireEvent('onLoginPage'); $extension = $this->grav['uri']->extension(); $extension = $extension ?: 'html'; @@ -490,19 +506,6 @@ public function onTwigSiteVariables() $twig->template = "login." . $extension . ".twig"; } - if (!$this->authenticated || !$user->authenticated) { - $providers = []; - foreach ($this->config->get('plugins.login.oauth.providers') as $provider => $options) { - if ($options['enabled'] && isset($options['credentials'])) { - $providers[$provider] = $options['credentials']; - } - } - $twig->twig_vars['oauth'] = [ - 'enabled' => $this->config->get('plugins.login.oauth.enabled'), - 'providers' => $providers - ]; - } - // add CSS for frontend if required if (!$this->isAdmin() && $this->config->get('plugins.login.built_in_css')) { $this->grav['assets']->add('plugin://login/css/login.css'); @@ -523,211 +526,121 @@ public function onTwigSiteVariables() } /** - * Process a registration form. Handles the following actions: + * Process the user registration, triggered by a registration form * - * - register_user: registers a user - * - * @param Event $event + * @param Form $form */ - public function onFormProcessed(Event $event) + private function processUserRegistration($form, Event $event) { - $form = $event['form']; - $action = $event['action']; - $params = $event['params']; - - switch ($action) { - - case 'register_user': - - if (!$this->config->get('plugins.login.enabled')) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.PLUGIN_LOGIN_DISABLED')); - } - - if (!$this->config->get('plugins.login.user_registration.enabled')) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_REGISTRATION_DISABLED')); - } - - $data = []; - $username = $form->value('username'); - - if (file_exists($this->grav['locator']->findResource('user://accounts/' . $username . YAML_EXT))) { - $this->grav->fireEvent('onFormValidationError', - new Event([ - 'form' => $form, - 'message' => $this->grav['language']->translate(['PLUGIN_LOGIN.USERNAME_NOT_AVAILABLE', $username]) - ])); - $event->stopPropagation(); - return; - } - - if ($this->config->get('plugins.login.user_registration.options.validate_password1_and_password2', false)) { - if ($form->value('password1') != $form->value('password2')) { - $this->grav->fireEvent('onFormValidationError', - new Event([ - 'form' => $form, - 'message' => $this->grav['language']->translate('PLUGIN_LOGIN.PASSWORDS_DO_NOT_MATCH') - ])); - $event->stopPropagation(); - return; - } - $data['password'] = $form->value('password1'); - } + if (!$this->config->get('plugins.login.enabled')) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.PLUGIN_LOGIN_DISABLED')); + } - $fields = $this->config->get('plugins.login.user_registration.fields', []); + if (!$this->config->get('plugins.login.user_registration.enabled')) { + throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_REGISTRATION_DISABLED')); + } - foreach($fields as $field) { - // Process value of field if set in the page process.register_user - $default_values = $this->config->get('plugins.login.user_registration.default_values'); - if ($default_values) foreach($default_values as $key => $param) { - $values = explode(',', $param); + $data = []; + $username = $form->value('username'); + $data['username'] = $username; - if ($key == $field) { - $data[$field] = $values; - } - } + if (file_exists($this->grav['locator']->findResource('account://' . $username . YAML_EXT))) { + $this->grav->fireEvent('onFormValidationError', new Event([ + 'form' => $form, + 'message' => $this->grav['language']->translate([ + 'PLUGIN_LOGIN.USERNAME_NOT_AVAILABLE', + $username + ]) + ])); + $event->stopPropagation(); - if (!isset($data[$field]) && $form->value($field)) { - $data[$field] = $form->value($field); - } - } + return; + } - if ($this->config->get('plugins.login.user_registration.options.validate_password1_and_password2', false)) { - unset($data['password1']); - unset($data['password2']); - } + if ($this->config->get('plugins.login.user_registration.options.validate_password1_and_password2', + false) + ) { + if ($form->value('password1') != $form->value('password2')) { + $this->grav->fireEvent('onFormValidationError', new Event([ + 'form' => $form, + 'message' => $this->grav['language']->translate('PLUGIN_LOGIN.PASSWORDS_DO_NOT_MATCH') + ])); + $event->stopPropagation(); - // Don't store the username: that is part of the filename - unset($data['username']); + return; + } + $data['password'] = $form->value('password1'); + } - if ($this->config->get('plugins.login.user_registration.options.set_user_disabled', false)) { - $data['state'] = 'disabled'; - } else { - $data['state'] = 'enabled'; - } + $fields = $this->config->get('plugins.login.user_registration.fields', []); - // Create user object and save it - $user = new User($data); - $file = CompiledYamlFile::instance($this->grav['locator']->findResource('user://accounts/' . $username . YAML_EXT, true, true)); - $user->file($file); - $user->save(); - $user = User::load($username); - - if ($data['state'] == 'enabled' && - $this->config->get('plugins.login.user_registration.options.login_after_registration', false)) { - - //Login user - $this->grav['session']->user = $user; - unset($this->grav['user']); - $this->grav['user'] = $user; - $user->authenticated = $user->authorize('site.login'); - } + foreach ($fields as $field) { + // Process value of field if set in the page process.register_user + $default_values = $this->config->get('plugins.login.user_registration.default_values'); + if ($default_values) { + foreach ($default_values as $key => $param) { + $values = explode(',', $param); - if ($this->config->get('plugins.login.user_registration.options.send_activation_email', false)) { - $this->sendActivationEmail($user); - } else { - if ($this->config->get('plugins.login.user_registration.options.send_welcome_email', false)) { - $this->sendWelcomeEmail($user); - } - if ($this->config->get('plugins.login.user_registration.options.send_notification_email', false)) { - $this->sendNotificationEmail($user); + if ($key == $field) { + $data[$field] = $values; } } + } - if ($redirect = $this->config->get('plugins.login.user_registration.redirect_after_registration', false)) { - $this->grav->redirect($redirect); - } - - break; - } - } - - /** - * Handle the email to notificate the user account creation to the site admin. - * - * @return bool True if the action was performed. - */ - protected function sendNotificationEmail($user) - { - if (empty($user->email)) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_NEEDS_EMAIL_FIELD')); + if (!isset($data[$field]) && $form->value($field)) { + $data[$field] = $form->value($field); + } } - $sitename = $this->grav['config']->get('site.title', 'Website'); - - $subject = $this->grav['language']->translate(['PLUGIN_LOGIN.NOTIFICATION_EMAIL_SUBJECT', $sitename]); - $content = $this->grav['language']->translate(['PLUGIN_LOGIN.NOTIFICATION_EMAIL_BODY', $sitename, $user->username, $user->email]); - $to = $this->grav['config']->get('plugins.email.from'); - - if (empty($to)) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_NOT_CONFIGURED')); + if ($this->config->get('plugins.login.user_registration.options.validate_password1_and_password2', + false) + ) { + unset($data['password1']); + unset($data['password2']); } - $sent = LoginUtils::sendEmail($subject, $content, $to); - - if ($sent < 1) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_SENDING_FAILURE')); + if ($this->config->get('plugins.login.user_registration.options.set_user_disabled', false)) { + $data['state'] = 'disabled'; + } else { + $data['state'] = 'enabled'; } - return true; - } + $user = $this->login->register($data); - /** - * Handle the email to welcome the new user - * - * @return bool True if the action was performed. - */ - protected function sendWelcomeEmail($user) - { - if (empty($user->email)) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_NEEDS_EMAIL_FIELD')); + if ($this->config->get('plugins.login.user_registration.options.send_activation_email', false)) { + $this->login->sendActivationEmail($user); + } else { + if ($this->config->get('plugins.login.user_registration.options.send_welcome_email', false)) { + $this->login->sendWelcomeEmail($user); + } + if ($this->config->get('plugins.login.user_registration.options.send_notification_email', false)) { + $this->login->sendNotificationEmail($user); + } } - $sitename = $this->grav['config']->get('site.title', 'Website'); - - $subject = $this->grav['language']->translate(['PLUGIN_LOGIN.WELCOME_EMAIL_SUBJECT', $sitename]); - $content = $this->grav['language']->translate(['PLUGIN_LOGIN.WELCOME_EMAIL_BODY', $user->username, $sitename]); - $to = $user->email; - - $sent = LoginUtils::sendEmail($subject, $content, $to); - - if ($sent < 1) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_SENDING_FAILURE')); + $redirect = $this->config->get('plugins.login.user_registration.redirect_after_registration', false); + if ($redirect) { + $this->grav->redirect($redirect); } - - return true; } /** - * Handle the email to activate the user account. + * Process a registration form. Handles the following actions: + * + * - register_user: registers a user * - * @return bool True if the action was performed. + * @param Event $event */ - protected function sendActivationEmail($user) + public function onFormProcessed(Event $event) { - if (empty($user->email)) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.USER_NEEDS_EMAIL_FIELD')); - } - - $token = md5(uniqid(mt_rand(), true)); - $expire = time() + 604800; // next week - $user->activation_token = $token . '::' . $expire; - $user->save(); - - $param_sep = $this->grav['config']->get('system.param_sep', ':'); - $activation_link = $this->grav['base_url_absolute'] . $this->config->get('plugins.login.route_activate') . '/token' . $param_sep . $token . '/username' . $param_sep . $user->username . '/nonce' . $param_sep . Utils::getNonce('user-activation'); - - $sitename = $this->grav['config']->get('site.title', 'Website'); - - $subject = $this->grav['language']->translate(['PLUGIN_LOGIN.ACTIVATION_EMAIL_SUBJECT', $sitename]); - $content = $this->grav['language']->translate(['PLUGIN_LOGIN.ACTIVATION_EMAIL_BODY', $user->username, $activation_link, $sitename]); - $to = $user->email; - - $sent = LoginUtils::sendEmail($subject, $content, $to); + $form = $event['form']; + $action = $event['action']; - if ($sent < 1) { - throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.EMAIL_SENDING_FAILURE')); + switch ($action) { + case 'register_user': + $this->processUserRegistration($form, $event); + break; } - - return true; } + } diff --git a/login.yaml b/login.yaml index 0a8eac5..95a50c1 100644 --- a/login.yaml +++ b/login.yaml @@ -5,8 +5,9 @@ route_register: false route_activate: /activate_user route_forgot: /forgot_password route_reset: /reset_password -redirect: +redirect_after_login: parent_acl: false +protect_protected_page_media: false user_registration: enabled: true @@ -17,11 +18,10 @@ user_registration: - 'email' - 'fullname' - 'title' - - 'access' - - 'state' - additional_params: - access: 'site.login' + access: + site: + login: 'true' options: validate_password1_and_password2: true @@ -33,39 +33,5 @@ user_registration: rememberme: enabled: true - timeout: 1800 # Timeout in seconds - name: grav-rememberme # Name prefix of the session cookie - -oauth: - enabled: false - - user: - autocreate: false - access: - site: - login: true - - providers: - Facebook: - enabled: false - credentials: - key: - secret: - - Google: - enabled: false - credentials: - key: - secret: - - GitHub: - enabled: false - credentials: - key: - secret: - - Twitter: - enabled: false - credentials: - key: - secret: + timeout: 604800 # Timeout in seconds. Defaults to 1 week + name: grav-rememberme # Name prefix of the session cookie \ No newline at end of file diff --git a/pages/forgot.md b/pages/forgot.md index 8eb5e1e..53c2f30 100644 --- a/pages/forgot.md +++ b/pages/forgot.md @@ -8,6 +8,10 @@ form: id: username placeholder: Username autofocus: true + validate: + required: true + message: PLUGIN_LOGIN.USERNAME_NOT_VALID + pattern: '^[a-z0-9_-]{3,16}$' --- diff --git a/pages/reset.md b/pages/reset.md index 35285a2..bf27624 100644 --- a/pages/reset.md +++ b/pages/reset.md @@ -4,17 +4,29 @@ title: Reset password form: fields: - name: username - type: text + type: hidden id: username placeholder: Username readonly: true + - name: password type: password id: password placeholder: Password autofocus: true + validate: + required: true + message: PLUGIN_LOGIN.PASSWORD_VALIDATION_MESSAGE + pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' + - name: token type: hidden + +process: + twig: true --- -# Password Reset \ No newline at end of file +# Password Reset + +### Username: {{uri.param('user')}} + diff --git a/templates/partials/forgot-form.html.twig b/templates/partials/forgot-form.html.twig index 9389a10..74c1b73 100644 --- a/templates/partials/forgot-form.html.twig +++ b/templates/partials/forgot-form.html.twig @@ -3,7 +3,7 @@ {% include 'partials/messages.html.twig' %} -
+ {% for field in page.header.form.fields %} {% if field.type %}
@@ -12,7 +12,7 @@ {% endif %} {% endfor %}
- +
{{ nonce_field('forgot-form', 'forgot-form-nonce') }} diff --git a/templates/partials/login-form.html.twig b/templates/partials/login-form.html.twig old mode 100644 new mode 100755 index 57b9a94..e9bbb6b --- a/templates/partials/login-form.html.twig +++ b/templates/partials/login-form.html.twig @@ -1,64 +1,52 @@ {% set icons = {'Microsoft': 'windows'} %}
- {{ content }} - {% include 'partials/messages.html.twig' %} - - {% if oauth.enabled %} -
- {# Create hidden duplicate of submit button to designate it as default #} - + {% if page.template == 'login' %} - {# Show OAuth authentication providers #} -

{{ 'PLUGIN_LOGIN.OAUTH_CONNECT_MESSAGE'|t }} - {% if oauth.providers|count > 4 %} - {{ 'PLUGIN_LOGIN.OR'|t }}

- -
    - {% for provider,credentials in oauth.providers[4:] %} - {% set icon = icons[provider]|default(provider|lower) %} -
  • - {% endfor %} -
- {% else %} -

- {% endif %} + {% if grav.user.username %} +

{{ 'PLUGIN_LOGIN.WELCOME'|t }} {{ grav.user.fullname ?: grav.user.username }}

+
+ {{ 'PLUGIN_LOGIN.BTN_LOGOUT'|t }} + + {% else %} + {{ content }} -
    - {% for provider,credentials in oauth.providers[:4] %} - {% set icon = icons[provider]|default(provider|lower) %} -
  • + + {% if grav.twig.plugins_hooked_loginPage %} + {% for label in grav.twig.plugins_hooked_loginPage %} + {% include label %} {% endfor %} -
-
- {{ 'PLUGIN_LOGIN.OR'|t }} -

{{ 'PLUGIN_LOGIN.OAUTH_SIGNIN'|t }}

- {% endif %} + {% endif %} - {% for field in page.header.form.fields %} - {% if field.type %} -
- {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %} + {% for field in page.header.form.fields %} + {% if field.type %} +
+ {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %} +
+ {% endif %} + {% endfor %} +
+ {% if config.plugins.login.rememberme.enabled %} +
+
+ + +
+
+ {% endif %} + + {{ 'PLUGIN_LOGIN.BTN_FORGOT'|t }} + +
- {% endif %} - {% endfor %} -
- {% if config.plugins.login.rememberme.enabled %} -
-
- - -
-
- {% endif %} - {{ 'PLUGIN_LOGIN.BTN_FORGOT'|t }} + {{ nonce_field('login-form', 'login-form-nonce') }} + + + {% endif %} - -
+ {% endif %} - {{ nonce_field('login-form', 'login-form-nonce') }} -
diff --git a/templates/partials/login-status.html.twig b/templates/partials/login-status.html.twig old mode 100644 new mode 100755 index 28c8f4e..f4a55c2 --- a/templates/partials/login-status.html.twig +++ b/templates/partials/login-status.html.twig @@ -1,5 +1,5 @@ diff --git a/templates/partials/reset-form.html.twig b/templates/partials/reset-form.html.twig index 114b301..f589c02 100644 --- a/templates/partials/reset-form.html.twig +++ b/templates/partials/reset-form.html.twig @@ -3,7 +3,7 @@ {% include 'partials/messages.html.twig' %} -
+ {% for field in page.header.form.fields %} {% set value = attribute(grav.twig.twig_vars, field.name) is defined ? attribute(grav.twig.twig_vars, field.name) : null %} @@ -14,7 +14,7 @@ {% endif %} {% endfor %}
- +
{{ nonce_field('reset-form', 'reset-form-nonce') }} diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 4e05d3b..ff6ecfb 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -13,9 +13,7 @@ namespace Composer\Autoload; /** - * ClassLoader implements a PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. * * $loader = new \Composer\Autoload\ClassLoader(); * @@ -39,6 +37,8 @@ * * @author Fabien Potencier * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ */ class ClassLoader { @@ -147,7 +147,7 @@ public function add($prefix, $paths, $prepend = false) * appending or prepending to the ones previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories + * @param array|string $paths The PSR-4 base directories * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException @@ -351,7 +351,7 @@ private function findFileWithExtension($class, $ext) foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { if (0 === strpos($class, $prefix)) { foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { return $file; } } @@ -361,7 +361,7 @@ private function findFileWithExtension($class, $ext) // PSR-4 fallback dirs foreach ($this->fallbackDirsPsr4 as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { return $file; } } @@ -380,7 +380,7 @@ private function findFileWithExtension($class, $ext) foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } @@ -390,7 +390,7 @@ private function findFileWithExtension($class, $ext) // PSR-0 fallback dirs foreach ($this->fallbackDirsPsr0 as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } diff --git a/vendor/lusitanian/oauth/LICENSE b/vendor/composer/LICENSE similarity index 90% rename from vendor/lusitanian/oauth/LICENSE rename to vendor/composer/LICENSE index cea529b..c8d57af 100644 --- a/vendor/lusitanian/oauth/LICENSE +++ b/vendor/composer/LICENSE @@ -1,5 +1,5 @@ -(c) 2013 David Desberg -Contributions (c) 2013 Pieter Hordijk + +Copyright (c) 2015 Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,3 +18,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 95c4f01..b7fc012 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -6,6 +6,4 @@ $baseDir = dirname($vendorDir); return array( - 'OAuth\\Unit' => array($vendorDir . '/lusitanian/oauth/tests'), - 'OAuth' => array($vendorDir . '/lusitanian/oauth/src'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index a690f0e..a39a2c9 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -43,8 +43,3 @@ public static function getLoader() return $loader; } } - -function composerRequire71f652402b8b0a33907795a253fefcfe($file) -{ - require $file; -} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 907d98c..ee87703 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -42,74 +42,5 @@ "remember", "security" ] - }, - { - "name": "lusitanian/oauth", - "version": "v0.8.3", - "version_normalized": "0.8.3.0", - "source": { - "type": "git", - "url": "https://github.com/Lusitanian/PHPoAuthLib.git", - "reference": "d47849e3838a7ea738111e3f1d7c810cc950539a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/d47849e3838a7ea738111e3f1d7c810cc950539a", - "reference": "d47849e3838a7ea738111e3f1d7c810cc950539a", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*", - "predis/predis": "0.8.*@dev", - "squizlabs/php_codesniffer": "2.*", - "symfony/http-foundation": "~2.1" - }, - "suggest": { - "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.", - "predis/predis": "Allows using the Redis storage backend.", - "symfony/http-foundation": "Allows using the Symfony Session storage backend." - }, - "time": "2015-11-17 21:54:31", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "OAuth": "src", - "OAuth\\Unit": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "David Desberg", - "email": "david@daviddesberg.com" - }, - { - "name": "Elliot Chance", - "email": "elliotchance@gmail.com" - }, - { - "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" - } - ], - "description": "PHP 5.3+ oAuth 1/2 Library", - "keywords": [ - "Authentication", - "authorization", - "oauth", - "security" - ] } ] diff --git a/vendor/lusitanian/oauth/.gitignore b/vendor/lusitanian/oauth/.gitignore deleted file mode 100644 index 54a7fcf..0000000 --- a/vendor/lusitanian/oauth/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.idea -vendor -.DS_Store -examples/init.php -atlassian-ide-plugin.xml -nbproject/ diff --git a/vendor/lusitanian/oauth/.scrutinizer.yml b/vendor/lusitanian/oauth/.scrutinizer.yml deleted file mode 100644 index 5a274c9..0000000 --- a/vendor/lusitanian/oauth/.scrutinizer.yml +++ /dev/null @@ -1,37 +0,0 @@ -before_commands: - - "composer install --dev --prefer-source" - -tools: - php_code_coverage: - enabled: true - test_command: phpunit -c phpunit.xml.dist - filter: - paths: ["src/*"] - php_code_sniffer: - enabled: true - config: - standard: PSR2 - filter: - paths: ["src/*"] - php_cpd: - enabled: true - excluded_dirs: ["examples", "tests", "vendor"] - php_cs_fixer: - enabled: true - config: - level: all - filter: - paths: ["src/*", "tests/*"] - php_loc: - enabled: true - php_mess_detector: - enabled: true - filter: - paths: ["src/*"] - php_pdepend: - enabled: true - excluded_dirs: ["tests", "examples", "vendor"] - php_analyzer: - filter: - paths: ["src/*", "tests/*"] - sensiolabs_security_checker: true diff --git a/vendor/lusitanian/oauth/.travis.yml b/vendor/lusitanian/oauth/.travis.yml deleted file mode 100644 index d279937..0000000 --- a/vendor/lusitanian/oauth/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -sudo: false -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - -matrix: - allow_failures: - - php: hhvm - -before_script: - - composer self-update - - composer install - - phpenv rehash - -script: - - phpunit --coverage-text diff --git a/vendor/lusitanian/oauth/README.md b/vendor/lusitanian/oauth/README.md deleted file mode 100644 index 0733056..0000000 --- a/vendor/lusitanian/oauth/README.md +++ /dev/null @@ -1,123 +0,0 @@ -PHPoAuthLib -=========== -**NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to it. However, I'm still going to keep trying to pay attention to PRs, etc.** - -PHPoAuthLib provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client. - -[![Build Status](https://travis-ci.org/Lusitanian/PHPoAuthLib.png?branch=master)](https://travis-ci.org/Lusitanian/PHPoAuthLib) -[![Code Coverage](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/badges/coverage.png?s=a0a15bebfda49e79f9ce289b00c6dfebd18fc98e)](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/) -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/badges/quality-score.png?s=c5976d2fefceb501f0d886c1a5bf087e69b44533)](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/) -[![Latest Stable Version](https://poser.pugx.org/lusitanian/oauth/v/stable.png)](https://packagist.org/packages/lusitanian/oauth) -[![Total Downloads](https://poser.pugx.org/lusitanian/oauth/downloads.png)](https://packagist.org/packages/lusitanian/oauth) - -Installation ------------- -This library can be found on [Packagist](https://packagist.org/packages/lusitanian/oauth). -The recommended way to install this is through [composer](http://getcomposer.org). - -Edit your `composer.json` and add: - -```json -{ - "require": { - "lusitanian/oauth": "~0.3" - } -} -``` - -And install dependencies: - -```bash -$ curl -sS https://getcomposer.org/installer | php -$ php composer.phar install -``` - -Features --------- -- PSR-0 compliant for easy interoperability -- Fully extensible in every facet. - - You can implement any service with any custom requirements by extending the protocol version's `AbstractService` implementation. - - You can use any HTTP client you desire, just create a class utilizing it which implements `OAuth\Common\Http\ClientInterface` (two implementations are included) - - You can use any storage mechanism for tokens. By default, session, in-memory and Redis.io (requires PHPRedis) storage mechanisms are included. Implement additional mechanisms by implementing `OAuth\Common\Token\TokenStorageInterface`. - -Service support ---------------- -The library supports both oAuth 1.x and oAuth 2.0 compliant services. A list of currently implemented services can be found below. - -Included service implementations --------------------------------- -- OAuth1 - - 500px - - BitBucket - - Etsy - - FitBit - - Flickr - - QuickBooks - - Scoop.it! - - Tumblr - - Twitter - - Xing - - Yahoo -- OAuth2 - - Amazon - - BitLy - - Bitrix24 - - Box - - Buffer - - Dailymotion - - Delicious - - Deezer - - DeviantArt - - Dropbox - - Eve Online - - Facebook - - Foursquare - - GitHub - - Google - - Harvest - - Heroku - - Hubic - - Instagram - - Jawbone UP - - LinkedIn - - Mailchimp - - Microsoft - - Nest - - Netatmo - - Parrot Flower Power - - PayPal - - Pinterest - - Pocket - - Reddit - - RunKeeper - - Salesforce - - SoundCloud - - Spotify - - Strava - - Ustream - - Vimeo - - Vkontakte - - Yahoo - - Yammer -- more to come! - -Examples --------- -Examples of basic usage are located in the examples/ directory. - -Usage ------- -For usage with complete auth flow, please see the examples. More in-depth documentation will come with release 1.0. - -Framework Integration ---------------------- -* Lithium: Sébastien Charrier has written [an adapter](https://github.com/scharrier/li3_socialauth) for the library. -* Laravel 4: Dariusz Prząda has written [a service provider](https://github.com/artdarek/oauth-4-laravel) for the library. - -Extensions ----------- -* Extract normalized user data from OAuth Services with the library [PHPoAuthUserData](https://github.com/Oryzone/PHPoAuthUserData) by Luciano Mammino - -Tests ------- -To run the tests, you must install dependencies with `composer install --dev` diff --git a/vendor/lusitanian/oauth/composer.json b/vendor/lusitanian/oauth/composer.json deleted file mode 100644 index 66fc46a..0000000 --- a/vendor/lusitanian/oauth/composer.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "lusitanian/oauth", - "description": "PHP 5.3+ oAuth 1/2 Library", - "keywords": ["oauth", "authentication", "authorization", "security"], - "license": "MIT", - "authors": [ - { - "name": "David Desberg", - "email": "david@daviddesberg.com" - }, - { - "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" - }, - { - "name": "Elliot Chance", - "email": "elliotchance@gmail.com" - } - ], - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "symfony/http-foundation": "~2.1", - "predis/predis": "0.8.*@dev", - "phpunit/phpunit": "3.7.*", - "squizlabs/php_codesniffer": "2.*" - }, - "suggest": { - "symfony/http-foundation": "Allows using the Symfony Session storage backend.", - "predis/predis": "Allows using the Redis storage backend.", - "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client." - }, - "autoload": { - "psr-0": { - "OAuth": "src", - "OAuth\\Unit": "tests" - } - }, - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" - } - } -} diff --git a/vendor/lusitanian/oauth/composer.lock b/vendor/lusitanian/oauth/composer.lock deleted file mode 100644 index 42ceafe..0000000 --- a/vendor/lusitanian/oauth/composer.lock +++ /dev/null @@ -1,610 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "734ee27aca2b4b8a33857520f518ef0c", - "packages": [], - "packages-dev": [ - { - "name": "phpunit/php-code-coverage", - "version": "1.2.18", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", - "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": ">=1.3.0@stable", - "phpunit/php-text-template": ">=1.2.0@stable", - "phpunit/php-token-stream": ">=1.1.3,<1.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*@dev" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.0.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2014-09-02 10:13:14" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2015-06-21 08:01:12" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2014-03-03 05:10:30" - }, - { - "name": "phpunit/phpunit", - "version": "3.7.38", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6", - "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpunit/php-code-coverage": "~1.2", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.1", - "phpunit/php-timer": "~1.0", - "phpunit/phpunit-mock-objects": "~1.2", - "symfony/yaml": "~2.0" - }, - "require-dev": { - "pear-pear.php.net/pear": "1.9.4" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "composer/bin/phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.7.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHPUnit/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "http://www.phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2014-10-17 09:04:17" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", - "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-text-template": ">=1.1.1@stable" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "autoload": { - "classmap": [ - "PHPUnit/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2013-01-13 10:24:48" - }, - { - "name": "predis/predis", - "version": "0.8.x-dev", - "source": { - "type": "git", - "url": "https://github.com/nrk/predis.git", - "reference": "192dfd61e54c3d32c9526bba03365fff818e17e4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nrk/predis/zipball/192dfd61e54c3d32c9526bba03365fff818e17e4", - "reference": "192dfd61e54c3d32c9526bba03365fff818e17e4", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "ext-curl": "Allows access to Webdis when paired with phpiredis", - "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" - }, - "type": "library", - "autoload": { - "psr-0": { - "Predis": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniele Alessandri", - "email": "suppakilla@gmail.com", - "homepage": "http://clorophilla.net" - } - ], - "description": "Flexible and feature-complete PHP client library for Redis", - "homepage": "http://github.com/nrk/predis", - "keywords": [ - "nosql", - "predis", - "redis" - ], - "time": "2015-07-07 17:11:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "2.3.4", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "11a2545c44a5915f883e2e5ec12e14ed345e3ab2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/11a2545c44a5915f883e2e5ec12e14ed345e3ab2", - "reference": "11a2545c44a5915f883e2e5ec12e14ed345e3ab2", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.1.2" - }, - "bin": [ - "scripts/phpcs", - "scripts/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2015-09-09 00:18:50" - }, - { - "name": "symfony/http-foundation", - "version": "v2.7.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "7253c2041652353e71560bbd300d6256d170ddaf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/7253c2041652353e71560bbd300d6256d170ddaf", - "reference": "7253c2041652353e71560bbd300d6256d170ddaf", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/expression-language": "~2.4", - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2015-08-27 06:45:45" - }, - { - "name": "symfony/yaml", - "version": "v2.7.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661", - "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2015-08-24 07:13:45" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "predis/predis": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.0" - }, - "platform-dev": [] -} diff --git a/vendor/lusitanian/oauth/phpunit.xml.dist b/vendor/lusitanian/oauth/phpunit.xml.dist deleted file mode 100644 index ee28195..0000000 --- a/vendor/lusitanian/oauth/phpunit.xml.dist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - tests/Unit - - - - - src/ - - src/OAuth/bootstrap.php - src/OAuth/Common/Exception/Exception.php - src/OAuth/Common/Http/Exception/TokenResponseException.php - src/OAuth/Common/Storage/Exception/StorageException.php - src/OAuth/Common/Storage/Exception/TokenNotFoundException.php - src/OAuth/Common/Token/Exception/ExpiredTokenException.php - src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php - src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php - src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php - src/OAuth/OAuth2/Token/StdOAuth2Token.php - - - - - - - - diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php b/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php deleted file mode 100644 index 9fe7951..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class AutoLoader -{ - /** - * @var string The namespace prefix for this instance. - */ - protected $namespace = ''; - - /** - * @var string The filesystem prefix to use for this instance - */ - protected $path = ''; - - /** - * Build the instance of the autoloader - * - * @param string $namespace The prefixed namespace this instance will load - * @param string $path The filesystem path to the root of the namespace - */ - public function __construct($namespace, $path) - { - $this->namespace = ltrim($namespace, '\\'); - $this->path = rtrim($path, '/\\') . DIRECTORY_SEPARATOR; - } - - /** - * Try to load a class - * - * @param string $class The class name to load - * - * @return boolean If the loading was successful - */ - public function load($class) - { - $class = ltrim($class, '\\'); - - if (strpos($class, $this->namespace) === 0) { - $nsparts = explode('\\', $class); - $class = array_pop($nsparts); - $nsparts[] = ''; - $path = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts); - $path .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; - - if (file_exists($path)) { - require $path; - - return true; - } - } - - return false; - } - - /** - * Register the autoloader to PHP - * - * @return boolean The status of the registration - */ - public function register() - { - return spl_autoload_register(array($this, 'load')); - } - - /** - * Unregister the autoloader to PHP - * - * @return boolean The status of the unregistration - */ - public function unregister() - { - return spl_autoload_unregister(array($this, 'load')); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php b/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php deleted file mode 100644 index 8e98e9f..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php +++ /dev/null @@ -1,60 +0,0 @@ -consumerId = $consumerId; - $this->consumerSecret = $consumerSecret; - $this->callbackUrl = $callbackUrl; - } - - /** - * @return string - */ - public function getCallbackUrl() - { - return $this->callbackUrl; - } - - /** - * @return string - */ - public function getConsumerId() - { - return $this->consumerId; - } - - /** - * @return string - */ - public function getConsumerSecret() - { - return $this->consumerSecret; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php deleted file mode 100644 index a33e54e..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -userAgent = $userAgent; - } - - /** - * @param int $redirects Maximum redirects for client - * - * @return ClientInterface - */ - public function setMaxRedirects($redirects) - { - $this->maxRedirects = $redirects; - - return $this; - } - - /** - * @param int $timeout Request timeout time for client in seconds - * - * @return ClientInterface - */ - public function setTimeout($timeout) - { - $this->timeout = $timeout; - - return $this; - } - - /** - * @param array $headers - */ - public function normalizeHeaders(&$headers) - { - // Normalize headers - array_walk( - $headers, - function (&$val, &$key) { - $key = ucfirst(strtolower($key)); - $val = ucfirst(strtolower($key)) . ': ' . $val; - } - ); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php deleted file mode 100644 index f9c2022..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - value` pairs) to be passed to `curl_setopt` - * - * @var array - */ - private $parameters = array(); - - /** - * Additional `curl_setopt` parameters - * - * @param array $parameters - */ - public function setCurlParameters(array $parameters) - { - $this->parameters = $parameters; - } - - /** - * @param bool $force - * - * @return CurlClient - */ - public function setForceSSL3($force) - { - $this->forceSSL3 = $force; - - return $this; - } - - /** - * Any implementing HTTP providers should send a request to the provided endpoint with the parameters. - * They should return, in string form, the response body and throw an exception on error. - * - * @param UriInterface $endpoint - * @param mixed $requestBody - * @param array $extraHeaders - * @param string $method - * - * @return string - * - * @throws TokenResponseException - * @throws \InvalidArgumentException - */ - public function retrieveResponse( - UriInterface $endpoint, - $requestBody, - array $extraHeaders = array(), - $method = 'POST' - ) { - // Normalize method name - $method = strtoupper($method); - - $this->normalizeHeaders($extraHeaders); - - if ($method === 'GET' && !empty($requestBody)) { - throw new \InvalidArgumentException('No body expected for "GET" request.'); - } - - if (!isset($extraHeaders['Content-Type']) && $method === 'POST' && is_array($requestBody)) { - $extraHeaders['Content-Type'] = 'Content-Type: application/x-www-form-urlencoded'; - } - - $extraHeaders['Host'] = 'Host: '.$endpoint->getHost(); - $extraHeaders['Connection'] = 'Connection: close'; - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $endpoint->getAbsoluteUri()); - - if ($method === 'POST' || $method === 'PUT') { - if ($requestBody && is_array($requestBody)) { - $requestBody = http_build_query($requestBody, '', '&'); - } - - if ($method === 'PUT') { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); - } else { - curl_setopt($ch, CURLOPT_POST, true); - } - - curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); - } else { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); - } - - if ($this->maxRedirects > 0) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->maxRedirects); - } - - curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_HTTPHEADER, $extraHeaders); - curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); - - foreach ($this->parameters as $key => $value) { - curl_setopt($ch, $key, $value); - } - - if ($this->forceSSL3) { - curl_setopt($ch, CURLOPT_SSLVERSION, 3); - } - - $response = curl_exec($ch); - $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - if (false === $response) { - $errNo = curl_errno($ch); - $errStr = curl_error($ch); - curl_close($ch); - if (empty($errStr)) { - throw new TokenResponseException('Failed to request resource.', $responseCode); - } - throw new TokenResponseException('cURL Error # '.$errNo.': '.$errStr, $responseCode); - } - - curl_close($ch); - - return $response; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php deleted file mode 100644 index d81fee8..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php +++ /dev/null @@ -1,95 +0,0 @@ -normalizeHeaders($extraHeaders); - - if ($method === 'GET' && !empty($requestBody)) { - throw new \InvalidArgumentException('No body expected for "GET" request.'); - } - - if (!isset($extraHeaders['Content-Type']) && $method === 'POST' && is_array($requestBody)) { - $extraHeaders['Content-Type'] = 'Content-Type: application/x-www-form-urlencoded'; - } - - $host = 'Host: '.$endpoint->getHost(); - // Append port to Host if it has been specified - if ($endpoint->hasExplicitPortSpecified()) { - $host .= ':'.$endpoint->getPort(); - } - - $extraHeaders['Host'] = $host; - $extraHeaders['Connection'] = 'Connection: close'; - - if (is_array($requestBody)) { - $requestBody = http_build_query($requestBody, '', '&'); - } - $extraHeaders['Content-length'] = 'Content-length: '.strlen($requestBody); - - $context = $this->generateStreamContext($requestBody, $extraHeaders, $method); - - $level = error_reporting(0); - $response = file_get_contents($endpoint->getAbsoluteUri(), false, $context); - error_reporting($level); - if (false === $response) { - $lastError = error_get_last(); - if (is_null($lastError)) { - throw new TokenResponseException( - 'Failed to request resource. HTTP Code: ' . - ((isset($http_response_header[0]))?$http_response_header[0]:'No response') - ); - } - throw new TokenResponseException($lastError['message']); - } - - return $response; - } - - private function generateStreamContext($body, $headers, $method) - { - return stream_context_create( - array( - 'http' => array( - 'method' => $method, - 'header' => implode("\r\n", array_values($headers)), - 'content' => $body, - 'protocol_version' => '1.1', - 'user_agent' => $this->userAgent, - 'max_redirects' => $this->maxRedirects, - 'timeout' => $this->timeout - ), - ) - ); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php deleted file mode 100644 index c519a22..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php +++ /dev/null @@ -1,12 +0,0 @@ -parseUri($uri); - } - } - - /** - * @param string $uri - * - * @throws \InvalidArgumentException - */ - protected function parseUri($uri) - { - if (false === ($uriParts = parse_url($uri))) { - // congratulations if you've managed to get parse_url to fail, - // it seems to always return some semblance of a parsed url no matter what - throw new InvalidArgumentException("Invalid URI: $uri"); - } - - if (!isset($uriParts['scheme'])) { - throw new InvalidArgumentException('Invalid URI: http|https scheme required'); - } - - $this->scheme = $uriParts['scheme']; - $this->host = $uriParts['host']; - - if (isset($uriParts['port'])) { - $this->port = $uriParts['port']; - $this->explicitPortSpecified = true; - } else { - $this->port = strcmp('https', $uriParts['scheme']) ? 80 : 443; - $this->explicitPortSpecified = false; - } - - if (isset($uriParts['path'])) { - $this->path = $uriParts['path']; - if ('/' === $uriParts['path']) { - $this->explicitTrailingHostSlash = true; - } - } else { - $this->path = '/'; - } - - $this->query = isset($uriParts['query']) ? $uriParts['query'] : ''; - $this->fragment = isset($uriParts['fragment']) ? $uriParts['fragment'] : ''; - - $userInfo = ''; - if (!empty($uriParts['user'])) { - $userInfo .= $uriParts['user']; - } - if ($userInfo && !empty($uriParts['pass'])) { - $userInfo .= ':' . $uriParts['pass']; - } - - $this->setUserInfo($userInfo); - } - - /** - * @param string $rawUserInfo - * - * @return string - */ - protected function protectUserInfo($rawUserInfo) - { - $colonPos = strpos($rawUserInfo, ':'); - - // rfc3986-3.2.1 | http://tools.ietf.org/html/rfc3986#section-3.2 - // "Applications should not render as clear text any data - // after the first colon (":") character found within a userinfo - // subcomponent unless the data after the colon is the empty string - // (indicating no password)" - if ($colonPos !== false && strlen($rawUserInfo)-1 > $colonPos) { - return substr($rawUserInfo, 0, $colonPos) . ':********'; - } else { - return $rawUserInfo; - } - } - - /** - * @return string - */ - public function getScheme() - { - return $this->scheme; - } - - /** - * @return string - */ - public function getUserInfo() - { - return $this->userInfo; - } - - /** - * @return string - */ - public function getRawUserInfo() - { - return $this->rawUserInfo; - } - - /** - * @return string - */ - public function getHost() - { - return $this->host; - } - - /** - * @return int - */ - public function getPort() - { - return $this->port; - } - - /** - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * @return string - */ - public function getQuery() - { - return $this->query; - } - - /** - * @return string - */ - public function getFragment() - { - return $this->fragment; - } - - /** - * Uses protected user info by default as per rfc3986-3.2.1 - * Uri::getRawAuthority() is available if plain-text password information is desirable. - * - * @return string - */ - public function getAuthority() - { - $authority = $this->userInfo ? $this->userInfo.'@' : ''; - $authority .= $this->host; - - if ($this->explicitPortSpecified) { - $authority .= ":{$this->port}"; - } - - return $authority; - } - - /** - * @return string - */ - public function getRawAuthority() - { - $authority = $this->rawUserInfo ? $this->rawUserInfo.'@' : ''; - $authority .= $this->host; - - if ($this->explicitPortSpecified) { - $authority .= ":{$this->port}"; - } - - return $authority; - } - - /** - * @return string - */ - public function getAbsoluteUri() - { - $uri = $this->scheme . '://' . $this->getRawAuthority(); - - if ('/' === $this->path) { - $uri .= $this->explicitTrailingHostSlash ? '/' : ''; - } else { - $uri .= $this->path; - } - - if (!empty($this->query)) { - $uri .= "?{$this->query}"; - } - - if (!empty($this->fragment)) { - $uri .= "#{$this->fragment}"; - } - - return $uri; - } - - /** - * @return string - */ - public function getRelativeUri() - { - $uri = ''; - - if ('/' === $this->path) { - $uri .= $this->explicitTrailingHostSlash ? '/' : ''; - } else { - $uri .= $this->path; - } - - return $uri; - } - - /** - * Uses protected user info by default as per rfc3986-3.2.1 - * Uri::getAbsoluteUri() is available if plain-text password information is desirable. - * - * @return string - */ - public function __toString() - { - $uri = $this->scheme . '://' . $this->getAuthority(); - - if ('/' === $this->path) { - $uri .= $this->explicitTrailingHostSlash ? '/' : ''; - } else { - $uri .= $this->path; - } - - if (!empty($this->query)) { - $uri .= "?{$this->query}"; - } - - if (!empty($this->fragment)) { - $uri .= "#{$this->fragment}"; - } - - return $uri; - } - - /** - * @param $path - */ - public function setPath($path) - { - if (empty($path)) { - $this->path = '/'; - $this->explicitTrailingHostSlash = false; - } else { - $this->path = $path; - if ('/' === $this->path) { - $this->explicitTrailingHostSlash = true; - } - } - } - - /** - * @param string $query - */ - public function setQuery($query) - { - $this->query = $query; - } - - /** - * @param string $var - * @param string $val - */ - public function addToQuery($var, $val) - { - if (strlen($this->query) > 0) { - $this->query .= '&'; - } - $this->query .= http_build_query(array($var => $val), '', '&'); - } - - /** - * @param string $fragment - */ - public function setFragment($fragment) - { - $this->fragment = $fragment; - } - - /** - * @param string $scheme - */ - public function setScheme($scheme) - { - $this->scheme = $scheme; - } - - - /** - * @param string $userInfo - */ - public function setUserInfo($userInfo) - { - $this->userInfo = $userInfo ? $this->protectUserInfo($userInfo) : ''; - $this->rawUserInfo = $userInfo; - } - - - /** - * @param int $port - */ - public function setPort($port) - { - $this->port = intval($port); - - if (('https' === $this->scheme && $this->port === 443) || ('http' === $this->scheme && $this->port === 80)) { - $this->explicitPortSpecified = false; - } else { - $this->explicitPortSpecified = true; - } - } - - /** - * @param string $host - */ - public function setHost($host) - { - $this->host = $host; - } - - /** - * @return bool - */ - public function hasExplicitTrailingHostSlash() - { - return $this->explicitTrailingHostSlash; - } - - /** - * @return bool - */ - public function hasExplicitPortSpecified() - { - return $this->explicitPortSpecified; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php deleted file mode 100644 index 127aa20..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php +++ /dev/null @@ -1,168 +0,0 @@ -attemptProxyStyleParse($_server)) { - return $uri; - } - - $scheme = $this->detectScheme($_server); - $host = $this->detectHost($_server); - $port = $this->detectPort($_server); - $path = $this->detectPath($_server); - $query = $this->detectQuery($_server); - - return $this->createFromParts($scheme, '', $host, $port, $path, $query); - } - - /** - * @param string $absoluteUri - * - * @return UriInterface - */ - public function createFromAbsolute($absoluteUri) - { - return new Uri($absoluteUri); - } - - /** - * Factory method to build a URI from parts - * - * @param string $scheme - * @param string $userInfo - * @param string $host - * @param string $port - * @param string $path - * @param string $query - * @param string $fragment - * - * @return UriInterface - */ - public function createFromParts($scheme, $userInfo, $host, $port, $path = '', $query = '', $fragment = '') - { - $uri = new Uri(); - $uri->setScheme($scheme); - $uri->setUserInfo($userInfo); - $uri->setHost($host); - $uri->setPort($port); - $uri->setPath($path); - $uri->setQuery($query); - $uri->setFragment($fragment); - - return $uri; - } - - /** - * @param array $_server - * - * @return UriInterface|null - */ - private function attemptProxyStyleParse($_server) - { - // If the raw HTTP request message arrives with a proxy-style absolute URI in the - // initial request line, the absolute URI is stored in $_SERVER['REQUEST_URI'] and - // we only need to parse that. - if (isset($_server['REQUEST_URI']) && parse_url($_server['REQUEST_URI'], PHP_URL_SCHEME)) { - return new Uri($_server['REQUEST_URI']); - } - - return null; - } - - /** - * @param array $_server - * - * @return string - * - * @throws RuntimeException - */ - private function detectPath($_server) - { - if (isset($_server['REQUEST_URI'])) { - $uri = $_server['REQUEST_URI']; - } elseif (isset($_server['REDIRECT_URL'])) { - $uri = $_server['REDIRECT_URL']; - } else { - throw new RuntimeException('Could not detect URI path from superglobal'); - } - - $queryStr = strpos($uri, '?'); - if ($queryStr !== false) { - $uri = substr($uri, 0, $queryStr); - } - - return $uri; - } - - /** - * @param array $_server - * - * @return string - */ - private function detectHost(array $_server) - { - $host = isset($_server['HTTP_HOST']) ? $_server['HTTP_HOST'] : ''; - - if (strstr($host, ':')) { - $host = parse_url($host, PHP_URL_HOST); - } - - return $host; - } - - /** - * @param array $_server - * - * @return string - */ - private function detectPort(array $_server) - { - return isset($_server['SERVER_PORT']) ? $_server['SERVER_PORT'] : 80; - } - - /** - * @param array $_server - * - * @return string - */ - private function detectQuery(array $_server) - { - return isset($_server['QUERY_STRING']) ? $_server['QUERY_STRING'] : ''; - } - - /** - * Determine URI scheme component from superglobal array - * - * When using ISAPI with IIS, the value will be "off" if the request was - * not made through the HTTPS protocol. As a result, we filter the - * value to a bool. - * - * @param array $_server A super-global $_SERVER array - * - * @return string Returns http or https depending on the URI scheme - */ - private function detectScheme(array $_server) - { - if (isset($_server['HTTPS']) && filter_var($_server['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { - return 'https'; - } else { - return 'http'; - } - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php deleted file mode 100644 index 2b157d8..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ -credentials = $credentials; - $this->httpClient = $httpClient; - $this->storage = $storage; - } - - /** - * @param UriInterface|string $path - * @param UriInterface $baseApiUri - * - * @return UriInterface - * - * @throws Exception - */ - protected function determineRequestUriFromPath($path, UriInterface $baseApiUri = null) - { - if ($path instanceof UriInterface) { - $uri = $path; - } elseif (stripos($path, 'http://') === 0 || stripos($path, 'https://') === 0) { - $uri = new Uri($path); - } else { - if (null === $baseApiUri) { - throw new Exception( - 'An absolute URI must be passed to ServiceInterface::request as no baseApiUri is set.' - ); - } - - $uri = clone $baseApiUri; - if (false !== strpos($path, '?')) { - $parts = explode('?', $path, 2); - $path = $parts[0]; - $query = $parts[1]; - $uri->setQuery($query); - } - - if ($path[0] === '/') { - $path = substr($path, 1); - } - - $uri->setPath($uri->getPath() . $path); - } - - return $uri; - } - - /** - * Accessor to the storage adapter to be able to retrieve tokens - * - * @return TokenStorageInterface - */ - public function getStorage() - { - return $this->storage; - } - - /** - * @return string - */ - public function service() - { - // get class name without backslashes - $classname = get_class($this); - - return preg_replace('/^.*\\\\/', '', $classname); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php deleted file mode 100644 index 5856a03..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php +++ /dev/null @@ -1,49 +0,0 @@ -tokens = array(); - $this->states = array(); - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if ($this->hasAccessToken($service)) { - return $this->tokens[$service]; - } - - throw new TokenNotFoundException('Token not stored'); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - $this->tokens[$service] = $token; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - return isset($this->tokens[$service]) && $this->tokens[$service] instanceof TokenInterface; - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - if (array_key_exists($service, $this->tokens)) { - unset($this->tokens[$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - $this->tokens = array(); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if ($this->hasAuthorizationState($service)) { - return $this->states[$service]; - } - - throw new AuthorizationStateNotFoundException('State not stored'); - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - $this->states[$service] = $state; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - return isset($this->states[$service]) && null !== $this->states[$service]; - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - if (array_key_exists($service, $this->states)) { - unset($this->states[$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - $this->states = array(); - - // allow chaining - return $this; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php deleted file mode 100644 index 5d3d9ae..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php +++ /dev/null @@ -1,230 +0,0 @@ -redis = $redis; - $this->key = $key; - $this->stateKey = $stateKey; - $this->cachedTokens = array(); - $this->cachedStates = array(); - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if (!$this->hasAccessToken($service)) { - throw new TokenNotFoundException('Token not found in redis'); - } - - if (isset($this->cachedTokens[$service])) { - return $this->cachedTokens[$service]; - } - - $val = $this->redis->hget($this->key, $service); - - return $this->cachedTokens[$service] = unserialize($val); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - // (over)write the token - $this->redis->hset($this->key, $service, serialize($token)); - $this->cachedTokens[$service] = $token; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - if (isset($this->cachedTokens[$service]) - && $this->cachedTokens[$service] instanceof TokenInterface - ) { - return true; - } - - return $this->redis->hexists($this->key, $service); - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - $this->redis->hdel($this->key, $service); - unset($this->cachedTokens[$service]); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - // memory - $this->cachedTokens = array(); - - // redis - $keys = $this->redis->hkeys($this->key); - $me = $this; // 5.3 compat - - // pipeline for performance - $this->redis->pipeline( - function ($pipe) use ($keys, $me) { - foreach ($keys as $k) { - $pipe->hdel($me->getKey(), $k); - } - } - ); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if (!$this->hasAuthorizationState($service)) { - throw new AuthorizationStateNotFoundException('State not found in redis'); - } - - if (isset($this->cachedStates[$service])) { - return $this->cachedStates[$service]; - } - - $val = $this->redis->hget($this->stateKey, $service); - - return $this->cachedStates[$service] = $val; - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - // (over)write the token - $this->redis->hset($this->stateKey, $service, $state); - $this->cachedStates[$service] = $state; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - if (isset($this->cachedStates[$service]) - && null !== $this->cachedStates[$service] - ) { - return true; - } - - return $this->redis->hexists($this->stateKey, $service); - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - $this->redis->hdel($this->stateKey, $service); - unset($this->cachedStates[$service]); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - // memory - $this->cachedStates = array(); - - // redis - $keys = $this->redis->hkeys($this->stateKey); - $me = $this; // 5.3 compat - - // pipeline for performance - $this->redis->pipeline( - function ($pipe) use ($keys, $me) { - foreach ($keys as $k) { - $pipe->hdel($me->getKey(), $k); - } - } - ); - - // allow chaining - return $this; - } - - /** - * @return Predis $redis - */ - public function getRedis() - { - return $this->redis; - } - - /** - * @return string $key - */ - public function getKey() - { - return $this->key; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php deleted file mode 100644 index dd9aba7..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php +++ /dev/null @@ -1,204 +0,0 @@ -sessionHasStarted()) { - session_start(); - } - - $this->startSession = $startSession; - $this->sessionVariableName = $sessionVariableName; - $this->stateVariableName = $stateVariableName; - if (!isset($_SESSION[$sessionVariableName])) { - $_SESSION[$sessionVariableName] = array(); - } - if (!isset($_SESSION[$stateVariableName])) { - $_SESSION[$stateVariableName] = array(); - } - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if ($this->hasAccessToken($service)) { - return unserialize($_SESSION[$this->sessionVariableName][$service]); - } - - throw new TokenNotFoundException('Token not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - $serializedToken = serialize($token); - - if (isset($_SESSION[$this->sessionVariableName]) - && is_array($_SESSION[$this->sessionVariableName]) - ) { - $_SESSION[$this->sessionVariableName][$service] = $serializedToken; - } else { - $_SESSION[$this->sessionVariableName] = array( - $service => $serializedToken, - ); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - return isset($_SESSION[$this->sessionVariableName], $_SESSION[$this->sessionVariableName][$service]); - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - if (array_key_exists($service, $_SESSION[$this->sessionVariableName])) { - unset($_SESSION[$this->sessionVariableName][$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - unset($_SESSION[$this->sessionVariableName]); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - if (isset($_SESSION[$this->stateVariableName]) - && is_array($_SESSION[$this->stateVariableName]) - ) { - $_SESSION[$this->stateVariableName][$service] = $state; - } else { - $_SESSION[$this->stateVariableName] = array( - $service => $state, - ); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - return isset($_SESSION[$this->stateVariableName], $_SESSION[$this->stateVariableName][$service]); - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if ($this->hasAuthorizationState($service)) { - return $_SESSION[$this->stateVariableName][$service]; - } - - throw new AuthorizationStateNotFoundException('State not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - if (array_key_exists($service, $_SESSION[$this->stateVariableName])) { - unset($_SESSION[$this->stateVariableName][$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - unset($_SESSION[$this->stateVariableName]); - - // allow chaining - return $this; - } - - public function __destruct() - { - if ($this->startSession) { - session_write_close(); - } - } - - /** - * Determine if the session has started. - * @url http://stackoverflow.com/a/18542272/1470961 - * @return bool - */ - protected function sessionHasStarted() - { - // For more modern PHP versions we use a more reliable method. - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { - return session_status() != PHP_SESSION_NONE; - } - - // Below PHP 5.4 we should test for the current session ID. - return session_id() !== ''; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php deleted file mode 100644 index 6c5fbf6..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php +++ /dev/null @@ -1,200 +0,0 @@ -session = $session; - $this->sessionVariableName = $sessionVariableName; - $this->stateVariableName = $stateVariableName; - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if ($this->hasAccessToken($service)) { - // get from session - $tokens = $this->session->get($this->sessionVariableName); - - // one item - return $tokens[$service]; - } - - throw new TokenNotFoundException('Token not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - // get previously saved tokens - $tokens = $this->session->get($this->sessionVariableName); - - if (!is_array($tokens)) { - $tokens = array(); - } - - $tokens[$service] = $token; - - // save - $this->session->set($this->sessionVariableName, $tokens); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - // get from session - $tokens = $this->session->get($this->sessionVariableName); - - return is_array($tokens) - && isset($tokens[$service]) - && $tokens[$service] instanceof TokenInterface; - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - // get previously saved tokens - $tokens = $this->session->get($this->sessionVariableName); - - if (is_array($tokens) && array_key_exists($service, $tokens)) { - unset($tokens[$service]); - - // Replace the stored tokens array - $this->session->set($this->sessionVariableName, $tokens); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - $this->session->remove($this->sessionVariableName); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if ($this->hasAuthorizationState($service)) { - // get from session - $states = $this->session->get($this->stateVariableName); - - // one item - return $states[$service]; - } - - throw new AuthorizationStateNotFoundException('State not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - // get previously saved tokens - $states = $this->session->get($this->stateVariableName); - - if (!is_array($states)) { - $states = array(); - } - - $states[$service] = $state; - - // save - $this->session->set($this->stateVariableName, $states); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - // get from session - $states = $this->session->get($this->stateVariableName); - - return is_array($states) - && isset($states[$service]) - && null !== $states[$service]; - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - // get previously saved tokens - $states = $this->session->get($this->stateVariableName); - - if (is_array($states) && array_key_exists($service, $states)) { - unset($states[$service]); - - // Replace the stored tokens array - $this->session->set($this->stateVariableName, $states); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - $this->session->remove($this->stateVariableName); - - // allow chaining - return $this; - } - - /** - * @return Session - */ - public function getSession() - { - return $this->session; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php deleted file mode 100644 index 46552ce..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php +++ /dev/null @@ -1,98 +0,0 @@ -accessToken = $accessToken; - $this->refreshToken = $refreshToken; - $this->setLifetime($lifetime); - $this->extraParams = $extraParams; - } - - /** - * @return string - */ - public function getAccessToken() - { - return $this->accessToken; - } - - /** - * @return string - */ - public function getRefreshToken() - { - return $this->refreshToken; - } - - /** - * @return int - */ - public function getEndOfLife() - { - return $this->endOfLife; - } - - /** - * @param array $extraParams - */ - public function setExtraParams(array $extraParams) - { - $this->extraParams = $extraParams; - } - - /** - * @return array - */ - public function getExtraParams() - { - return $this->extraParams; - } - - /** - * @param string $accessToken - */ - public function setAccessToken($accessToken) - { - $this->accessToken = $accessToken; - } - - /** - * @param int $endOfLife - */ - public function setEndOfLife($endOfLife) - { - $this->endOfLife = $endOfLife; - } - - /** - * @param int $lifetime - */ - public function setLifetime($lifetime) - { - if (0 === $lifetime || static::EOL_NEVER_EXPIRES === $lifetime) { - $this->endOfLife = static::EOL_NEVER_EXPIRES; - } elseif (null !== $lifetime) { - $this->endOfLife = intval($lifetime) + time(); - } else { - $this->endOfLife = static::EOL_UNKNOWN; - } - } - - /** - * @param string $refreshToken - */ - public function setRefreshToken($refreshToken) - { - $this->refreshToken = $refreshToken; - } - - public function isExpired() - { - return ($this->getEndOfLife() !== TokenInterface::EOL_NEVER_EXPIRES - && $this->getEndOfLife() !== TokenInterface::EOL_UNKNOWN - && time() > $this->getEndOfLife()); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php deleted file mode 100644 index 26ad6cc..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php +++ /dev/null @@ -1,12 +0,0 @@ -signature = $signature; - $this->baseApiUri = $baseApiUri; - - $this->signature->setHashingAlgorithm($this->getSignatureMethod()); - } - - /** - * {@inheritDoc} - */ - public function requestRequestToken() - { - $authorizationHeader = array('Authorization' => $this->buildAuthorizationHeaderForTokenRequest()); - $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders()); - - $responseBody = $this->httpClient->retrieveResponse($this->getRequestTokenEndpoint(), array(), $headers); - - $token = $this->parseRequestTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($additionalParameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritDoc} - */ - public function requestAccessToken($token, $verifier, $tokenSecret = null) - { - if (is_null($tokenSecret)) { - $storedRequestToken = $this->storage->retrieveAccessToken($this->service()); - $tokenSecret = $storedRequestToken->getRequestTokenSecret(); - } - $this->signature->setTokenSecret($tokenSecret); - - $bodyParams = array( - 'oauth_verifier' => $verifier, - ); - - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest( - 'POST', - $this->getAccessTokenEndpoint(), - $this->storage->retrieveAccessToken($this->service()), - $bodyParams - ) - ); - - $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders()); - - $responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * Refreshes an OAuth1 access token - * @param TokenInterface $token - * @return TokenInterface $token - */ - public function refreshAccessToken(TokenInterface $token) - { - } - - /** - * Sends an authenticated API request to the path provided. - * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. - * - * @param string|UriInterface $path - * @param string $method HTTP method - * @param array $body Request body if applicable (key/value pairs) - * @param array $extraHeaders Extra headers if applicable. - * These will override service-specific any defaults. - * - * @return string - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri); - - /** @var $token StdOAuth1Token */ - $token = $this->storage->retrieveAccessToken($this->service()); - $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body) - ); - $headers = array_merge($authorizationHeader, $extraHeaders); - - return $this->httpClient->retrieveResponse($uri, $body, $headers, $method); - } - - /** - * Return any additional headers always needed for this service implementation's OAuth calls. - * - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array(); - } - - /** - * Return any additional headers always needed for this service implementation's API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array(); - } - - /** - * Builds the authorization header for getting an access or request token. - * - * @param array $extraParameters - * - * @return string - */ - protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = array()) - { - $parameters = $this->getBasicAuthorizationHeaderInfo(); - $parameters = array_merge($parameters, $extraParameters); - $parameters['oauth_signature'] = $this->signature->getSignature( - $this->getRequestTokenEndpoint(), - $parameters, - 'POST' - ); - - $authorizationHeader = 'OAuth '; - $delimiter = ''; - foreach ($parameters as $key => $value) { - $authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"'; - - $delimiter = ', '; - } - - return $authorizationHeader; - } - - /** - * Builds the authorization header for an authenticated API request - * - * @param string $method - * @param UriInterface $uri The uri the request is headed - * @param TokenInterface $token - * @param array $bodyParams Request body if applicable (key/value pairs) - * - * @return string - */ - protected function buildAuthorizationHeaderForAPIRequest( - $method, - UriInterface $uri, - TokenInterface $token, - $bodyParams = null - ) { - $this->signature->setTokenSecret($token->getAccessTokenSecret()); - $authParameters = $this->getBasicAuthorizationHeaderInfo(); - if (isset($authParameters['oauth_callback'])) { - unset($authParameters['oauth_callback']); - } - - $authParameters = array_merge($authParameters, array('oauth_token' => $token->getAccessToken())); - - $signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters; - $authParameters['oauth_signature'] = $this->signature->getSignature($uri, $signatureParams, $method); - - if (isset($bodyParams['oauth_session_handle'])) { - $authParameters['oauth_session_handle'] = $bodyParams['oauth_session_handle']; - unset($bodyParams['oauth_session_handle']); - } - - $authorizationHeader = 'OAuth '; - $delimiter = ''; - - foreach ($authParameters as $key => $value) { - $authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"'; - $delimiter = ', '; - } - - return $authorizationHeader; - } - - /** - * Builds the authorization header array. - * - * @return array - */ - protected function getBasicAuthorizationHeaderInfo() - { - $dateTime = new \DateTime(); - $headerParameters = array( - 'oauth_callback' => $this->credentials->getCallbackUrl(), - 'oauth_consumer_key' => $this->credentials->getConsumerId(), - 'oauth_nonce' => $this->generateNonce(), - 'oauth_signature_method' => $this->getSignatureMethod(), - 'oauth_timestamp' => $dateTime->format('U'), - 'oauth_version' => $this->getVersion(), - ); - - return $headerParameters; - } - - /** - * Pseudo random string generator used to build a unique string to sign each request - * - * @param int $length - * - * @return string - */ - protected function generateNonce($length = 32) - { - $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; - - $nonce = ''; - $maxRand = strlen($characters)-1; - for ($i = 0; $i < $length; $i++) { - $nonce.= $characters[rand(0, $maxRand)]; - } - - return $nonce; - } - - /** - * @return string - */ - protected function getSignatureMethod() - { - return 'HMAC-SHA1'; - } - - /** - * This returns the version used in the authorization header of the requests - * - * @return string - */ - protected function getVersion() - { - return '1.0'; - } - - /** - * Parses the request token response and returns a TokenInterface. - * This is only needed to verify the `oauth_callback_confirmed` parameter. The actual - * parsing logic is contained in the access token parser. - * - * @abstract - * - * @param string $responseBody - * - * @return TokenInterface - * - * @throws TokenResponseException - */ - abstract protected function parseRequestTokenResponse($responseBody); - - /** - * Parses the access token response and returns a TokenInterface. - * - * @abstract - * - * @param string $responseBody - * - * @return TokenInterface - * - * @throws TokenResponseException - */ - abstract protected function parseAccessTokenResponse($responseBody); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php deleted file mode 100644 index f6d8edf..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php +++ /dev/null @@ -1,96 +0,0 @@ -baseApiUri = new Uri('https://bitbucket.org/api/1.0/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://bitbucket.org/!api/1.0/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://bitbucket.org/!api/1.0/oauth/authenticate'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://bitbucket.org/!api/1.0/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php deleted file mode 100644 index 30dc331..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php +++ /dev/null @@ -1,132 +0,0 @@ -baseApiUri = new Uri('https://openapi.etsy.com/v2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - $uri = new Uri($this->baseApiUri . 'oauth/request_token'); - $scopes = $this->getScopes(); - - if (count($scopes)) { - $uri->setQuery('scope=' . implode('%20', $scopes)); - } - - return $uri; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri($this->baseApiUri); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri($this->baseApiUri . 'oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } - - /** - * Set the scopes for permissions - * @see https://www.etsy.com/developers/documentation/getting_started/oauth#section_permission_scopes - * @param array $scopes - * - * @return $this - */ - public function setScopes(array $scopes) - { - if (!is_array($scopes)) { - $scopes = array(); - } - - $this->scopes = $scopes; - return $this; - } - - /** - * Return the defined scopes - * @return array - */ - public function getScopes() - { - return $this->scopes; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php deleted file mode 100644 index 78032d7..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php +++ /dev/null @@ -1,96 +0,0 @@ -baseApiUri = new Uri('https://api.fitbit.com/1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.fitbit.com/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.fitbit.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.fitbit.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php deleted file mode 100644 index ea7f9b3..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developers.500px.com/ - */ - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -/** - * 500px service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developers.500px.com/ - */ -class FiveHundredPx extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $signature, - $baseApiUri - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.500px.com/v1/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.500px.com/v1/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.500px.com/v1/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.500px.com/v1/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) - || $data['oauth_callback_confirmed'] !== 'true' - ) { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php deleted file mode 100644 index 7ceee7d..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php +++ /dev/null @@ -1,133 +0,0 @@ -baseApiUri = new Uri('https://api.flickr.com/services/rest/'); - } - } - - public function getRequestTokenEndpoint() - { - return new Uri('https://www.flickr.com/services/oauth/request_token'); - } - - public function getAuthorizationEndpoint() - { - return new Uri('https://www.flickr.com/services/oauth/authorize'); - } - - public function getAccessTokenEndpoint() - { - return new Uri('https://www.flickr.com/services/oauth/access_token'); - } - - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - return $this->parseAccessTokenResponse($responseBody); - } - - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - if ($data === null || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } - - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath('/', $this->baseApiUri); - $uri->addToQuery('method', $path); - - if (!empty($this->format)) { - $uri->addToQuery('format', $this->format); - - if ($this->format === 'json') { - $uri->addToQuery('nojsoncallback', 1); - } - } - - $token = $this->storage->retrieveAccessToken($this->service()); - $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body) - ); - $headers = array_merge($authorizationHeader, $extraHeaders); - - return $this->httpClient->retrieveResponse($uri, $body, $headers, $method); - } - - public function requestRest($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - return $this->request($path, $method, $body, $extraHeaders); - } - - public function requestXmlrpc($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $this->format = 'xmlrpc'; - - return $this->request($path, $method, $body, $extraHeaders); - } - - public function requestSoap($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $this->format = 'soap'; - - return $this->request($path, $method, $body, $extraHeaders); - } - - public function requestJson($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $this->format = 'json'; - - return $this->request($path, $method, $body, $extraHeaders); - } - - public function requestPhp($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $this->format = 'php_serial'; - - return $this->request($path, $method, $body, $extraHeaders); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php deleted file mode 100644 index 0014ca8..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php +++ /dev/null @@ -1,120 +0,0 @@ -baseApiUri = new Uri('https://quickbooks.api.intuit.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://oauth.intuit.com/oauth/v1/get_request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://appcenter.intuit.com/Connect/Begin'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://oauth.intuit.com/oauth/v1/get_access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) - || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - $message = 'Error in retrieving token: "' . $data['error'] . '"'; - throw new TokenResponseException($message); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritDoc} - */ - public function request( - $path, - $method = 'GET', - $body = null, - array $extraHeaders = array() - ) { - $extraHeaders['Accept'] = 'application/json'; - return parent::request($path, $method, $body, $extraHeaders); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php deleted file mode 100644 index 55f89a2..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php +++ /dev/null @@ -1,96 +0,0 @@ -baseApiUri->getAbsoluteUri() . '/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri($this->baseApiUri->getAbsoluteUri() . '/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri($this->baseApiUri->getAbsoluteUri() . '/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php deleted file mode 100644 index 28bd250..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php +++ /dev/null @@ -1,96 +0,0 @@ -baseApiUri = new Uri('https://www.scoop.it/api/1/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://www.scoop.it/oauth/request'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.scoop.it/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.scoop.it/oauth/access'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php deleted file mode 100644 index 3f91fbf..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php +++ /dev/null @@ -1,45 +0,0 @@ -baseApiUri = new Uri('https://api.tumblr.com/v2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://www.tumblr.com/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.tumblr.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.tumblr.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php deleted file mode 100644 index dea680f..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php +++ /dev/null @@ -1,123 +0,0 @@ -baseApiUri = new Uri('https://api.twitter.com/1.1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.twitter.com/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - if ($this->authorizationEndpoint != self::ENDPOINT_AUTHENTICATE - && $this->authorizationEndpoint != self::ENDPOINT_AUTHORIZE) { - $this->authorizationEndpoint = self::ENDPOINT_AUTHENTICATE; - } - return new Uri($this->authorizationEndpoint); - } - - /** - * @param string $authorizationEndpoint - * - * @throws Exception - */ - public function setAuthorizationEndpoint($endpoint) - { - if ($endpoint != self::ENDPOINT_AUTHENTICATE && $endpoint != self::ENDPOINT_AUTHORIZE) { - throw new Exception( - sprintf("'%s' is not a correct Twitter authorization endpoint.", $endpoint) - ); - } - $this->authorizationEndpoint = $endpoint; - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.twitter.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response: ' . $responseBody); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } elseif (!isset($data["oauth_token"]) || !isset($data["oauth_token_secret"])) { - throw new TokenResponseException('Invalid response. OAuth Token data not set: ' . $responseBody); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php deleted file mode 100644 index e6824db..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php +++ /dev/null @@ -1,97 +0,0 @@ -baseApiUri = new Uri('https://api.xing.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.xing.com/v1/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.xing.com/v1/access_token'); - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.xing.com/v1/request_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - $errors = json_decode($responseBody); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif ($errors) { - throw new TokenResponseException('Error in retrieving token: "' . $errors->error_name . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php deleted file mode 100644 index 50a825b..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php +++ /dev/null @@ -1,131 +0,0 @@ -baseApiUri = new Uri('https://social.yahooapis.com/v1/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.login.yahoo.com/oauth/v2/get_request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.login.yahoo.com/oauth/v2/request_auth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.login.yahoo.com/oauth/v2/get_token'); - } - - /** - * {@inheritdoc} - */ - public function refreshAccessToken(TokenInterface $token) - { - $extraParams = $token->getExtraParams(); - $bodyParams = array('oauth_session_handle' => $extraParams['oauth_session_handle']); - - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest( - 'POST', - $this->getAccessTokenEndpoint(), - $this->storage->retrieveAccessToken($this->service()), - $bodyParams - ) - ); - - - - $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders(), array()); - - $responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - if (isset($data['oauth_expires_in'])) { - $token->setLifetime($data['oauth_expires_in']); - } else { - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - } - - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php deleted file mode 100644 index 44c36ce..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php +++ /dev/null @@ -1,12 +0,0 @@ -credentials = $credentials; - } - - /** - * @param string $algorithm - */ - public function setHashingAlgorithm($algorithm) - { - $this->algorithm = $algorithm; - } - - /** - * @param string $token - */ - public function setTokenSecret($token) - { - $this->tokenSecret = $token; - } - - /** - * @param UriInterface $uri - * @param array $params - * @param string $method - * - * @return string - */ - public function getSignature(UriInterface $uri, array $params, $method = 'POST') - { - parse_str($uri->getQuery(), $queryStringData); - - foreach (array_merge($queryStringData, $params) as $key => $value) { - $signatureData[rawurlencode($key)] = rawurlencode($value); - } - - ksort($signatureData); - - // determine base uri - $baseUri = $uri->getScheme() . '://' . $uri->getRawAuthority(); - - if ('/' === $uri->getPath()) { - $baseUri .= $uri->hasExplicitTrailingHostSlash() ? '/' : ''; - } else { - $baseUri .= $uri->getPath(); - } - - $baseString = strtoupper($method) . '&'; - $baseString .= rawurlencode($baseUri) . '&'; - $baseString .= rawurlencode($this->buildSignatureDataString($signatureData)); - - return base64_encode($this->hash($baseString)); - } - - /** - * @param array $signatureData - * - * @return string - */ - protected function buildSignatureDataString(array $signatureData) - { - $signatureString = ''; - $delimiter = ''; - foreach ($signatureData as $key => $value) { - $signatureString .= $delimiter . $key . '=' . $value; - - $delimiter = '&'; - } - - return $signatureString; - } - - /** - * @return string - */ - protected function getSigningKey() - { - $signingKey = rawurlencode($this->credentials->getConsumerSecret()) . '&'; - if ($this->tokenSecret !== null) { - $signingKey .= rawurlencode($this->tokenSecret); - } - - return $signingKey; - } - - /** - * @param string $data - * - * @return string - * - * @throws UnsupportedHashAlgorithmException - */ - protected function hash($data) - { - switch (strtoupper($this->algorithm)) { - case 'HMAC-SHA1': - return hash_hmac('sha1', $data, $this->getSigningKey(), true); - default: - throw new UnsupportedHashAlgorithmException( - 'Unsupported hashing algorithm (' . $this->algorithm . ') used.' - ); - } - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php deleted file mode 100644 index da50ddb..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -requestToken = $requestToken; - } - - /** - * @return string - */ - public function getRequestToken() - { - return $this->requestToken; - } - - /** - * @param string $requestTokenSecret - */ - public function setRequestTokenSecret($requestTokenSecret) - { - $this->requestTokenSecret = $requestTokenSecret; - } - - /** - * @return string - */ - public function getRequestTokenSecret() - { - return $this->requestTokenSecret; - } - - /** - * @param string $accessTokenSecret - */ - public function setAccessTokenSecret($accessTokenSecret) - { - $this->accessTokenSecret = $accessTokenSecret; - } - - /** - * @return string - */ - public function getAccessTokenSecret() - { - return $this->accessTokenSecret; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php deleted file mode 100644 index 0bc3f73..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php +++ /dev/null @@ -1,41 +0,0 @@ -stateParameterInAuthUrl = $stateParameterInAutUrl; - - foreach ($scopes as $scope) { - if (!$this->isValidScope($scope)) { - throw new InvalidScopeException('Scope ' . $scope . ' is not valid for service ' . get_class($this)); - } - } - - $this->scopes = $scopes; - - $this->baseApiUri = $baseApiUri; - - $this->apiVersion = $apiVersion; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode($this->getScopesDelimiter(), $this->scopes); - - if ($this->needsStateParameterInAuthUrl()) { - if (!isset($parameters['state'])) { - $parameters['state'] = $this->generateAuthorizationState(); - } - $this->storeAuthorizationState($parameters['state']); - } - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function requestAccessToken($code, $state = null) - { - if (null !== $state) { - $this->validateAuthorizationState($state); - } - - $bodyParams = array( - 'code' => $code, - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'grant_type' => 'authorization_code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * Sends an authenticated API request to the path provided. - * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. - * - * @param string|UriInterface $path - * @param string $method HTTP method - * @param array $body Request body if applicable. - * @param array $extraHeaders Extra headers if applicable. These will override service-specific - * any defaults. - * - * @return string - * - * @throws ExpiredTokenException - * @throws Exception - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri); - $token = $this->storage->retrieveAccessToken($this->service()); - - if ($token->getEndOfLife() !== TokenInterface::EOL_NEVER_EXPIRES - && $token->getEndOfLife() !== TokenInterface::EOL_UNKNOWN - && time() > $token->getEndOfLife() - ) { - throw new ExpiredTokenException( - sprintf( - 'Token expired on %s at %s', - date('m/d/Y', $token->getEndOfLife()), - date('h:i:s A', $token->getEndOfLife()) - ) - ); - } - - // add the token where it may be needed - if (static::AUTHORIZATION_METHOD_HEADER_OAUTH === $this->getAuthorizationMethod()) { - $extraHeaders = array_merge(array('Authorization' => 'OAuth ' . $token->getAccessToken()), $extraHeaders); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING === $this->getAuthorizationMethod()) { - $uri->addToQuery('access_token', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V2 === $this->getAuthorizationMethod()) { - $uri->addToQuery('oauth2_access_token', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V3 === $this->getAuthorizationMethod()) { - $uri->addToQuery('apikey', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V4 === $this->getAuthorizationMethod()) { - $uri->addToQuery('auth', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_HEADER_BEARER === $this->getAuthorizationMethod()) { - $extraHeaders = array_merge(array('Authorization' => 'Bearer ' . $token->getAccessToken()), $extraHeaders); - } - - $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); - - return $this->httpClient->retrieveResponse($uri, $body, $extraHeaders, $method); - } - - /** - * Accessor to the storage adapter to be able to retrieve tokens - * - * @return TokenStorageInterface - */ - public function getStorage() - { - return $this->storage; - } - - /** - * Refreshes an OAuth2 access token. - * - * @param TokenInterface $token - * - * @return TokenInterface $token - * - * @throws MissingRefreshTokenException - */ - public function refreshAccessToken(TokenInterface $token) - { - $refreshToken = $token->getRefreshToken(); - - if (empty($refreshToken)) { - throw new MissingRefreshTokenException(); - } - - $parameters = array( - 'grant_type' => 'refresh_token', - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'refresh_token' => $refreshToken, - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $parameters, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * Return whether or not the passed scope value is valid. - * - * @param string $scope - * - * @return bool - */ - public function isValidScope($scope) - { - $reflectionClass = new \ReflectionClass(get_class($this)); - - return in_array($scope, $reflectionClass->getConstants(), true); - } - - /** - * Check if the given service need to generate a unique state token to build the authorization url - * - * @return bool - */ - public function needsStateParameterInAuthUrl() - { - return $this->stateParameterInAuthUrl; - } - - /** - * Validates the authorization state against a given one - * - * @param string $state - * @throws InvalidAuthorizationStateException - */ - protected function validateAuthorizationState($state) - { - if ($this->retrieveAuthorizationState() !== $state) { - throw new InvalidAuthorizationStateException(); - } - } - - /** - * Generates a random string to be used as state - * - * @return string - */ - protected function generateAuthorizationState() - { - return md5(rand()); - } - - /** - * Retrieves the authorization state for the current service - * - * @return string - */ - protected function retrieveAuthorizationState() - { - return $this->storage->retrieveAuthorizationState($this->service()); - } - - /** - * Stores a given authorization state into the storage - * - * @param string $state - */ - protected function storeAuthorizationState($state) - { - $this->storage->storeAuthorizationState($this->service(), $state); - } - - /** - * Return any additional headers always needed for this service implementation's OAuth calls. - * - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array(); - } - - /** - * Return any additional headers always needed for this service implementation's API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array(); - } - - /** - * Parses the access token response and returns a TokenInterface. - * - * @abstract - * - * @param string $responseBody - * - * @return TokenInterface - * - * @throws TokenResponseException - */ - abstract protected function parseAccessTokenResponse($responseBody); - - /** - * Returns a class constant from ServiceInterface defining the authorization method used for the API - * Header is the sane default. - * - * @return int - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_OAUTH; - } - - /** - * Returns api version string if is set else retrun empty string - * - * @return string - */ - protected function getApiVersionString() - { - return !(empty($this->apiVersion)) ? "/".$this->apiVersion : "" ; - } - - /** - * Returns delimiter to scopes in getAuthorizationUri - * For services that do not fully respect the Oauth's RFC, - * and use scopes with commas as delimiter - * - * @return string - */ - protected function getScopesDelimiter() - { - return ' '; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php deleted file mode 100644 index 035d1a5..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @link https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-developer-guide._TTH_.pdf - */ -class Amazon extends AbstractService -{ - /** - * Defined scopes - * @link https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-developer-guide._TTH_.pdf - */ - const SCOPE_PROFILE = 'profile'; - const SCOPE_POSTAL_CODE = 'postal_code'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.amazon.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.amazon.com/ap/oa'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.amazon.com/ap/oatoken'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error_description'] . '"'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php deleted file mode 100644 index e01cbc4..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php +++ /dev/null @@ -1,111 +0,0 @@ -baseApiUri = new Uri('https://api-ssl.bitly.com/v3/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://bitly.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api-ssl.bitly.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // I'm invincible!!! - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function requestAccessToken($code, $state = null) - { - if (null !== $state) { - $this->validateAuthorizationState($state); - } - - $bodyParams = array( - 'code' => $code, - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'grant_type' => 'authorization_code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - - // we can scream what we want that we want bitly to return a json encoded string (format=json), but the - // WOAH WATCH YOUR LANGUAGE ;) service doesn't seem to like screaming, hence we need to manually - // parse the result - $parsedResult = array(); - parse_str($responseBody, $parsedResult); - - $token = $this->parseAccessTokenResponse(json_encode($parsedResult)); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitrix24.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitrix24.php deleted file mode 100644 index 1630d30..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitrix24.php +++ /dev/null @@ -1,118 +0,0 @@ -baseApiUri)); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri(sprintf('%s/oauth/token/', $this->baseApiUri)); - } - - /** - * {@inheritdoc} - */ - public function requestAccessToken($code, $state = null) - { - if (null !== $state) { - $this->validateAuthorizationState($state); - } - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenUri($code), - array(), - $this->getExtraOAuthHeaders(), - 'GET' - ); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenUri($code) - { - $parameters = array( - 'code' => $code, - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'grant_type' => 'authorization_code', - 'scope' => $this->scopes - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - // Build the url - $url = $this->getAccessTokenEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php deleted file mode 100644 index 14696c5..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @link https://developers.box.com/oauth/ - */ -class Box extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.box.com/2.0/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.box.com/api/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.box.com/api/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php deleted file mode 100644 index 5905678..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @link https://bufferapp.com/developers/api - */ -class Buffer extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - if ($baseApiUri === null) { - $this->baseApiUri = new Uri('https://api.bufferapp.com/1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://bufferapp.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.bufferapp.com/1/oauth2/token.json'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function requestRequestToken() - { - $responseBody = $this->httpClient->retrieveResponse( - $this->getRequestTokenEndpoint(), - array( - 'client_key' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $code = $this->parseRequestTokenResponse($responseBody); - - return $code; - } - - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['code'])) { - throw new TokenResponseException('Error in retrieving code.'); - } - return $data['code']; - } - - public function requestAccessToken($code) - { - $bodyParams = array( - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'code' => $code, - 'grant_type' => 'authorization_code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if ($data === null || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php deleted file mode 100644 index 095a467..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @link http://www.dailymotion.com/doc/api/authentication.html - */ -class Dailymotion extends AbstractService -{ - /** - * Scopes - * - * @var string - */ - const SCOPE_EMAIL = 'email', - SCOPE_PROFILE = 'userinfo', - SCOPE_VIDEOS = 'manage_videos', - SCOPE_COMMENTS = 'manage_comments', - SCOPE_PLAYLIST = 'manage_playlists', - SCOPE_TILES = 'manage_tiles', - SCOPE_SUBSCRIPTIONS = 'manage_subscriptions', - SCOPE_FRIENDS = 'manage_friends', - SCOPE_FAVORITES = 'manage_favorites', - SCOPE_GROUPS = 'manage_groups'; - - /** - * Dialog form factors - * - * @var string - */ - const DISPLAY_PAGE = 'page', - DISPLAY_POPUP = 'popup', - DISPLAY_MOBILE = 'mobile'; - - /** - * {@inheritdoc} - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.dailymotion.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.dailymotion.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.dailymotion.com/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_OAUTH; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description']) || isset($data['error'])) { - throw new TokenResponseException( - sprintf( - 'Error in retrieving token: "%s"', - isset($data['error_description']) ? $data['error_description'] : $data['error'] - ) - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Deezer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Deezer.php deleted file mode 100644 index 3e3965b..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Deezer.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://developers.deezer.com/api/ - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Deezer service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://developers.deezer.com/api/ - */ -class Deezer extends AbstractService -{ - /** - * Defined scopes - * http://developers.deezer.com/api/permissions - */ - const SCOPE_BASIC_ACCESS = 'basic_access'; // Access users basic information - const SCOPE_EMAIL = 'email'; // Get the user's email - const SCOPE_OFFLINE_ACCESS = 'offline_access'; // Access user data any time - const SCOPE_MANAGE_LIBRARY = 'manage_library'; // Manage users' library - const SCOPE_MANAGE_COMMUNITY = 'manage_community'; // Manage users' friends - const SCOPE_DELETE_LIBRARY = 'delete_library'; // Delete library items - const SCOPE_LISTENING_HISTORY = 'listening_history'; // Access the user's listening history - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.deezer.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://connect.deezer.com/oauth/auth.php'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://connect.deezer.com/oauth/access_token.php'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - if (null === $data || !is_array($data) || empty($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } elseif (isset($data['error_reason'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error_reason'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires']); - - // I hope one day Deezer add a refresh token :) - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Delicious.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Delicious.php deleted file mode 100644 index eba6035..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Delicious.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://github.com/SciDevs/delicious-api/blob/master/api/oauth.md - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Delicious service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://github.com/SciDevs/delicious-api/blob/master/api/oauth.md - */ -class Delicious extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.del.icio.us/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://delicious.com/auth/authorize'); - - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://avosapi.delicious.com/api/v1/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifetime($data['expires_in']); - unset($data['expires_in']); - } - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - - // Special, delicious didn't respect the oauth2 RFC and need a grant_type='code' - /** - * {@inheritdoc} - */ - public function requestAccessToken($code, $state = null) - { - if (null !== $state) { - $this->validateAuthorizationState($state); - } - - $bodyParams = array( - 'code' => $code, - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'grant_type' => 'code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/DeviantArt.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/DeviantArt.php deleted file mode 100644 index 31e94b4..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/DeviantArt.php +++ /dev/null @@ -1,99 +0,0 @@ -baseApiUri = new Uri('https://www.deviantart.com/api/v1/oauth2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.deviantart.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.deviantart.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifeTime($data['expires_in']); - } - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php deleted file mode 100644 index 43ec6c7..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @link https://www.dropbox.com/developers/core/docs - */ -class Dropbox extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.dropbox.com/1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.dropbox.com/1/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.dropbox.com/1/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/EveOnline.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/EveOnline.php deleted file mode 100644 index 76fafa6..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/EveOnline.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ -namespace OAuth\OAuth2\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Token\TokenInterface; -use OAuth\OAuth2\Token\StdOAuth2Token; - -/** - * Class EveOnline - */ -class EveOnline extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://login.eveonline.com'); - } - } - - /** - * Returns the authorization API endpoint. - * @return UriInterface - */ - public function getAuthorizationEndpoint() - { - return new Uri($this->baseApiUri . '/oauth/authorize'); - } - - /** - * Returns the access token API endpoint. - * @return UriInterface - */ - public function getAccessTokenEndpoint() - { - return new Uri($this->baseApiUri . '/oauth/token'); - } - - /** - * Parses the access token response and returns a TokenInterface. - * - * @param string $responseBody - * - * @return TokenInterface - * @throws TokenResponseException - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error_description'] . '"'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php deleted file mode 100644 index 398df2f..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php +++ /dev/null @@ -1,12 +0,0 @@ - - * Released under the MIT license. - */ - -namespace OAuth\OAuth2\Service\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception thrown when a scope provided to a service is invalid. - */ -class InvalidScopeException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php deleted file mode 100644 index 21eece6..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php +++ /dev/null @@ -1,17 +0,0 @@ - - * Released under the MIT license. - */ - -namespace OAuth\OAuth2\Service\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception thrown when service is requested to refresh the access token but no refresh token can be found. - */ -class MissingRefreshTokenException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php deleted file mode 100644 index 308513b..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php +++ /dev/null @@ -1,208 +0,0 @@ -baseApiUri = new Uri('https://graph.facebook.com'.$this->getApiVersionString().'/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.facebook.com'.$this->getApiVersionString().'/dialog/oauth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://graph.facebook.com'.$this->getApiVersionString().'/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ? - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires'])) { - $token->setLifeTime($data['expires']); - } - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires']); - - $token->setExtraParams($data); - - return $token; - } - - public function getDialogUri($dialogPath, array $parameters) - { - if (!isset($parameters['redirect_uri'])) { - throw new Exception("Redirect uri is mandatory for this request"); - } - $parameters['app_id'] = $this->credentials->getConsumerId(); - $baseUrl = self::WWW_URL .$this->getApiVersionString(). '/dialog/' . $dialogPath; - $query = http_build_query($parameters); - return new Uri($baseUrl . '?' . $query); - } - - /** - * {@inheritdoc} - */ - protected function getScopesDelimiter() - { - return ','; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php deleted file mode 100644 index 981ff44..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php +++ /dev/null @@ -1,81 +0,0 @@ -baseApiUri = new Uri('https://api.foursquare.com/v2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://foursquare.com/oauth2/authenticate'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://foursquare.com/oauth2/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Foursquare tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri); - $uri->addToQuery('v', $this->apiVersionDate); - - return parent::request($uri, $method, $body, $extraHeaders); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php deleted file mode 100644 index 8d4d122..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php +++ /dev/null @@ -1,216 +0,0 @@ -baseApiUri = new Uri('https://api.github.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://github.com/login/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://github.com/login/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Github tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * Used to configure response type -- we want JSON from github, default is query string format - * - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } - - /** - * Required for GitHub API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array('Accept' => 'application/vnd.github.beta+json'); - } - - /** - * {@inheritdoc} - */ - protected function getScopesDelimiter() - { - return ','; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php deleted file mode 100644 index 8fa556a..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php +++ /dev/null @@ -1,190 +0,0 @@ -baseApiUri = new Uri('https://www.googleapis.com/oauth2/v1/'); - } - } - - public function setAccessType($accessType) - { - if (!in_array($accessType, array('online', 'offline'), true)) { - throw new InvalidAccessTypeException('Invalid accessType, expected either online or offline'); - } - $this->accessType = $accessType; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://accounts.google.com/o/oauth2/auth?access_type=' . $this->accessType); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://accounts.google.com/o/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php deleted file mode 100644 index 96fb0f2..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php +++ /dev/null @@ -1,157 +0,0 @@ -baseApiUri = new Uri('https://api.harvestapp.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'state' => 'optional-csrf-token', - 'response_type' => 'code', - ) - ); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.harvestapp.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.harvestapp.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || ! is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - $token->setRefreshToken($data['refresh_token']); - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * Refreshes an OAuth2 access token. - * - * @param TokenInterface $token - * - * @return TokenInterface $token - * - * @throws MissingRefreshTokenException - */ - public function refreshAccessToken(TokenInterface $token) - { - $refreshToken = $token->getRefreshToken(); - - if (empty($refreshToken)) { - throw new MissingRefreshTokenException(); - } - - $parameters = array( - 'grant_type' => 'refresh_token', - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'refresh_token' => $refreshToken, - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $parameters, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } - - /** - * Return any additional headers always needed for this service implementation's API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array('Accept' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php deleted file mode 100644 index 470cedc..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @link https://devcenter.heroku.com/articles/oauth - */ -class Heroku extends AbstractService -{ - /** - * Defined scopes - * @link https://devcenter.heroku.com/articles/oauth#scopes - */ - const SCOPE_GLOBAL = 'global'; - const SCOPE_IDENTITY = 'identity'; - const SCOPE_READ = 'read'; - const SCOPE_WRITE = 'write'; - const SCOPE_READ_PROTECTED = 'read-protected'; - const SCOPE_WRITE_PROTECTED = 'write-protected'; - - /** - * {@inheritdoc} - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.heroku.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://id.heroku.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://id.heroku.com/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description']) || isset($data['error'])) { - throw new TokenResponseException( - sprintf( - 'Error in retrieving token: "%s"', - isset($data['error_description']) ? $data['error_description'] : $data['error'] - ) - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/vnd.heroku+json; version=3'); - } - - /** - * {@inheritdoc} - */ - protected function getExtraApiHeaders() - { - return array('Accept' => 'application/vnd.heroku+json; version=3', 'Content-Type' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Hubic.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Hubic.php deleted file mode 100644 index b995450..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Hubic.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://api.hubic.com/docs/ - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Hubic service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://api.hubic.com/docs/ - */ -class Hubic extends AbstractService -{ - - // Scopes - const SCOPE_USAGE_GET = 'usage.r'; - const SCOPE_ACCOUNT_GET = 'account.r'; - const SCOPE_GETALLLINKS_GET = 'getAllLinks.r'; - const SCOPE_CREDENTIALS_GET = 'credentials.r'; - const SCOPE_SPONSORCODE_GET = 'sponsorCode.r'; - const SCOPE_ACTIVATE_POST = 'activate.w'; - const SCOPE_SPONSORED_GET = 'sponsored.r'; - const SCOPE_LINKS_GET = 'links.r'; - const SCOPE_LINKS_POST = 'links.rw'; - const SCOPE_LINKS_ALL = 'links.drw'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.hubic.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.hubic.com/oauth/auth'); - - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.hubic.com/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - // special, hubic use a param scope with commas - // between scopes instead of spaces - $parameters['scope'] = implode(',', $this->scopes); - - if ($this->needsStateParameterInAuthUrl()) { - if (!isset($parameters['state'])) { - $parameters['state'] = $this->generateAuthorizationState(); - } - $this->storeAuthorizationState($parameters['state']); - } - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php deleted file mode 100644 index c60c455..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php +++ /dev/null @@ -1,85 +0,0 @@ -baseApiUri = new Uri('https://api.instagram.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.instagram.com/oauth/authorize/'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.instagram.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Instagram tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/JawboneUP.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/JawboneUP.php deleted file mode 100644 index fad1125..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/JawboneUP.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @link https://jawbone.com/up/developer/authentication - */ -class JawboneUP extends AbstractService -{ - /** - * Defined scopes - * - * - * @link https://jawbone.com/up/developer/authentication - */ - // general information scopes - const SCOPE_BASIC_READ = 'basic_read'; - const SCOPE_EXTENDED_READ = 'extended_read'; - const SCOPE_LOCATION_READ = 'location_read'; - const SCOPE_FRIENDS_READ = 'friends_read'; - // mood scopes - const SCOPE_MOOD_READ = 'mood_read'; - const SCOPE_MOOD_WRITE = 'mood_write'; - // move scopes - const SCOPE_MOVE_READ = 'move_read'; - const SCOPE_MOVE_WRITE = 'move_write'; - // sleep scopes - const SCOPE_SLEEP_READ = 'sleep_read'; - const SCOPE_SLEEP_WRITE = 'sleep_write'; - // meal scopes - const SCOPE_MEAL_READ = 'meal_read'; - const SCOPE_MEAL_WRITE = 'meal_write'; - // weight scopes - const SCOPE_WEIGHT_READ = 'weight_read'; - const SCOPE_WEIGHT_WRITE = 'weight_write'; - // generic event scopes - const SCOPE_GENERIC_EVENT_READ = 'generic_event_read'; - const SCOPE_GENERIC_EVENT_WRITE = 'generic_event_write'; - - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://jawbone.com/nudge/api/v.1.1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://jawbone.com/auth/oauth2/auth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://jawbone.com/auth/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php deleted file mode 100644 index 65cfd94..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @link http://developer.linkedin.com/documents/authentication - */ -class Linkedin extends AbstractService -{ - /** - * Defined scopes - * @link http://developer.linkedin.com/documents/authentication#granting - */ - const SCOPE_R_BASICPROFILE = 'r_basicprofile'; - const SCOPE_R_FULLPROFILE = 'r_fullprofile'; - const SCOPE_R_EMAILADDRESS = 'r_emailaddress'; - const SCOPE_R_NETWORK = 'r_network'; - const SCOPE_R_CONTACTINFO = 'r_contactinfo'; - const SCOPE_RW_NUS = 'rw_nus'; - const SCOPE_RW_COMPANY_ADMIN = 'rw_company_admin'; - const SCOPE_RW_GROUPS = 'rw_groups'; - const SCOPE_W_MESSAGES = 'w_messages'; - const SCOPE_W_SHARE = 'w_share'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.linkedin.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.linkedin.com/uas/oauth2/authorization'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.linkedin.com/uas/oauth2/accessToken'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php deleted file mode 100644 index 842153d..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php +++ /dev/null @@ -1,114 +0,0 @@ -baseApiUri) && $storage->hasAccessToken($this->service())) { - $this->setBaseApiUri($storage->retrieveAccessToken($this->service())); - } - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING_V3; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://login.mailchimp.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://login.mailchimp.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - // Parse JSON - $data = json_decode($responseBody, true); - - // Do validation. - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - // Create token object. - $token = new StdOAuth2Token($data['access_token']); - - // Set the right API endpoint. - $this->setBaseApiUri($token); - - // Mailchimp tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - if (is_null($this->baseApiUri)) { - $this->setBaseApiUri($this->storage->retrieveAccessToken($this->service())); - } - - return parent::request($path, $method, $body, $extraHeaders); - } - - /** - * Set the right base endpoint. - * - * @param StdOAuth2Token $token - */ - protected function setBaseApiUri(StdOAuth2Token $token) - { - // Make request uri. - $endpoint = 'https://login.mailchimp.com/oauth2/metadata?oauth_token='. $token->getAccessToken(); - - // Grab meta data about the token. - $response = $this->httpClient->retrieveResponse(new Uri($endpoint), array(), array(), 'GET'); - - // Parse JSON. - $meta = json_decode($response, true); - - // Set base api uri. - $this->baseApiUri = new Uri('https://'. $meta['dc'] .'.api.mailchimp.com/2.0/'); - - // Allow chaining. - return $this; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php deleted file mode 100644 index c815b22..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php +++ /dev/null @@ -1,120 +0,0 @@ -baseApiUri = new Uri('https://apis.live.net/v5.0/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://login.live.com/oauth20_authorize.srf'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://login.live.com/oauth20_token.srf'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Nest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Nest.php deleted file mode 100644 index 7659e4f..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Nest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developer.nest.com/documentation - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Nest service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developer.nest.com/documentation - */ -class Nest extends AbstractService -{ - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://developer-api.nest.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://home.nest.com/login/oauth2'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.home.nest.com/oauth2/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING_V4; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Netatmo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Netatmo.php deleted file mode 100644 index eb5c68d..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Netatmo.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://dev.netatmo.com/doc/ - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Netatmo service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://dev.netatmo.com/doc/ - */ -class Netatmo extends AbstractService -{ - - // SCOPES - // @link https://dev.netatmo.com/doc/authentication/scopes - - // Used to read weather station's data (devicelist, getmeasure) - const SCOPE_STATION_READ = 'read_station'; - // Used to read thermostat's data (devicelist, getmeasure, getthermstate) - const SCOPE_THERMOSTAT_READ = 'read_thermostat'; - // Used to configure the thermostat (syncschedule, setthermpoint) - const SCOPE_THERMOSTAT_WRITE = 'write_thermostat'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true // use parameter state - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.netatmo.net/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri($this->baseApiUri.'oauth2/authorize'); - - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri($this->baseApiUri.'oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ParrotFlowerPower.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ParrotFlowerPower.php deleted file mode 100644 index 78ef942..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ParrotFlowerPower.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://flowerpowerdev.parrot.com/projects/flower-power-web-service-api/wiki - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\OAuth2\Service\Exception\MissingRefreshTokenException; -use OAuth\Common\Token\TokenInterface; - -/** - * ParrotFlowerPower service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://flowerpowerdev.parrot.com/projects/flower-power-web-service-api/wiki - */ -class ParrotFlowerPower extends AbstractService -{ - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://apiflowerpower.parrot.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri($this->baseApiUri.'oauth2/v1/authorize'); - - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri($this->baseApiUri.'user/v1/authenticate'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - - /** - * Parrot use a different endpoint for refresh a token - * - * {@inheritdoc} - */ - public function refreshAccessToken(TokenInterface $token) - { - $refreshToken = $token->getRefreshToken(); - - if (empty($refreshToken)) { - throw new MissingRefreshTokenException(); - } - - $parameters = array( - 'grant_type' => 'refresh_token', - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'refresh_token' => $refreshToken, - ); - - $responseBody = $this->httpClient->retrieveResponse( - new Uri($this->baseApiUri.'user/v1/refresh'), - $parameters, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php deleted file mode 100644 index 761c09d..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @link https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/ - */ -class Paypal extends AbstractService -{ - /** - * Defined scopes - * @link https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/ - * @see #attributes - */ - const SCOPE_OPENID = 'openid'; - const SCOPE_PROFILE = 'profile'; - const SCOPE_PAYPALATTRIBUTES = 'https://uri.paypal.com/services/paypalattributes'; - const SCOPE_EMAIL = 'email'; - const SCOPE_ADDRESS = 'address'; - const SCOPE_PHONE = 'phone'; - const SCOPE_EXPRESSCHECKOUT = 'https://uri.paypal.com/services/expresscheckout'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.paypal.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.paypal.com/v1/identity/openidconnect/tokenservice'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['message'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['message'] . '"'); - } elseif (isset($data['name'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['name'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pinterest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pinterest.php deleted file mode 100644 index e7ecd3c..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pinterest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developers.pinterest.com/docs/api/overview/ - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Pinterest service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developers.pinterest.com/docs/api/overview/ - */ -class Pinterest extends AbstractService -{ - /** - * Defined scopes - More scopes are listed here: - * https://developers.pinterest.com/docs/api/overview/ - */ - const SCOPE_READ_PUBLIC = 'read_public'; // read a user’s Pins, boards and likes - const SCOPE_WRITE_PUBLIC = 'write_public'; // write Pins, boards, likes - const SCOPE_READ_RELATIONSHIPS = 'read_relationships'; // read a user’s follows (boards, users, interests) - const SCOPE_WRITE_RELATIONSHIPS = 'write_relationships'; // follow boards, users and interests - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.pinterest.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.pinterest.com/oauth/'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.pinterest.com/v1/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifeTime($data['expires_in']); - unset($data['expires_in']); - } - // I hope one day Pinterest add a refresh token :) - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php deleted file mode 100644 index 8c95544..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php +++ /dev/null @@ -1,125 +0,0 @@ -baseApiUri = new Uri('https://getpocket.com/v3/'); - } - } - - public function getRequestTokenEndpoint() - { - return new Uri('https://getpocket.com/v3/oauth/request'); - } - - public function getAuthorizationEndpoint() - { - return new Uri('https://getpocket.com/auth/authorize'); - } - - public function getAccessTokenEndpoint() - { - return new Uri('https://getpocket.com/v3/oauth/authorize'); - } - - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'redirect_uri' => $this->credentials->getCallbackUrl(), - ) - ); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - public function requestRequestToken() - { - $responseBody = $this->httpClient->retrieveResponse( - $this->getRequestTokenEndpoint(), - array( - 'consumer_key' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - ) - ); - - $code = $this->parseRequestTokenResponse($responseBody); - - return $code; - } - - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['code'])) { - throw new TokenResponseException('Error in retrieving code.'); - } - return $data['code']; - } - - public function requestAccessToken($code) - { - $bodyParams = array( - 'consumer_key' => $this->credentials->getConsumerId(), - 'code' => $code, - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if ($data === null || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - #$token->setRequestToken($data['access_token']); - $token->setAccessToken($data['access_token']); - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php deleted file mode 100644 index 9e524d1..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php +++ /dev/null @@ -1,114 +0,0 @@ -baseApiUri = new Uri('https://oauth.reddit.com'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://ssl.reddit.com/api/v1/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://ssl.reddit.com/api/v1/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - // Reddit uses a Basic OAuth header - return array('Authorization' => 'Basic ' . - base64_encode($this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret())); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php deleted file mode 100644 index 7158407..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php +++ /dev/null @@ -1,105 +0,0 @@ -baseApiUri = new Uri('https://api.runkeeper.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://runkeeper.com/apps/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://runkeeper.com/apps/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php deleted file mode 100644 index a50de11..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php +++ /dev/null @@ -1,92 +0,0 @@ -parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Salesforce tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php deleted file mode 100644 index e689a4c..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -baseApiUri = new Uri('https://api.soundcloud.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://soundcloud.com/connect'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.soundcloud.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifetime($data['expires_in']); - unset($data['expires_in']); - } - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Spotify.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Spotify.php deleted file mode 100644 index 22f645b..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Spotify.php +++ /dev/null @@ -1,112 +0,0 @@ -baseApiUri = new Uri('https://api.spotify.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://accounts.spotify.com/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://accounts.spotify.com/api/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifetime($data['expires_in']); - unset($data['expires_in']); - } - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Authorization' => 'Basic ' . - base64_encode($this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret())); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Strava.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Strava.php deleted file mode 100644 index 208ec63..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Strava.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://strava.github.io/ - * @link http://strava.github.io/api/v3/oauth/ - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException; - -/** - * Strava service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://strava.github.io/ - * @link http://strava.github.io/api/v3/oauth/ - */ -class Strava extends AbstractService -{ - /** - * Scopes - */ - // default - const SCOPE_PUBLIC = 'public'; - // Modify activities, upload on the user’s behalf - const SCOPE_WRITE = 'write'; - // View private activities and data within privacy zones - const SCOPE_VIEW_PRIVATE = 'view_private'; - - protected $approvalPrompt = 'auto'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - if (empty($scopes)) { - $scopes = array(self::SCOPE_PUBLIC); - } - - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://www.strava.com/api/v3/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.strava.com/oauth/authorize?approval_prompt=' . $this->approvalPrompt); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.strava.com/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error_description'] . '"' - ); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifeTime($data['expires_in']); - unset($data['expires_in']); - } - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - public function setApprouvalPrompt($prompt) - { - if (!in_array($prompt, array('auto', 'force'), true)) { - // @todo Maybe could we rename this exception - throw new InvalidAccessTypeException('Invalid approuvalPrompt, expected either auto or force.'); - } - $this->approvalPrompt = $prompt; - } - - /** - * {@inheritdoc} - */ - protected function getScopesDelimiter() - { - return ','; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php deleted file mode 100644 index 7e55815..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php +++ /dev/null @@ -1,98 +0,0 @@ -baseApiUri = new Uri('https://api.ustream.tv/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.ustream.tv/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.ustream.tv/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Authorization' => 'Basic ' . $this->credentials->getConsumerSecret()); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vimeo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vimeo.php deleted file mode 100644 index 2efe6b2..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vimeo.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developer.vimeo.com/ - * @link https://developer.vimeo.com/api/authentication - */ - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Vimeo service. - * - * @author Pedro Amorim - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link https://developer.vimeo.com/ - * @link https://developer.vimeo.com/api/authentication - */ -class Vimeo extends AbstractService -{ - // API version - const VERSION = '3.2'; - // API Header Accept - const HEADER_ACCEPT = 'application/vnd.vimeo.*+json;version=3.2'; - - /** - * Scopes - * @see https://developer.vimeo.com/api/authentication#scope - */ - // View public videos - const SCOPE_PUBLIC = 'public'; - // View private videos - const SCOPE_PRIVATE = 'private'; - // View Vimeo On Demand purchase history - const SCOPE_PURCHASED = 'purchased'; - // Create new videos, groups, albums, etc. - const SCOPE_CREATE = 'create'; - // Edit videos, groups, albums, etc. - const SCOPE_EDIT = 'edit'; - // Delete videos, groups, albums, etc. - const SCOPE_DELETE = 'delete'; - // Interact with a video on behalf of a user, such as liking - // a video or adding it to your watch later queue - const SCOPE_INTERACT = 'interact'; - // Upload a video - const SCOPE_UPLOAD = 'upload'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct( - $credentials, - $httpClient, - $storage, - $scopes, - $baseApiUri, - true - ); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.vimeo.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.vimeo.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.vimeo.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error_description'] . '"' - ); - } elseif (isset($data['error'])) { - throw new TokenResponseException( - 'Error in retrieving token: "' . $data['error'] . '"' - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifeTime($data['expires_in']); - unset($data['expires_in']); - } - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => self::HEADER_ACCEPT); - } - - /** - * {@inheritdoc} - */ - protected function getExtraApiHeaders() - { - return array('Accept' => self::HEADER_ACCEPT); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php deleted file mode 100644 index 4a7744e..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php +++ /dev/null @@ -1,109 +0,0 @@ -baseApiUri = new Uri('https://api.vk.com/method/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://oauth.vk.com/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://oauth.vk.com/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yahoo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yahoo.php deleted file mode 100644 index ee5e985..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yahoo.php +++ /dev/null @@ -1,76 +0,0 @@ -setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - $encodedCredentials = base64_encode( - $this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret() - ); - return array('Authorization' => 'Basic ' . $encodedCredentials); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php deleted file mode 100644 index 994a293..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php +++ /dev/null @@ -1,82 +0,0 @@ -baseApiUri = new Uri('https://www.yammer.com/api/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.yammer.com/dialog/oauth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.yammer.com/oauth2/access_token.json'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']['token']); - $token->setLifetime($data['access_token']['expires_at']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php deleted file mode 100644 index eaaacac..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php +++ /dev/null @@ -1,13 +0,0 @@ - - * @author Pieter Hordijk - * @copyright Copyright (c) 2013 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth; - -use OAuth\Common\Service\ServiceInterface; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Client\StreamClient; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Exception\Exception; -use OAuth\OAuth1\Signature\Signature; - -class ServiceFactory -{ - /** - *@var ClientInterface - */ - protected $httpClient; - - /** - * @var array - */ - protected $serviceClassMap = array( - 'OAuth1' => array(), - 'OAuth2' => array() - ); - - /** - * @var array - */ - protected $serviceBuilders = array( - 'OAuth2' => 'buildV2Service', - 'OAuth1' => 'buildV1Service', - ); - - /** - * @param ClientInterface $httpClient - * - * @return ServiceFactory - */ - public function setHttpClient(ClientInterface $httpClient) - { - $this->httpClient = $httpClient; - - return $this; - } - - /** - * Register a custom service to classname mapping. - * - * @param string $serviceName Name of the service - * @param string $className Class to instantiate - * - * @return ServiceFactory - * - * @throws Exception If the class is nonexistent or does not implement a valid ServiceInterface - */ - public function registerService($serviceName, $className) - { - if (!class_exists($className)) { - throw new Exception(sprintf('Service class %s does not exist.', $className)); - } - - $reflClass = new \ReflectionClass($className); - - foreach (array('OAuth2', 'OAuth1') as $version) { - if ($reflClass->implementsInterface('OAuth\\' . $version . '\\Service\\ServiceInterface')) { - $this->serviceClassMap[$version][ucfirst($serviceName)] = $className; - - return $this; - } - } - - throw new Exception(sprintf('Service class %s must implement ServiceInterface.', $className)); - } - - /** - * Builds and returns oauth services - * - * It will first try to build an OAuth2 service and if none found it will try to build an OAuth1 service - * - * @param string $serviceName Name of service to create - * @param CredentialsInterface $credentials - * @param TokenStorageInterface $storage - * @param array|null $scopes If creating an oauth2 service, array of scopes - * @param UriInterface|null $baseApiUri - * @param string $apiVersion version of the api call - * - * @return ServiceInterface - */ - public function createService( - $serviceName, - CredentialsInterface $credentials, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null, - $apiVersion = "" - ) { - if (!$this->httpClient) { - // for backwards compatibility. - $this->httpClient = new StreamClient(); - } - - foreach ($this->serviceBuilders as $version => $buildMethod) { - $fullyQualifiedServiceName = $this->getFullyQualifiedServiceName($serviceName, $version); - - if (class_exists($fullyQualifiedServiceName)) { - return $this->$buildMethod( - $fullyQualifiedServiceName, - $credentials, - $storage, - $scopes, - $baseApiUri, - $apiVersion - ); - } - } - - return null; - } - - /** - * Gets the fully qualified name of the service - * - * @param string $serviceName The name of the service of which to get the fully qualified name - * @param string $type The type of the service to get (either OAuth1 or OAuth2) - * - * @return string The fully qualified name of the service - */ - private function getFullyQualifiedServiceName($serviceName, $type) - { - $serviceName = ucfirst($serviceName); - - if (isset($this->serviceClassMap[$type][$serviceName])) { - return $this->serviceClassMap[$type][$serviceName]; - } - - return '\\OAuth\\' . $type . '\\Service\\' . $serviceName; - } - - /** - * Builds v2 services - * - * @param string $serviceName The fully qualified service name - * @param CredentialsInterface $credentials - * @param TokenStorageInterface $storage - * @param array|null $scopes Array of scopes for the service - * @param UriInterface|null $baseApiUri - * - * @return ServiceInterface - * - * @throws Exception - */ - private function buildV2Service( - $serviceName, - CredentialsInterface $credentials, - TokenStorageInterface $storage, - array $scopes, - UriInterface $baseApiUri = null, - $apiVersion = "" - ) { - return new $serviceName( - $credentials, - $this->httpClient, - $storage, - $this->resolveScopes($serviceName, $scopes), - $baseApiUri, - $apiVersion - ); - } - - /** - * Resolves scopes for v2 services - * - * @param string $serviceName The fully qualified service name - * @param array $scopes List of scopes for the service - * - * @return array List of resolved scopes - */ - private function resolveScopes($serviceName, array $scopes) - { - $reflClass = new \ReflectionClass($serviceName); - $constants = $reflClass->getConstants(); - - $resolvedScopes = array(); - foreach ($scopes as $scope) { - $key = strtoupper('SCOPE_' . $scope); - - if (array_key_exists($key, $constants)) { - $resolvedScopes[] = $constants[$key]; - } else { - $resolvedScopes[] = $scope; - } - } - - return $resolvedScopes; - } - - /** - * Builds v1 services - * - * @param string $serviceName The fully qualified service name - * @param CredentialsInterface $credentials - * @param TokenStorageInterface $storage - * @param array $scopes - * @param UriInterface $baseApiUri - * - * @return ServiceInterface - * - * @throws Exception - */ - private function buildV1Service( - $serviceName, - CredentialsInterface $credentials, - TokenStorageInterface $storage, - $scopes, - UriInterface $baseApiUri = null - ) { - if (!empty($scopes)) { - throw new Exception( - 'Scopes passed to ServiceFactory::createService but an OAuth1 service was requested.' - ); - } - - return new $serviceName($credentials, $this->httpClient, $storage, new Signature($credentials), $baseApiUri); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/bootstrap.php b/vendor/lusitanian/oauth/src/OAuth/bootstrap.php deleted file mode 100644 index 548678a..0000000 --- a/vendor/lusitanian/oauth/src/OAuth/bootstrap.php +++ /dev/null @@ -1,13 +0,0 @@ -register();