diff options
author | 85pando <85pando@googlemail.com> | 2016-02-05 10:28:40 +0100 |
---|---|---|
committer | 85pando <85pando@googlemail.com> | 2016-02-05 10:28:40 +0100 |
commit | 791d13c87bf510d913973b77a5f6d152311a1d87 (patch) | |
tree | 81412e8dbd3ac4fa0047030a6068afafd975687e /app/Auth/GitlabAuth.php | |
parent | 2074aaaa9a75455097e4e77ca09f4fba3e567052 (diff) | |
parent | 12aaec03b19a07635f59b00f532c92c37ac1df5f (diff) |
Merge remote-tracking branch 'refs/remotes/upstream/master'
Conflicts:
app/Locale/de_DE/translations.php
Diffstat (limited to 'app/Auth/GitlabAuth.php')
-rw-r--r-- | app/Auth/GitlabAuth.php | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/app/Auth/GitlabAuth.php b/app/Auth/GitlabAuth.php deleted file mode 100644 index c0a2cf9b..00000000 --- a/app/Auth/GitlabAuth.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php - -namespace Kanboard\Auth; - -use Kanboard\Core\Base; -use Kanboard\Core\Security\OAuthAuthenticationProviderInterface; -use Kanboard\User\GitlabUserProvider; - -/** - * Gitlab Authentication Provider - * - * @package auth - * @author Frederic Guillot - */ -class GitlabAuth extends Base implements OAuthAuthenticationProviderInterface -{ - /** - * User properties - * - * @access private - * @var \Kanboard\User\GitlabUserProvider - */ - private $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 'Gitlab'; - } - - /** - * Authenticate the user - * - * @access public - * @return boolean - */ - public function authenticate() - { - $profile = $this->getProfile(); - - if (! empty($profile)) { - $this->userInfo = new GitlabUserProvider($profile); - return true; - } - - return false; - } - - /** - * Set Code - * - * @access public - * @param string $code - * @return GitlabAuth - */ - public function setCode($code) - { - $this->code = $code; - return $this; - } - - /** - * Get user object - * - * @access public - * @return GitlabUserProvider - */ - 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( - GITLAB_CLIENT_ID, - GITLAB_CLIENT_SECRET, - $this->helper->url->to('oauth', 'gitlab', array(), '', true), - GITLAB_OAUTH_AUTHORIZE_URL, - GITLAB_OAUTH_TOKEN_URL, - array() - ); - } - - return $this->service; - } - - /** - * Get Gitlab profile - * - * @access public - * @return array - */ - public function getProfile() - { - $this->getService()->getAccessToken($this->code); - - return $this->httpClient->getJson( - GITLAB_API_URL.'user', - array($this->getService()->getAuthorizationHeader()) - ); - } - - /** - * Unlink user - * - * @access public - * @param integer $userId - * @return bool - */ - public function unlink($userId) - { - return $this->user->update(array('id' => $userId, 'gitlab_id' => '')); - } -} |