Refactoring of Github authentication (oauth url change)

This commit is contained in:
Frederic Guillot 2015-07-16 20:35:56 -04:00
parent 12036aa21f
commit ede1f1d9b0
33 changed files with 426 additions and 485 deletions

View File

@ -1,163 +0,0 @@
<?php
namespace Auth;
use Event\AuthEvent;
use OAuth\Common\Storage\Session;
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Uri\UriFactory;
use OAuth\ServiceFactory;
use OAuth\Common\Http\Exception\TokenResponseException;
/**
* GitHub backend
*
* @package auth
*/
class GitHub extends Base
{
/**
* Backend name
*
* @var string
*/
const AUTH_NAME = 'Github';
/**
* Authenticate a GitHub user
*
* @access public
* @param string $github_id GitHub user id
* @return boolean
*/
public function authenticate($github_id)
{
$user = $this->user->getByGitHubId($github_id);
if (! empty($user)) {
$this->userSession->refresh($user);
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
return true;
}
return false;
}
/**
* Unlink a GitHub account for a given user
*
* @access public
* @param integer $user_id User id
* @return boolean
*/
public function unlink($user_id)
{
return $this->user->update(array(
'id' => $user_id,
'github_id' => '',
));
}
/**
* Update the user table based on the GitHub profile information
*
* @access public
* @param integer $user_id User id
* @param array $profile GitHub profile
* @return boolean
* @todo Don't overwrite existing email/name with empty GitHub data
*/
public function updateUser($user_id, array $profile)
{
return $this->user->update(array(
'id' => $user_id,
'github_id' => $profile['id'],
'email' => $profile['email'],
'name' => $profile['name'],
));
}
/**
* Get the GitHub service instance
*
* @access public
* @return \OAuth\OAuth2\Service\GitHub
*/
public function getService()
{
$uriFactory = new UriFactory();
$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
$currentUri->setQuery('controller=user&action=gitHub');
$storage = new Session(false);
$credentials = new Credentials(
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
$currentUri->getAbsoluteUri()
);
$serviceFactory = new ServiceFactory();
return $serviceFactory->createService(
'gitHub',
$credentials,
$storage,
array('')
);
}
/**
* Get the authorization URL
*
* @access public
* @return \OAuth\Common\Http\Uri\Uri
*/
public function getAuthorizationUrl()
{
return $this->getService()->getAuthorizationUri();
}
/**
* Get GitHub profile information from the API
*
* @access public
* @param string $code GitHub authorization code
* @return bool|array
*/
public function getGitHubProfile($code)
{
try {
$gitHubService = $this->getService();
$gitHubService->requestAccessToken($code);
return json_decode($gitHubService->request('user'), true);
}
catch (TokenResponseException $e) {
return false;
}
}
/**
* Revokes this user's GitHub tokens for Kanboard
*
* @access public
* @return bool|array
* @todo Currently this simply removes all our tokens for this user, ideally it should
* restrict itself to the one in question
*/
public function revokeGitHubAccess()
{
try {
$gitHubService = $this->getService();
$basicAuthHeader = array('Authorization' => 'Basic ' .
base64_encode(GITHUB_CLIENT_ID.':'.GITHUB_CLIENT_SECRET));
return json_decode($gitHubService->request('/applications/'.GITHUB_CLIENT_ID.'/tokens', 'DELETE', null, $basicAuthHeader), true);
}
catch (TokenResponseException $e) {
return false;
}
}
}

122
app/Auth/Github.php Normal file
View File

@ -0,0 +1,122 @@
<?php
namespace Auth;
use Event\AuthEvent;
/**
* Github backend
*
* @package auth
*/
class Github extends Base
{
/**
* Backend name
*
* @var string
*/
const AUTH_NAME = 'Github';
/**
* OAuth2 instance
*
* @access private
* @var \Core\OAuth2
*/
private $service;
/**
* Authenticate a Github user
*
* @access public
* @param string $github_id Github user id
* @return boolean
*/
public function authenticate($github_id)
{
$user = $this->user->getByGithubId($github_id);
if (! empty($user)) {
$this->userSession->refresh($user);
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
return true;
}
return false;
}
/**
* Unlink a Github account for a given user
*
* @access public
* @param integer $user_id User id
* @return boolean
*/
public function unlink($user_id)
{
return $this->user->update(array(
'id' => $user_id,
'github_id' => '',
));
}
/**
* Update the user table based on the Github profile information
*
* @access public
* @param integer $user_id User id
* @param array $profile Github profile
* @return boolean
*/
public function updateUser($user_id, array $profile)
{
$user = $this->user->getById($user_id);
return $this->user->update(array(
'id' => $user_id,
'github_id' => $profile['id'],
'email' => $profile['email'] ?: $user['email'],
'name' => $profile['name'] ?: $user['name'],
));
}
/**
* Get OAuth2 configured service
*
* @access public
* @return \Core\OAuth2
*/
public function getService()
{
if (empty($this->service)) {
$this->service = $this->oauth->createService(
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
$this->helper->url->to('oauth', 'github', array(), '', true),
'https://github.com/login/oauth/authorize',
'https://github.com/login/oauth/access_token',
array()
);
}
return $this->service;
}
/**
* Get Github profile
*
* @access public
* @param string $code
* @return array
*/
public function getProfile($code)
{
$this->getService()->getAccessToken($code);
return $this->httpClient->getJson(
'https://api.github.com/user',
array($this->getService()->getAuthorizationHeader())
);
}
}

View File

@ -22,6 +22,7 @@ class Google extends Base
/**
* OAuth2 instance
*
* @access private
* @var \Core\OAuth2
*/
private $service;
@ -71,11 +72,13 @@ class Google extends Base
*/
public function updateUser($user_id, array $profile)
{
$user = $this->user->getById($user_id);
return $this->user->update(array(
'id' => $user_id,
'google_id' => $profile['id'],
'email' => $profile['email'],
'name' => $profile['name'],
'email' => $profile['email'] ?: $user['email'],
'name' => $profile['name'] ?: $user['name'],
));
}
@ -114,7 +117,7 @@ class Google extends Base
return $this->httpClient->getJson(
'https://www.googleapis.com/oauth2/v1/userinfo',
array($this->getService()->getAuthorizationHeader()
));
array($this->getService()->getAuthorizationHeader())
);
}
}

View File

