diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-29 20:15:53 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-29 20:15:53 -0500 |
commit | dae0c7391ab8308506bddc5fff76414a3bb87ce4 (patch) | |
tree | 1b594635ceee536c986b8f4f24a7122858ab7fc3 /app/Auth | |
parent | 915bf5882293d7041e8e5d0f5c32b8acf0938148 (diff) |
Move Google authentication to an external plugin
Diffstat (limited to 'app/Auth')
-rw-r--r-- | app/Auth/GoogleAuth.php | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/app/Auth/GoogleAuth.php b/app/Auth/GoogleAuth.php deleted file mode 100644 index 6eacf0b0..00000000 --- a/app/Auth/GoogleAuth.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php - -namespace Kanboard\Auth; - -use Kanboard\Core\Base; -use Kanboard\Core\Security\OAuthAuthenticationProviderInterface; -use Kanboard\User\GoogleUserProvider; - -/** - * Google Authentication Provider - * - * @package auth - * @author Frederic Guillot - */ -class GoogleAuth extends Base implements OAuthAuthenticationProviderInterface -{ - /** - * User properties - * - * @access protected - * @var \Kanboard\User\GoogleUserProvider - */ - protected $userInfo = null; - - /** - * OAuth2 instance - * - * @access protected - * @var \Kanboard\Core\Http\OAuth2 - */ - protected $service; - - /** - * OAuth2 code - * - * @access protected - * @var string - */ - protected $code = ''; - - /** - * Get authentication provider name - * - * @access public - * @return string - */ - public function getName() - { - return 'Google'; - } - - /** - * Authenticate the user - * - * @access public - * @return boolean - */ - public function authenticate() - { - $profile = $this->getProfile(); - - if (! empty($profile)) { - $this->userInfo = new GoogleUserProvider($profile); - return true; - } - - return false; - } - - /** - * Set Code - * - * @access public - * @param string $code - * @return GoogleAuth - */ - public function setCode($code) - { - $this->code = $code; - return $this; - } - - /** - * Get user object - * - * @access public - * @return GoogleUserProvider - */ - public function getUser() - { - return $this->userInfo; - } - - /** - * Get configured OAuth2 service - * - * @access public - * @return \Kanboard\Core\Http\OAuth2 - */ - public function getService() - { - if (empty($this->service)) { - $this->service = $this->oauth->createService( - GOOGLE_CLIENT_ID, - GOOGLE_CLIENT_SECRET, - $this->helper->url->to('oauth', 'google', array(), '', true), - 'https://accounts.google.com/o/oauth2/auth', - 'https://accounts.google.com/o/oauth2/token', - array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile') - ); - } - - return $this->service; - } - - /** - * Get Google profile - * - * @access public - * @return array - */ - public function getProfile() - { - $this->getService()->getAccessToken($this->code); - - return $this->httpClient->getJson( - 'https://www.googleapis.com/oauth2/v1/userinfo', - array($this->getService()->getAuthorizationHeader()) - ); - } - - /** - * Unlink user - * - * @access public - * @param integer $userId - * @return bool - */ - public function unlink($userId) - { - return $this->user->update(array('id' => $userId, 'google_id' => '')); - } -} |