| | <?php |
| |
|
| | namespace Kanboard\Auth; |
| |
|
| | use Kanboard\Core\Base; |
| | use Kanboard\Core\Security\PasswordAuthenticationProviderInterface; |
| | use Kanboard\Model\UserModel; |
| | use Kanboard\User\DatabaseUserProvider; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | class ApiAccessTokenAuth extends Base implements PasswordAuthenticationProviderInterface |
| | { |
| | |
| | |
| | |
| | |
| | |
| | |
| | protected $userInfo = array(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | protected $username = ''; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | protected $password = ''; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getName() |
| | { |
| | return 'API Access Token'; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | public function authenticate() |
| | { |
| | if (session_get('scope') !== 'API') { |
| | return false; |
| | } |
| |
|
| | $user = $this->db |
| | ->table(UserModel::TABLE) |
| | ->columns('id', 'password') |
| | ->eq('username', $this->username) |
| | ->eq('api_access_token', $this->password) |
| | ->notNull('api_access_token') |
| | ->eq('is_active', 1) |
| | ->findOne(); |
| |
|
| | if (! empty($user)) { |
| | $this->userInfo = $user; |
| | return true; |
| | } |
| |
|
| | return false; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getUser() |
| | { |
| | if (empty($this->userInfo)) { |
| | return null; |
| | } |
| |
|
| | return new DatabaseUserProvider($this->userInfo); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | public function setUsername($username) |
| | { |
| | $this->username = $username; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | public function setPassword($password) |
| | { |
| | $this->password = $password; |
| | } |
| | } |
| |
|