@ -20,6 +20,16 @@ class Oauth extends Base
$this->step1('google');
}
/**
* Link or authenticate a Github account
*
* @access public
*/
public function github()
{
$this->step1('github');
}
/**
* Unlink external account
*

View File

@ -360,69 +360,4 @@ class User extends Base
'user' => $user,
)));
}
/**
* GitHub authentication
*
* @access public
*/
public function github()
{
$code = $this->request->getStringParam('code');
if ($code) {
$profile = $this->authentication->backend('gitHub')->getGitHubProfile($code);
if (is_array($profile)) {
// If the user is already logged, link the account otherwise authenticate
if ($this->userSession->isLogged()) {
if ($this->authentication->backend('gitHub')->updateUser($this->userSession->getId(), $profile)) {
$this->session->flash(t('Your GitHub account was successfully linked to your profile.'));
}
else {
$this->session->flashError(t('Unable to link your GitHub Account.'));
}
$this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId())));
}
else if ($this->authentication->backend('gitHub')->authenticate($profile['id'])) {
$this->response->redirect($this->helper->url->to('app', 'index'));
}
else {
$this->response->html($this->template->layout('auth/index', array(
'errors' => array('login' => t('GitHub authentication failed')),
'values' => array(),
'no_layout' => true,
'redirect_query' => '',
'title' => t('Login')
)));
}
}
}
$this->response->redirect($this->authentication->backend('gitHub')->getAuthorizationUrl());
}
/**
* Unlink a GitHub account
*
* @access public
*/
public function unlinkGithub()
{
$this->checkCSRFParam();
$this->authentication->backend('gitHub')->revokeGitHubAccess();
if ($this->authentication->backend('gitHub')->unlink($this->userSession->getId())) {
$this->session->flash(t('Your GitHub account is no longer linked to your profile.'));
}
else {
$this->session->flashError(t('Unable to unlink your GitHub Account.'));
}
$this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId())));
}
}

View File

@ -19,6 +19,18 @@ class OAuth2 extends Base
private $tokenType;
private $accessToken;
/**
* Create OAuth2 service
*
* @access public
* @param string $clientId
* @param string $secret
* @param string $callbackUrl
* @param string $authUrl
* @param string $tokenUrl
* @param array $scopes
* @return OAuth2
*/
public function createService($clientId, $secret, $callbackUrl, $authUrl, $tokenUrl, array $scopes)
{
$this->clientId = $clientId;
@ -31,6 +43,12 @@ class OAuth2 extends Base
return $this;
}
/**
* Get authorization url
*
* @access public
* @return string
*/
public function getAuthorizationUrl()
{
$params = array(
@ -43,15 +61,28 @@ class OAuth2 extends Base
return $this->authUrl.'?'.http_build_query($params);
}
/**
* Get authorization header
*
* @access public
* @return string
*/
public function getAuthorizationHeader()
{
if ($this->tokenType === 'Bearer') {
if (strtolower($this->tokenType) === 'bearer') {
return 'Authorization: Bearer '.$this->accessToken;
}
return '';
}
/**
* Get access token
*
* @access public
* @param string $code
* @return string
*/
public function getAccessToken($code)
{
if (empty($this->accessToken) && ! empty($code)) {
@ -64,7 +95,7 @@ class OAuth2 extends Base
'grant_type' => 'authorization_code',
);
$response = json_decode($this->httpClient->postForm($this->tokenUrl, $params), true);
$response = json_decode($this->httpClient->postForm($this->tokenUrl, $params, array('Accept: application/json')), true);
$this->tokenType = isset($response['token_type']) ? $response['token_type'] : '';
$this->accessToken = isset($response['access_token']) ? $response['access_token'] : '';
@ -72,4 +103,18 @@ class OAuth2 extends Base
return $this->accessToken;
}
/**
* Set access token
*
* @access public
* @param string $token
* @param string $type
* @return string
*/
public function setAccessToken($token, $type = 'bearer')
{
$this->accessToken = $token;
$this->tokenType = $type;
}
}

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maksimum størrelse: ',
'Unable to upload the file.' => 'Filen kunne ikke uploades.',
'Display another project' => 'Vis et andet projekt...',
'Your GitHub account was successfully linked to your profile.' => 'Din GitHub-konto er forbundet til din profil.',
'Unable to link your GitHub Account.' => 'Det var ikke muligt er forbinde til din GitHub-konto.',
'GitHub authentication failed' => 'GitHub autentificering mislykkedes',
'Your GitHub account is no longer linked to your profile.' => 'Din GitHub-konto er ikke længere forbundet til din profil.',
'Unable to unlink your GitHub Account.' => 'Det var ikke muligt at fjerne forbindelsen til din GitHub-konto.',
'Login with my GitHub Account' => 'Login med min GitHub-konto',
'Link my GitHub Account' => 'Forbind min GitHub-konto',
'Unlink my GitHub Account' => 'Fjern forbindelsen til min GitHub-konto',
'Your Github account was successfully linked to your profile.' => 'Din Github-konto er forbundet til din profil.',
'Unable to link your Github Account.' => 'Det var ikke muligt er forbinde til din Github-konto.',
'Github authentication failed' => 'Github autentificering mislykkedes',
'Your Github account is no longer linked to your profile.' => 'Din Github-konto er ikke længere forbundet til din profil.',
'Unable to unlink your Github Account.' => 'Det var ikke muligt at fjerne forbindelsen til din Github-konto.',
'Login with my Github Account' => 'Login med min Github-konto',
'Link my Github Account' => 'Forbind min Github-konto',
'Unlink my Github Account' => 'Fjern forbindelsen til min Github-konto',
'Created by %s' => 'Oprettet af %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Sidst redigeret %d.%m.%Y - %H:%M',
'Tasks Export' => 'Opgave eksport',
@ -403,7 +403,7 @@ return array(
'Enabled' => 'Aktiv',
'Disabled' => 'Deaktiveret',
'Google account linked' => 'Google-konto forbundet',
'Github account linked' => 'GitHub-konto forbundet',
'Github account linked' => 'Github-konto forbundet',
'Username:' => 'Brugernavn',
'Name:' => 'Navn:',
'Email:' => 'Email:',
@ -417,7 +417,7 @@ return array(
'Password modification' => 'Adgangskode ændring',
'External authentications' => 'Ekstern autentificering',
'Google Account' => 'Google-konto',
'Github Account' => 'GitHub-konto',
'Github Account' => 'Github-konto',
'Never connected.' => 'Aldrig forbundet.',
'No account linked.' => 'Ingen kontoer forfundet.',
'Account linked.' => 'Konto forbundet.',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maximalgröße: ',
'Unable to upload the file.' => 'Hochladen der Datei nicht möglich.',
'Display another project' => 'Zu Projekt wechseln',
'Your GitHub account was successfully linked to your profile.' => 'GitHub-Account erfolgreich mit dem Profil verbunden.',
'Unable to link your GitHub Account.' => 'Verbindung mit diesem GitHub-Account nicht möglich.',
'GitHub authentication failed' => 'Zugriff mit GitHub fehlgeschlagen',
'Your GitHub account is no longer linked to your profile.' => 'GitHub-Account ist nicht mehr mit dem Profil verbunden.',
'Unable to unlink your GitHub Account.' => 'Trennung der Verbindung zum GitHub-Account ist nicht möglich.',
'Login with my GitHub Account' => 'Anmelden mit meinem GitHub-Account',
'Link my GitHub Account' => 'Mit meinem GitHub-Account verbinden',
'Unlink my GitHub Account' => 'Verbindung mit meinem GitHub-Account trennen',
'Your Github account was successfully linked to your profile.' => 'Github-Account erfolgreich mit dem Profil verbunden.',
'Unable to link your Github Account.' => 'Verbindung mit diesem Github-Account nicht möglich.',
'Github authentication failed' => 'Zugriff mit Github fehlgeschlagen',
'Your Github account is no longer linked to your profile.' => 'Github-Account ist nicht mehr mit dem Profil verbunden.',
'Unable to unlink your Github Account.' => 'Trennung der Verbindung zum Github-Account ist nicht möglich.',
'Login with my Github Account' => 'Anmelden mit meinem Github-Account',
'Link my Github Account' => 'Mit meinem Github-Account verbinden',
'Unlink my Github Account' => 'Verbindung mit meinem Github-Account trennen',
'Created by %s' => 'Erstellt durch %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Letzte Änderung am %d.%m.%Y um %H:%M',
'Tasks Export' => 'Aufgaben exportieren',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Tamaño máximo',
'Unable to upload the file.' => 'No pude cargar el fichero.',
'Display another project' => 'Mostrar otro proyecto',
'Your GitHub account was successfully linked to your profile.' => 'Tu cuenta de GitHub ha sido correctamente vinculada con tu perfil',
'Unable to link your GitHub Account.' => 'Imposible vincular tu cuenta de GitHub',
'GitHub authentication failed' => 'Falló la autenticación de GitHub',
'Your GitHub account is no longer linked to your profile.' => 'Tu cuenta de GitHub ya no está vinculada a tu perfil',
'Unable to unlink your GitHub Account.' => 'Imposible desvincular tu cuenta de GitHub',
'Login with my GitHub Account' => 'Ingresar con mi cuenta de GitHub',
'Link my GitHub Account' => 'Vincular mi cuenta de GitHub',
'Unlink my GitHub Account' => 'Desvincular mi cuenta de GitHub',
'Your Github account was successfully linked to your profile.' => 'Tu cuenta de Github ha sido correctamente vinculada con tu perfil',
'Unable to link your Github Account.' => 'Imposible vincular tu cuenta de Github',
'Github authentication failed' => 'Falló la autenticación de Github',
'Your Github account is no longer linked to your profile.' => 'Tu cuenta de Github ya no está vinculada a tu perfil',
'Unable to unlink your Github Account.' => 'Imposible desvincular tu cuenta de Github',
'Login with my Github Account' => 'Ingresar con mi cuenta de Github',
'Link my Github Account' => 'Vincular mi cuenta de Github',
'Unlink my Github Account' => 'Desvincular mi cuenta de Github',
'Created by %s' => 'Creado por %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Última modificación %B %e, %Y a las %k:%M %p',
'Tasks Export' => 'Exportar tareas',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maksimikoko: ',
'Unable to upload the file.' => 'Tiedoston lataus epäonnistui.',
'Display another project' => 'Näytä toinen projekti',
'Your GitHub account was successfully linked to your profile.' => 'Github-tilisi on onnistuneesti liitetty profiiliisi',
'Unable to link your GitHub Account.' => 'Github-tilin liittäminen epäonnistui',
'GitHub authentication failed' => 'Github-todennus epäonnistui',
'Your GitHub account is no longer linked to your profile.' => 'Github-tiliäsi ei ole enää liitetty profiiliisi.',
'Unable to unlink your GitHub Account.' => 'Github-tilisi liitoksen poisto epäonnistui',
'Login with my GitHub Account' => 'Kirjaudu sisään Github-tililläni',
'Link my GitHub Account' => 'Liitä Github-tilini',
'Unlink my GitHub Account' => 'Poista liitos Github-tiliini',
'Your Github account was successfully linked to your profile.' => 'Github-tilisi on onnistuneesti liitetty profiiliisi',
'Unable to link your Github Account.' => 'Github-tilin liittäminen epäonnistui',
'Github authentication failed' => 'Github-todennus epäonnistui',
'Your Github account is no longer linked to your profile.' => 'Github-tiliäsi ei ole enää liitetty profiiliisi.',
'Unable to unlink your Github Account.' => 'Github-tilisi liitoksen poisto epäonnistui',
'Login with my Github Account' => 'Kirjaudu sisään Github-tililläni',
'Link my Github Account' => 'Liitä Github-tilini',
'Unlink my Github Account' => 'Poista liitos Github-tiliini',
'Created by %s' => 'Luonut: %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Viimeksi muokattu %B %e, %Y kello %H:%M',
'Tasks Export' => 'Tehtävien vienti',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Taille maximum : ',
'Unable to upload the file.' => 'Impossible de transférer le fichier.',
'Display another project' => 'Afficher un autre projet',
'Your GitHub account was successfully linked to your profile.' => 'Votre compte Github est désormais lié avec votre profile.',
'Unable to link your GitHub Account.' => 'Impossible de lier votre compte Github.',
'GitHub authentication failed' => 'L\'authentification avec Github à échouée',
'Your GitHub account is no longer linked to your profile.' => 'Votre compte Github n\'est plus relié avec votre profile.',
'Unable to unlink your GitHub Account.' => 'Impossible de déconnecter votre compte Github.',
'Login with my GitHub Account' => 'Se connecter avec mon compte Github',
'Link my GitHub Account' => 'Lier mon compte Github',
'Unlink my GitHub Account' => 'Ne plus utiliser mon compte Github',
'Your Github account was successfully linked to your profile.' => 'Votre compte Github est désormais lié avec votre profile.',
'Unable to link your Github Account.' => 'Impossible de lier votre compte Github.',
'Github authentication failed' => 'L\'authentification avec Github à échouée',
'Your Github account is no longer linked to your profile.' => 'Votre compte Github n\'est plus relié avec votre profile.',
'Unable to unlink your Github Account.' => 'Impossible de déconnecter votre compte Github.',
'Login with my Github Account' => 'Se connecter avec mon compte Github',
'Link my Github Account' => 'Lier mon compte Github',
'Unlink my Github Account' => 'Ne plus utiliser mon compte Github',
'Created by %s' => 'Créé par %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Modifié le %d/%m/%Y à %H:%M',
'Tasks Export' => 'Exportation des tâches',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maximális méret: ',
'Unable to upload the file.' => 'Fájl feltöltése nem lehetséges.',
'Display another project' => 'Másik projekt megjelenítése',
'Your GitHub account was successfully linked to your profile.' => 'GitHub fiók sikeresen csatolva a profilhoz.',
'Unable to link your GitHub Account.' => 'Nem lehet csatolni a GitHub fiókot.',
'GitHub authentication failed' => 'GitHub azonosítás sikertelen',
'Your GitHub account is no longer linked to your profile.' => 'GitHub fiók már nincs profilhoz kapcsolva.',
'Unable to unlink your GitHub Account.' => 'GitHub fiók leválasztása nem lehetséges.',
'Login with my GitHub Account' => 'Jelentkezzen be GitHub fiókkal',
'Link my GitHub Account' => 'GitHub fiók csatolása',
'Unlink my GitHub Account' => 'GitHub fiók leválasztása',
'Your Github account was successfully linked to your profile.' => 'Github fiók sikeresen csatolva a profilhoz.',
'Unable to link your Github Account.' => 'Nem lehet csatolni a Github fiókot.',
'Github authentication failed' => 'Github azonosítás sikertelen',
'Your Github account is no longer linked to your profile.' => 'Github fiók már nincs profilhoz kapcsolva.',
'Unable to unlink your Github Account.' => 'Github fiók leválasztása nem lehetséges.',
'Login with my Github Account' => 'Jelentkezzen be Github fiókkal',
'Link my Github Account' => 'Github fiók csatolása',
'Unlink my Github Account' => 'Github fiók leválasztása',
'Created by %s' => 'Készítette: %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Utolsó módosítás: %Y. %m. %d. %H:%M',
'Tasks Export' => 'Feladatok exportálása',
@ -403,7 +403,7 @@ return array(
'Enabled' => 'Engedélyezve',
'Disabled' => 'Letiltva',
'Google account linked' => 'Google fiók összekapcsolva',
'Github account linked' => 'GitHub fiók összekapcsolva',
'Github account linked' => 'Github fiók összekapcsolva',
'Username:' => 'Felhasználónév:',
'Name:' => 'Név:',
'Email:' => 'E-mail:',
@ -458,12 +458,12 @@ return array(
'%s changed the assignee of the task %s to %s' => '%s a felelőst %s módosította: %s',
'New password for the user "%s"' => 'Felhasználó új jelszava: %s',
'Choose an event' => 'Válasszon eseményt',
'Github commit received' => 'GitHub commit érkezett',
'Github issue opened' => 'GitHub issue nyitás',
'Github issue closed' => 'GitHub issue zárás',
'Github issue reopened' => 'GitHub issue újranyitva',
'Github issue assignee change' => 'GitHub issue felelős változás',
'Github issue label change' => 'GitHub issue címke változás',
'Github commit received' => 'Github commit érkezett',
'Github issue opened' => 'Github issue nyitás',
'Github issue closed' => 'Github issue zárás',
'Github issue reopened' => 'Github issue újranyitva',
'Github issue assignee change' => 'Github issue felelős változás',
'Github issue label change' => 'Github issue címke változás',
'Create a task from an external provider' => 'Feladat létrehozása külsős számára',
'Change the assignee based on an external username' => 'Felelős módosítása külső felhasználónév alapján',
'Change the category based on an external label' => 'Kategória módosítása külső címke alapján',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Dimensioni massime',
'Unable to upload the file.' => 'Non si può caricare il file.',
'Display another project' => 'Mostrare un altro progetto',
'Your GitHub account was successfully linked to your profile.' => 'Il suo account di Github è stato collegato correttamente col tuo profilo.',
'Unable to link your GitHub Account.' => 'Non si può collegarre il tuo account di Github.',
'GitHub authentication failed' => 'Autenticazione con GitHub non riuscita',
'Your GitHub account is no longer linked to your profile.' => 'Il tuo account di Github non è più collegato al tuo profilo.',
'Unable to unlink your GitHub Account.' => 'Non si può collegare il tuo account di Github.',
'Login with my GitHub Account' => 'Entrare col tuo account di Github',
'Link my GitHub Account' => 'Collegare il mio account Github',
'Unlink my GitHub Account' => 'Scollegare il mio account di Github',
'Your Github account was successfully linked to your profile.' => 'Il suo account di Github è stato collegato correttamente col tuo profilo.',
'Unable to link your Github Account.' => 'Non si può collegarre il tuo account di Github.',
'Github authentication failed' => 'Autenticazione con Github non riuscita',
'Your Github account is no longer linked to your profile.' => 'Il tuo account di Github non è più collegato al tuo profilo.',
'Unable to unlink your Github Account.' => 'Non si può collegare il tuo account di Github.',
'Login with my Github Account' => 'Entrare col tuo account di Github',
'Link my Github Account' => 'Collegare il mio account Github',
'Unlink my Github Account' => 'Scollegare il mio account di Github',
'Created by %s' => 'Creato da %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Ultima modifica il %d/%m/%Y alle %H:%M',
'Tasks Export' => 'Esportazione di compiti',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => '最大: ',
'Unable to upload the file.' => 'ファイルのアップロードに失敗しました。',
'Display another project' => '別のプロジェクトを表示',
'Your GitHub account was successfully linked to your profile.' => 'GitHub アカウントとリンクしました。',
'Unable to link your GitHub Account.' => 'GitHub アカウントとリンクできませんでした。',
'GitHub authentication failed' => 'GitHub アカウントの認証に失敗しました。',
'Your GitHub account is no longer linked to your profile.' => 'GitHub アカウントへのリンクが解除されました。',
'Unable to unlink your GitHub Account.' => 'GitHub アカウントのリンク解除に失敗しました。',
'Login with my GitHub Account' => 'Github アカウントでログインする',
'Link my GitHub Account' => 'Github アカウントをリンクする',
'Unlink my GitHub Account' => 'Github アカウントとのリンクを解除する',
'Your Github account was successfully linked to your profile.' => 'Github アカウントとリンクしました。',
'Unable to link your Github Account.' => 'Github アカウントとリンクできませんでした。',
'Github authentication failed' => 'Github アカウントの認証に失敗しました。',
'Your Github account is no longer linked to your profile.' => 'Github アカウントへのリンクが解除されました。',
'Unable to unlink your Github Account.' => 'Github アカウントのリンク解除に失敗しました。',
'Login with my Github Account' => 'Github アカウントでログインする',
'Link my Github Account' => 'Github アカウントをリンクする',
'Unlink my Github Account' => 'Github アカウントとのリンクを解除する',
'Created by %s' => '%s が作成',
'Last modified on %B %e, %Y at %k:%M %p' => ' %Y/%m/%d %H:%M に変更',
'Tasks Export' => 'タスクの出力',
@ -403,7 +403,7 @@ return array(
'Enabled' => '有効',
'Disabled' => '無効',
'Google account linked' => 'Google アカウントがリンク',
'Github account linked' => 'GitHub のアカウントがリンク',
'Github account linked' => 'Github のアカウントがリンク',
'Username:' => 'ユーザ名:',
'Name:' => '名前:',
'Email:' => 'Email:',
@ -417,7 +417,7 @@ return array(
'Password modification' => 'パスワードの変更',
'External authentications' => '外部認証',
'Google Account' => 'Google アカウント',
'Github Account' => 'GitHub アカウント',
'Github Account' => 'Github アカウント',
'Never connected.' => '未接続。',
'No account linked.' => 'アカウントがリンクしていません。',
'Account linked.' => 'アカウントがリンクしました。',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maximale grootte : ',
'Unable to upload the file.' => 'Uploaden van bestand niet gelukt.',
'Display another project' => 'Een ander project weergeven',
'Your GitHub account was successfully linked to your profile.' => 'Uw Github Account is succesvol gelinkt aan uw profiel.',
'Unable to link your GitHub Account.' => 'Linken van uw Github Account niet gelukt.',
'GitHub authentication failed' => 'Github Authenticatie niet gelukt',
'Your GitHub account is no longer linked to your profile.' => 'Uw Github Account is niet langer gelinkt aan uw profiel.',
'Unable to unlink your GitHub Account.' => 'Verwijdern van de link met uw Github Account niet gelukt.',
'Login with my GitHub Account' => 'Login met mijn Github Account',
'Link my GitHub Account' => 'Link met mijn Github',
'Unlink my GitHub Account' => 'Link met mijn Github verwijderen',
'Your Github account was successfully linked to your profile.' => 'Uw Github Account is succesvol gelinkt aan uw profiel.',
'Unable to link your Github Account.' => 'Linken van uw Github Account niet gelukt.',
'Github authentication failed' => 'Github Authenticatie niet gelukt',
'Your Github account is no longer linked to your profile.' => 'Uw Github Account is niet langer gelinkt aan uw profiel.',
'Unable to unlink your Github Account.' => 'Verwijdern van de link met uw Github Account niet gelukt.',
'Login with my Github Account' => 'Login met mijn Github Account',
'Link my Github Account' => 'Link met mijn Github',
'Unlink my Github Account' => 'Link met mijn Github verwijderen',
'Created by %s' => 'Aangemaakt door %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Laatst gewijzigd op %d/%m/%Y à %H:%M',
'Tasks Export' => 'Taken exporteren',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maksymalny rozmiar: ',
'Unable to upload the file.' => 'Nie można wczytać pliku.',
'Display another project' => 'Wyświetl inny projekt',
'Your GitHub account was successfully linked to your profile.' => 'Konto Github podłączone pomyślnie.',
'Unable to link your GitHub Account.' => 'Nie można połączyć z kontem Github.',
'GitHub authentication failed' => 'Autentykacja Github nieudana',
'Your GitHub account is no longer linked to your profile.' => 'Konto Github nie jest już podłączone do twojego profilu.',
'Unable to unlink your GitHub Account.' => 'Nie można odłączyć konta Github.',
'Login with my GitHub Account' => 'Zaloguj przy użyciu konta Github',
'Link my GitHub Account' => 'Podłącz konto Github',
'Unlink my GitHub Account' => 'Odłącz konto Github',
'Your Github account was successfully linked to your profile.' => 'Konto Github podłączone pomyślnie.',
'Unable to link your Github Account.' => 'Nie można połączyć z kontem Github.',
'Github authentication failed' => 'Autentykacja Github nieudana',
'Your Github account is no longer linked to your profile.' => 'Konto Github nie jest już podłączone do twojego profilu.',
'Unable to unlink your Github Account.' => 'Nie można odłączyć konta Github.',
'Login with my Github Account' => 'Zaloguj przy użyciu konta Github',
'Link my Github Account' => 'Podłącz konto Github',
'Unlink my Github Account' => 'Odłącz konto Github',
'Created by %s' => 'Utworzone przez %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Ostatnio zmienione %e %B %Y o %k:%M',
'Tasks Export' => 'Eksport zadań',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Tamanho máximo:',
'Unable to upload the file.' => 'Não foi possível carregar o arquivo.',
'Display another project' => 'Exibir outro projeto',
'Your GitHub account was successfully linked to your profile.' => 'A sua Conta do GitHub foi associada com sucesso ao seu perfil.',
'Unable to link your GitHub Account.' => 'Não foi possível associar sua Conta do GitHub.',
'GitHub authentication failed' => 'Autenticação do GitHub falhou',
'Your GitHub account is no longer linked to your profile.' => 'A sua Conta do GitHub não está mais associada ao seu perfil.',
'Unable to unlink your GitHub Account.' => 'Não foi possível desassociar a sua Conta do GitHub.',
'Login with my GitHub Account' => 'Entrar com minha Conta do GitHub',
'Link my GitHub Account' => 'Associar à minha Conta do GitHub',
'Unlink my GitHub Account' => 'Desassociar a minha Conta do GitHub',
'Your Github account was successfully linked to your profile.' => 'A sua Conta do Github foi associada com sucesso ao seu perfil.',
'Unable to link your Github Account.' => 'Não foi possível associar sua Conta do Github.',
'Github authentication failed' => 'Autenticação do Github falhou',
'Your Github account is no longer linked to your profile.' => 'A sua Conta do Github não está mais associada ao seu perfil.',
'Unable to unlink your Github Account.' => 'Não foi possível desassociar a sua Conta do Github.',
'Login with my Github Account' => 'Entrar com minha Conta do Github',
'Link my Github Account' => 'Associar à minha Conta do Github',
'Unlink my Github Account' => 'Desassociar a minha Conta do Github',
'Created by %s' => 'Criado por %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Última modificação em %B %e, %Y às %k: %M %p',
'Tasks Export' => 'Exportar Tarefas',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Максимальный размер: ',
'Unable to upload the file.' => 'Не удалось загрузить файл.',
'Display another project' => 'Показать другой проект',
'Your GitHub account was successfully linked to your profile.' => 'Ваш GitHub привязан к вашему профилю.',
'Unable to link your GitHub Account.' => 'Не удалось привязать ваш профиль к GitHub.',
'GitHub authentication failed' => 'Аутентификация в GitHub не удалась',
'Your GitHub account is no longer linked to your profile.' => 'Ваш GitHub отвязан от вашего профиля.',
'Unable to unlink your GitHub Account.' => 'Не удалось отвязать ваш профиль от GitHub.',
'Login with my GitHub Account' => 'Аутентификация через GitHub',
'Link my GitHub Account' => 'Привязать мой профиль к GitHub',
'Unlink my GitHub Account' => 'Отвязать мой профиль от GitHub',
'Your Github account was successfully linked to your profile.' => 'Ваш Github привязан к вашему профилю.',
'Unable to link your Github Account.' => 'Не удалось привязать ваш профиль к Github.',
'Github authentication failed' => 'Аутентификация в Github не удалась',
'Your Github account is no longer linked to your profile.' => 'Ваш Github отвязан от вашего профиля.',
'Unable to unlink your Github Account.' => 'Не удалось отвязать ваш профиль от Github.',
'Login with my Github Account' => 'Аутентификация через Github',
'Link my Github Account' => 'Привязать мой профиль к Github',
'Unlink my Github Account' => 'Отвязать мой профиль от Github',
'Created by %s' => 'Создано %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Последнее изменение %d/%m/%Y в %H:%M',
'Tasks Export' => 'Экспорт задач',
@ -403,7 +403,7 @@ return array(
'Enabled' => 'Включен',
'Disabled' => 'Выключены',
'Google account linked' => 'Профиль Google связан',
'Github account linked' => 'Профиль GitHub связан',
'Github account linked' => 'Профиль Github связан',
'Username:' => 'Имя пользователя:',
'Name:' => 'Имя:',
'Email:' => 'E-mail:',
@ -417,7 +417,7 @@ return array(
'Password modification' => 'Изменение пароля',
'External authentications' => 'Внешняя аутентификация',
'Google Account' => 'Профиль Google',
'Github Account' => 'Профиль GitHub',
'Github Account' => 'Профиль Github',
'Never connected.' => 'Ранее не соединялось.',
'No account linked.' => 'Нет связанных профилей.',
'Account linked.' => 'Профиль связан.',
@ -458,12 +458,12 @@ return array(
'%s changed the assignee of the task %s to %s' => '%s сменил назначенного для задачи %s на %s',
'New password for the user "%s"' => 'Новый пароль для пользователя "%s"',
'Choose an event' => 'Выберите событие',
'Github commit received' => 'GitHub: коммит получен',
'Github issue opened' => 'GitHub: новая проблема',
'Github issue closed' => 'GitHub: проблема закрыта',
'Github issue reopened' => 'GitHub: проблема переоткрыта',
'Github issue assignee change' => 'GitHub: сменить ответственного за проблему',
'Github issue label change' => 'GitHub: ярлык проблемы изменен',
'Github commit received' => 'Github: коммит получен',
'Github issue opened' => 'Github: новая проблема',
'Github issue closed' => 'Github: проблема закрыта',
'Github issue reopened' => 'Github: проблема переоткрыта',
'Github issue assignee change' => 'Github: сменить ответственного за проблему',
'Github issue label change' => 'Github: ярлык проблемы изменен',
'Create a task from an external provider' => 'Создать задачу из внешнего источника',
'Change the assignee based on an external username' => 'Изменить назначенного основываясь на внешнем имени пользователя',
'Change the category based on an external label' => 'Изменить категорию основываясь на внешнем ярлыке',
@ -508,8 +508,8 @@ return array(
'Everybody have access to this project.' => 'Любой может получить доступ к этому проекту.',
'Webhooks' => 'Webhooks',
'API' => 'API',
'Github webhooks' => 'GitHub webhooks',
'Help on Github webhooks' => 'Помощь по GitHub webhooks',
'Github webhooks' => 'Github webhooks',
'Help on Github webhooks' => 'Помощь по Github webhooks',
'Create a comment from an external provider' => 'Создать комментарий из внешнего источника',
'Github issue comment created' => 'Github issue комментарий создан',
'Project management' => 'Управление проектом',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maksimalna veličina: ',
'Unable to upload the file.' => 'Nije moguće snimiti fajl.',
'Display another project' => 'Prikaži drugi projekat',
'Your GitHub account was successfully linked to your profile.' => 'Konto Github podłączone pomyślnie.',
'Unable to link your GitHub Account.' => 'Nie można połączyć z kontem Github.',
'GitHub authentication failed' => 'Autentykacja Github nieudana',
'Your GitHub account is no longer linked to your profile.' => 'Konto Github nie jest już podłączone do twojego profilu.',
'Unable to unlink your GitHub Account.' => 'Nie można odłączyć konta Github.',
'Login with my GitHub Account' => 'Zaloguj przy użyciu konta Github',
'Link my GitHub Account' => 'Podłącz konto Github',
'Unlink my GitHub Account' => 'Odłącz konto Github',
'Your Github account was successfully linked to your profile.' => 'Konto Github podłączone pomyślnie.',
'Unable to link your Github Account.' => 'Nie można połączyć z kontem Github.',
'Github authentication failed' => 'Autentykacja Github nieudana',
'Your Github account is no longer linked to your profile.' => 'Konto Github nie jest już podłączone do twojego profilu.',
'Unable to unlink your Github Account.' => 'Nie można odłączyć konta Github.',
'Login with my Github Account' => 'Zaloguj przy użyciu konta Github',
'Link my Github Account' => 'Podłącz konto Github',
'Unlink my Github Account' => 'Odłącz konto Github',
'Created by %s' => 'Kreirao %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Poslednja izmena %e %B %Y o %k:%M',
'Tasks Export' => 'Izvoz zadataka',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maxstorlek: ',
'Unable to upload the file.' => 'Kunde inte ladda upp filen.',
'Display another project' => 'Visa ett annat projekt',
'Your GitHub account was successfully linked to your profile.' => 'Ditt GitHub-konto har anslutits till din profil.',
'Unable to link your GitHub Account.' => 'Kunde inte ansluta ditt GitHub-konto.',
'GitHub authentication failed' => 'GitHub-verifiering misslyckades',
'Your GitHub account is no longer linked to your profile.' => 'Ditt GitHub-konto är inte längre anslutet till din profil.',
'Unable to unlink your GitHub Account.' => 'Kunde inte koppla ifrån ditt GitHub-konto.',
'Login with my GitHub Account' => 'Logga in med mitt GitHub-konto',
'Link my GitHub Account' => 'Anslut mitt GitHub-konto',
'Unlink my GitHub Account' => 'Koppla ifrån mitt GitHub-konto',
'Your Github account was successfully linked to your profile.' => 'Ditt Github-konto har anslutits till din profil.',
'Unable to link your Github Account.' => 'Kunde inte ansluta ditt Github-konto.',
'Github authentication failed' => 'Github-verifiering misslyckades',
'Your Github account is no longer linked to your profile.' => 'Ditt Github-konto är inte längre anslutet till din profil.',
'Unable to unlink your Github Account.' => 'Kunde inte koppla ifrån ditt Github-konto.',
'Login with my Github Account' => 'Logga in med mitt Github-konto',
'Link my Github Account' => 'Anslut mitt Github-konto',
'Unlink my Github Account' => 'Koppla ifrån mitt Github-konto',
'Created by %s' => 'Skapad av %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'Senaste ändring %Y-%m-%d kl %H:%M',
'Tasks Export' => 'Exportera uppgifter',
@ -865,8 +865,8 @@ return array(
'By @%s on Bitbucket' => 'Av @%s på Bitbucket',
'Bitbucket Issue' => 'Bitbucket fråga',
'Commit made by @%s on Bitbucket' => 'Bidrag gjort av @%s på Bitbucket',
'Commit made by @%s on Github' => 'Bidrag gjort av @%s på GitHub',
'By @%s on Github' => 'Av @%s på GitHub',
'Commit made by @%s on Github' => 'Bidrag gjort av @%s på Github',
'By @%s on Github' => 'Av @%s på Github',
'Commit made by @%s on Gitlab' => 'Bidrag gjort av @%s på Gitlab',
'Add a comment log when moving the task between columns' => 'Lägg till en kommentarslogg när en uppgift flyttas mellan kolumner',
'Move the task to another column when the category is changed' => 'Flyttas uppgiften till en annan kolumn när kategorin ändras',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'ขนาดสูงสุด:',
'Unable to upload the file.' => 'ไม่สามารถอัพโหลดไฟล์ได้',
'Display another project' => 'แสดงโปรเจคอื่น',
'Your GitHub account was successfully linked to your profile.' => 'กิทฮับแอคเคาท์เชื่อมต่อกับประวัติเรียบร้อยแล้ว',
'Unable to link your GitHub Account.' => 'ไม่สามารถเชื่อมต่อกับกิทฮับแอคเคาท์ได้',
'GitHub authentication failed' => 'การยืนยันกิทฮับผิดพลาด',
'Your GitHub account is no longer linked to your profile.' => 'กิทฮับแอคเคาท์ไม่ได้มีการเชื่อมโยงไปยังโปรไฟล์ของคุณ',
'Unable to unlink your GitHub Account.' => 'ไม่สามารถยกเลิกการเชื่อมต่อกิทฮับแอคเคาท์ได้',
'Login with my GitHub Account' => 'เข้าใช้ด้วยกิทฮับแอคเคาท์',
'Link my GitHub Account' => 'เชื่อมกับกิทฮับแอคเคาท์',
'Unlink my GitHub Account' => 'ยกเลิกการเชื่อมกับกิทอับแอคเคาท์',
'Your Github account was successfully linked to your profile.' => 'กิทฮับแอคเคาท์เชื่อมต่อกับประวัติเรียบร้อยแล้ว',
'Unable to link your Github Account.' => 'ไม่สามารถเชื่อมต่อกับกิทฮับแอคเคาท์ได้',
'Github authentication failed' => 'การยืนยันกิทฮับผิดพลาด',
'Your Github account is no longer linked to your profile.' => 'กิทฮับแอคเคาท์ไม่ได้มีการเชื่อมโยงไปยังโปรไฟล์ของคุณ',
'Unable to unlink your Github Account.' => 'ไม่สามารถยกเลิกการเชื่อมต่อกิทฮับแอคเคาท์ได้',
'Login with my Github Account' => 'เข้าใช้ด้วยกิทฮับแอคเคาท์',
'Link my Github Account' => 'เชื่อมกับกิทฮับแอคเคาท์',
'Unlink my Github Account' => 'ยกเลิกการเชื่อมกับกิทอับแอคเคาท์',
'Created by %s' => 'สร้างโดย %s',
'Last modified on %B %e, %Y at %k:%M %p' => 'แก้ไขล่าสุดวันที่ %B %e, %Y เวลา %k:%M %p',
'Tasks Export' => 'ส่งออกงาน',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => 'Maksimum boyutu',
'Unable to upload the file.' => 'Karşıya yükleme başarısız',
'Display another project' => 'Başka bir proje göster',
'Your GitHub account was successfully linked to your profile.' => 'GitHub Hesabınız Profilinize bağlandı.',
'Unable to link your GitHub Account.' => 'GitHub hesabınızla bağ oluşturulamadı.',
// 'GitHub authentication failed' => '',
// 'Your GitHub account is no longer linked to your profile.' => '',
// 'Unable to unlink your GitHub Account.' => '',
// 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '',
'Your Github account was successfully linked to your profile.' => 'Github Hesabınız Profilinize bağlandı.',
'Unable to link your Github Account.' => 'Github hesabınızla bağ oluşturulamadı.',
// 'Github authentication failed' => '',
// 'Your Github account is no longer linked to your profile.' => '',
// 'Unable to unlink your Github Account.' => '',
// 'Login with my Github Account' => '',
// 'Link my Github Account' => '',
// 'Unlink my Github Account' => '',
'Created by %s' => '%s tarafından oluşturuldu',
'Last modified on %B %e, %Y at %k:%M %p' => 'Son değişiklik tarihi %d.%m.%Y, saati %H:%M',
'Tasks Export' => 'Görevleri dışa aktar',

View File

@ -338,14 +338,14 @@ return array(
'Maximum size: ' => '大小上限:',
'Unable to upload the file.' => '无法上传文件',
'Display another project' => '显示其它项目',
'Your GitHub account was successfully linked to your profile.' => 'GitHub账号已经成功链接到您的用户',
'Unable to link your GitHub Account.' => '无法链接到GitHub账户',
'GitHub authentication failed' => 'GitHub认证失败',
'Your GitHub account is no longer linked to your profile.' => 'Github账号已经不再链接到您的用户',
'Unable to unlink your GitHub Account.' => '无法链接GitHub账号',
'Login with my GitHub Account' => '用Github账号登录',
'Link my GitHub Account' => '链接GitHub账号',
'Unlink my GitHub Account' => '取消GitHub账号链接',
'Your Github account was successfully linked to your profile.' => 'Github账号已经成功链接到您的用户',
'Unable to link your Github Account.' => '无法链接到Github账户',
'Github authentication failed' => 'Github认证失败',
'Your Github account is no longer linked to your profile.' => 'Github账号已经不再链接到您的用户',
'Unable to unlink your Github Account.' => '无法链接Github账号',
'Login with my Github Account' => '用Github账号登录',
'Link my Github Account' => '链接Github账号',
'Unlink my Github Account' => '取消Github账号链接',
'Created by %s' => '创建者:%s',
'Last modified on %B %e, %Y at %k:%M %p' => '最后修改:%Y/%m/%d/ %H:%M',
'Tasks Export' => '任务导出',

View File

@ -18,13 +18,12 @@ class Acl extends Base
*/
private $public_acl = array(
'auth' => array('login', 'check'),
'user' => array('github'),
'task' => array('readonly'),
'board' => array('readonly'),
'webhook' => '*',
'ical' => '*',
'feed' => '*',
'oauth' => array('google'),
'oauth' => array('google', 'github'),
);
/**

View File

@ -122,13 +122,13 @@ class User extends Base
}
/**
* Get a specific user by the GitHub id
* Get a specific user by the Github id
*
* @access public
* @param string $github_id GitHub user id
* @param string $github_id Github user id
* @return array|boolean
*/
public function getByGitHubId($github_id)
public function getByGithubId($github_id)
{
if (empty($github_id)) {
return false;

View File

@ -16,12 +16,16 @@
<?= $this->form->checkbox('remember_me', t('Remember Me'), 1, true) ?><br/>
<?php if (GOOGLE_AUTH): ?>
<?= $this->url->link(t('Login with my Google Account'), 'oauth', 'google') ?>
<?php endif ?>
<?php if (GOOGLE_AUTH || GITHUB_AUTH): ?>
<ul>
<?php if (GOOGLE_AUTH): ?>
<li><?= $this->url->link(t('Login with my Google Account'), 'oauth', 'google') ?></li>
<?php endif ?>
<?php if (GITHUB_AUTH): ?>
<?= $this->url->link(t('Login with my GitHub Account'), 'user', 'gitHub') ?>
<?php if (GITHUB_AUTH): ?>
<li><?= $this->url->link(t('Login with my Github Account'), 'oauth', 'gitHub') ?></li>
<?php endif ?>
</ul>
<?php endif ?>
<div class="form-actions">

View File

@ -24,9 +24,9 @@
<p class="listing">
<?php if ($this->user->isCurrentUser($user['id'])): ?>
<?php if (empty($user['github_id'])): ?>
<?= $this->url->link(t('Link my GitHub Account'), 'user', 'github', array(), true) ?>
<?= $this->url->link(t('Link my Github Account'), 'oauth', 'github', array(), true) ?>
<?php else: ?>
<?= $this->url->link(t('Unlink my GitHub Account'), 'user', 'unlinkGitHub', array(), true) ?>
<?= $this->url->link(t('Unlink my Github Account'), 'oauth', 'unlink', array('backend' => 'github'), true) ?>
<?php endif ?>
<?php else: ?>
<?= empty($user['github_id']) ? t('No account linked.') : t('Account linked.') ?>

View File

@ -115,4 +115,8 @@ if (ENABLE_URL_REWRITE) {
// Ical routes
$container['router']->addRoute('ical/project/:token', 'ical', 'project', array('token'));
$container['router']->addRoute('ical/user/:token', 'ical', 'user', array('token'));
// Auth routes
$container['router']->addRoute('oauth/google', 'oauth', 'google');
$container['router']->addRoute('oauth/github', 'oauth', 'github');
}

View File

@ -41,7 +41,7 @@ defined('GOOGLE_AUTH') or define('GOOGLE_AUTH', false);
defined('GOOGLE_CLIENT_ID') or define('GOOGLE_CLIENT_ID', '');
defined('GOOGLE_CLIENT_SECRET') or define('GOOGLE_CLIENT_SECRET', '');
// GitHub authentication
// Github authentication
defined('GITHUB_AUTH') or define('GITHUB_AUTH', false);
defined('GITHUB_CLIENT_ID') or define('GITHUB_CLIENT_ID', '');
defined('GITHUB_CLIENT_SECRET') or define('GITHUB_CLIENT_SECRET', '');

View File

@ -11,7 +11,6 @@
"fguillot/picodb" : "1.0.0",
"fguillot/simpleLogger" : "0.0.2",
"fguillot/simple-validator" : "0.0.3",
"lusitanian/oauth" : "0.3.5",
"nickcernis/html-to-markdown" : "2.2.1",
"pimple/pimple" : "~3.0",
"swiftmailer/swiftmailer" : "@stable",

94
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "0048471872ea99cd30c53c0398c7d9f2",
"hash": "305f839bfc9c4acb5d9357e1174c42da",
"packages": [
{
"name": "christian-riesen/base32",
@ -404,68 +404,6 @@
"homepage": "https://github.com/fguillot/simpleLogger",
"time": "2015-05-30 19:25:09"
},
{
"name": "lusitanian/oauth",
"version": "v0.3.5",
"source": {
"type": "git",
"url": "https://github.com/Lusitanian/PHPoAuthLib.git",
"reference": "ac5a1cd5a4519143728dce2213936eea302edf8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/ac5a1cd5a4519143728dce2213936eea302edf8a",
"reference": "ac5a1cd5a4519143728dce2213936eea302edf8a",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"predis/predis": "0.8.*@dev",
"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."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
},
"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": "Pieter Hordijk",
"email": "info@pieterhordijk.com"
}
],
"description": "PHP 5.3+ oAuth 1/2 Library",
"keywords": [
"Authentication",
"authorization",
"oauth",
"security"
],
"time": "2014-09-05 15:19:58"
},
{
"name": "nickcernis/html-to-markdown",
"version": "2.2.1",
@ -651,16 +589,16 @@
},
{
"name": "symfony/console",
"version": "v2.7.1",
"version": "v2.7.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "564398bc1f33faf92fc2ec86859983d30eb81806"
"reference": "8cf484449130cabfd98dcb4694ca9945802a21ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806",
"reference": "564398bc1f33faf92fc2ec86859983d30eb81806",
"url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed",
"reference": "8cf484449130cabfd98dcb4694ca9945802a21ed",
"shasum": ""
},
"require": {
@ -704,20 +642,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-06-10 15:30:22"
"time": "2015-07-09 16:07:40"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.7.1",
"version": "v2.7.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
"reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9"
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9",
"reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"shasum": ""
},
"require": {
@ -762,22 +700,22 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2015-06-08 09:37:21"
"time": "2015-06-18 19:21:56"
}
],
"packages-dev": [
{
"name": "symfony/stopwatch",
"version": "v2.7.1",
"version": "v2.7.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/Stopwatch.git",
"reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b"
"reference": "b07a866719bbac5294c67773340f97b871733310"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b",
"reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b07a866719bbac5294c67773340f97b871733310",
"reference": "b07a866719bbac5294c67773340f97b871733310",
"shasum": ""
},
"require": {
@ -813,7 +751,7 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2015-06-04 20:11:48"
"time": "2015-07-01 18:23:16"
}
],
"aliases": [],

View File

@ -39,6 +39,8 @@ class AclTest extends Base
$this->assertFalse($acl->isPublicAction('board', 'show'));
$this->assertTrue($acl->isPublicAction('feed', 'project'));
$this->assertTrue($acl->isPublicAction('feed', 'user'));
$this->assertTrue($acl->isPublicAction('oauth', 'github'));
$this->assertTrue($acl->isPublicAction('oauth', 'google'));
}
public function testAdminActions()

View File

@ -0,0 +1,43 @@
<?php
require_once __DIR__.'/Base.php';
use Core\OAuth2;
class OAuth2Test extends Base
{
public function testAuthUrl()
{
$oauth = new OAuth2($this->container);
$oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
$this->assertEquals('D?response_type=code&client_id=A&redirect_uri=C&scope=f+g', $oauth->getAuthorizationUrl());
}
public function testAuthHeader()
{
$oauth = new OAuth2($this->container);
$oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
$oauth->setAccessToken('foobar', 'BeaRer');
$this->assertEquals('Authorization: Bearer foobar', $oauth->getAuthorizationHeader());
$oauth->setAccessToken('foobar', 'unknown');
$this->assertEquals('', $oauth->getAuthorizationHeader());
}
public function testAccessToken()
{
$oauth = new OAuth2($this->container);
$oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
$oauth->getAccessToken('something');
$data = $this->container['httpClient']->getData();
$this->assertEquals('something', $data['code']);
$this->assertEquals('A', $data['client_id']);
$this->assertEquals('B', $data['client_secret']);
$this->assertEquals('C', $data['redirect_uri']);
$this->assertEquals('authorization_code', $data['grant_type']);
$this->assertEquals('E', $this->container['httpClient']->getUrl());
}
}