Skip to content

Commit

Permalink
Excluse secret from source
Browse files Browse the repository at this point in the history
  • Loading branch information
ytorres committed Jul 28, 2014
1 parent 68fe9b4 commit 3bdbbb6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 65 deletions.
28 changes: 16 additions & 12 deletions index.php
Expand Up @@ -3,6 +3,7 @@
session_start();

require_once dirname(__FILE__) . '/php/html.templates.php';
require_once dirname(__FILE__) . '/php/Conf.php';
require_once dirname(__FILE__) . '/php/oauth.php';

// Perm link management
Expand Down Expand Up @@ -100,6 +101,8 @@
// Log the user in if needed
if (!isset($_SESSION['userID']))
{
$Conf = Config::getInstance()->getConf();

// Init var
if( !isset($_SESSION['oauth']) ) $_SESSION['oauth'] = array();

Expand All @@ -108,14 +111,14 @@

$_SESSION['oauth']['identService'] = 'instagram';

$instagram = new Oauth_instagram();
$instagram = new Oauth_instagram($Conf['GLOBAL_CONFIGURATION']['oauth.instagram.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.instagram.clientSecret']);

$instagram->RequestCode();
}

if( isset($_SESSION['oauth']['identService']) && $_SESSION['oauth']['identService'] == 'instagram' && isset($_GET['code']) ) {

$instagram = new Oauth_instagram();
$instagram = new Oauth_instagram($Conf['GLOBAL_CONFIGURATION']['oauth.instagram.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.instagram.clientSecret']);
$access_token = $instagram->RequestToken($_GET['code']);

$jsVar .= "
Expand All @@ -133,14 +136,15 @@

$_SESSION['oauth']['identService'] = 'github';

$git = new Oauth_github();
$git = new Oauth_github($Conf['GLOBAL_CONFIGURATION']['oauth.github.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.github.clientSecret']);

$git->RequestCode();
}

if( isset($_SESSION['oauth']['identService']) && $_SESSION['oauth']['identService'] == 'github' && isset($_GET['code']) ) {

$git = new Oauth_github();
$git = new Oauth_github($Conf['GLOBAL_CONFIGURATION']['oauth.github.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.github.clientSecret']);

$access_token = $git->RequestToken($_GET['code']);
$user = $git->getUserInfo($access_token);

Expand All @@ -160,14 +164,14 @@

$_SESSION['oauth']['identService'] = 'stackoverflow';

$stack = new Oauth_stackoverflow();
$stack = new Oauth_stackoverflow($Conf['GLOBAL_CONFIGURATION']['oauth.stackoverflow.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.stackoverflow.clientSecret'], $Conf['GLOBAL_CONFIGURATION']['oauth.stackoverflow.clientKey']);

$stack->RequestCode();
}

if( isset($_SESSION['oauth']['identService']) && $_SESSION['oauth']['identService'] == 'stackoverflow' && isset($_GET['code']) ) {

$stack = new Oauth_stackoverflow();
$stack = new Oauth_stackoverflow($Conf['GLOBAL_CONFIGURATION']['oauth.stackoverflow.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.stackoverflow.clientSecret'], $Conf['GLOBAL_CONFIGURATION']['oauth.stackoverflow.clientKey']);
$access_token = $stack->RequestToken($_GET['code']);

$user = $stack->getUserInfo($access_token);
Expand All @@ -188,14 +192,14 @@

$_SESSION['oauth']['identService'] = 'facebook';

$facebook = new Oauth_facebook();
$facebook = new Oauth_facebook($Conf['GLOBAL_CONFIGURATION']['oauth.facebook.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.facebook.clientSecret']);

$facebook->RequestCode();
}

if( isset($_SESSION['oauth']['identService']) && $_SESSION['oauth']['identService'] == 'facebook' && isset($_GET['code']) ) {

$facebook = new Oauth_facebook();
$facebook = new Oauth_facebook($Conf['GLOBAL_CONFIGURATION']['oauth.facebook.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.facebook.clientSecret']);
$access_token = $facebook->RequestToken($_GET['code']);

$user = $facebook->getUserInfo($access_token);
Expand All @@ -217,14 +221,14 @@

$_SESSION['oauth']['identService'] = 'google';

$google = new Oauth_google();
$google = new Oauth_google($Conf['GLOBAL_CONFIGURATION']['oauth.google.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.google.clientSecret']);

$google->RequestCode();
}

if( isset($_SESSION['oauth']['identService']) && $_SESSION['oauth']['identService'] == 'google' && isset($_GET['code']) ) {

$google = new Oauth_google();
$google = new Oauth_google($Conf['GLOBAL_CONFIGURATION']['oauth.google.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.google.clientSecret']);
$access_token = $google->RequestToken($_GET['code']);

$user = $google->getUserInfo($access_token);
Expand All @@ -246,14 +250,14 @@

$_SESSION['oauth']['identService'] = 'linkedin';

$linkedin = new Oauth_linkedin();
$linkedin = new Oauth_linkedin($Conf['GLOBAL_CONFIGURATION']['oauth.linkedin.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.linkedin.clientSecret']);

$linkedin->RequestCode();
}

if( isset($_SESSION['oauth']['identService']) && $_SESSION['oauth']['identService'] == 'linkedin' && isset($_GET['code']) ) {

$linkedin = new Oauth_linkedin();
$linkedin = new Oauth_linkedin($Conf['GLOBAL_CONFIGURATION']['oauth.linkedin.clientID'], $Conf['GLOBAL_CONFIGURATION']['oauth.linkedin.clientSecret']);
$access_token = $linkedin->RequestToken($_GET['code']);

$user = $linkedin->getUserInfo($access_token);
Expand Down
73 changes: 20 additions & 53 deletions php/oauth.php
@@ -1,5 +1,4 @@
<?php

class Oauth_github
{
public $redirect_uri;
Expand All @@ -9,21 +8,15 @@ class Oauth_github
public $serveurURL;
public $userInfoURL;

public function __construct() {
public function __construct($clientID, $clientSecret) {

$this->serveurURL = 'https://github.com/login/oauth/authorize';
$this->tokenURL = 'https://github.com/login/oauth/access_token';
$this->userInfoURL = 'https://api.github.com/user';

// Dev - OK
//$this->redirect_uri = 'http://phpdoc.local/';
//$this->clientID = 'cd59e5a636c4f0de0f79';
//$this->clientSecret = '4ef43189760ae9889539507a76f3b5f7aea02c77';

// Prod - OK
$this->redirect_uri = 'https://edit.php.net/';
$this->clientID = '5ca48f6dadff47ffe5b4';
$this->clientSecret = '0f6b44d38340150e58d17d5d45d31c55a5130ce7';
$this->clientID = $clientID;
$this->clientSecret = $clientSecret;
}

public function RequestCode() {
Expand Down Expand Up @@ -95,23 +88,17 @@ class Oauth_stackoverflow
public $serveurURL;
public $userInfoURL;

public function __construct() {
public function __construct($clientID, $clientSecret, $clientKey) {

$this->serveurURL = 'https://stackexchange.com/oauth';
$this->tokenURL = 'https://stackexchange.com/oauth/access_token';
$this->userInfoURL = 'https://api.stackexchange.com/me';

// Dev - OK
//$this->redirect_uri = 'http://phpdoc.local/';
//$this->clientID = '3333';
//$this->clientSecret = '8y7KkcWXYil*DOGMF)bL*g((';
//$this->clientKey = 'Peqo3*0QVMQbPpw*YvKkrw((';

// Prod - OK
$this->redirect_uri = 'https://edit.php.net/';
$this->clientID = '3338';
$this->clientSecret = 'tPjwsBG6Qawkr7eOgl)Luw((';
$this->clientKey = 'taHVAxpz*cMJyTCHACkixA((';
$this->clientID = $clientID;
$this->clientSecret = $clientSecret;
$this->clientKey = $clientKey;
}

public function RequestCode() {
Expand Down Expand Up @@ -184,21 +171,16 @@ class Oauth_facebook
public $serveurURL;
public $userInfoURL;

public function __construct() {
public function __construct($clientID, $clientSecret) {

$this->serveurURL = 'https://www.facebook.com/dialog/oauth';
$this->tokenURL = 'https://graph.facebook.com/oauth/access_token';
$this->userInfoURL = 'https://graph.facebook.com/me';

// Dev - OK
//$this->redirect_uri = 'http://phpdoc.local/';
//$this->clientID = '687771861310348';
//$this->clientSecret = '482d1d6df9981e3e6d8350da8a166edc';

// Prod
// Prod - OK
$this->redirect_uri = 'https://edit.php.net/';
$this->clientID = '128417830579090';
$this->clientSecret = '2e18fd9adfc219ddb85031fe08f481d9';
$this->clientID = $clientID;
$this->clientSecret = $clientSecret;
}

public function RequestCode() {
Expand Down Expand Up @@ -271,21 +253,16 @@ class Oauth_google
public $serveurURL;
public $userInfoURL;

public function __construct() {
public function __construct($clientID, $clientSecret) {

$this->serveurURL = 'https://accounts.google.com/o/oauth2/auth';
$this->tokenURL = 'https://accounts.google.com/o/oauth2/token';
$this->userInfoURL = 'https://www.googleapis.com/plus/v1/people/me';

// Dev - OK
//$this->redirect_uri = 'http://localhost/';
//$this->clientID = '175713024907-23ur2ii7e6eupirce8u72c4su9c682dq.apps.googleusercontent.com';
//$this->clientSecret = '_Lm3fJcvS8Ubct4z_dJ3OJzq';

// Prod
$this->redirect_uri = 'https://edit.php.net/';
$this->clientID = '100526866357.apps.googleusercontent.com';
$this->clientSecret = 'FcKf36077Rco6S2xvdad9-WG';
$this->clientID = $clientID;
$this->clientSecret = $clientSecret;
}

public function RequestCode() {
Expand Down Expand Up @@ -359,22 +336,17 @@ class Oauth_linkedin
public $serveurURL;
public $userInfoURL;

public function __construct() {
public function __construct($clientID, $clientSecret) {

$this->serveurURL = 'https://www.linkedin.com/uas/oauth2/authorization';
$this->tokenURL = 'https://www.linkedin.com/uas/oauth2/accessToken';
$this->userInfoURLEmail = 'https://api.linkedin.com/v1/people/~/email-address';
$this->userInfoURL = 'https://api.linkedin.com/v1/people/~:(firstName,lastName)';

// Dev - OK
//$this->redirect_uri = 'http://phpdoc.local/';
//$this->clientID = '77jy88t0ioyi51';
//$this->clientSecret = 'FglhuuI0g7IjiYZQ';

// Prod - OK
$this->redirect_uri = 'https://edit.php.net/';
$this->clientID = '77x6uic1m4ilry';
$this->clientSecret = 'KFsgABtaBLuWX3sf';
$this->clientID = $clientID;
$this->clientSecret = $clientSecret;
}

public function RequestCode() {
Expand Down Expand Up @@ -469,21 +441,16 @@ class Oauth_instagram
public $serveurURL;
public $userInfoURL;

public function __construct() {
public function __construct($clientID, $clientSecret) {

$this->serveurURL = 'https://api.instagram.com/oauth/authorize/';
$this->tokenURL = 'https://api.instagram.com/oauth/access_token';
$this->userInfoURL = 'https://api.instagram.com/v1/user';

// Dev - OK
//$this->redirect_uri = 'http://phpdoc.local/';
//$this->clientID = 'a6f32c43608648c2aca7ab29d2300dd4';
//$this->clientSecret = 'c5a9f895cdc9414ea5a8d82cfddfd975';

// Prod - OK
$this->redirect_uri = 'https://edit.php.net/';
$this->clientID = '3e83439913b441829396fd009dcee1b3';
$this->clientSecret = '01d24b054bda44c4946eeca3629b3f8d';
$this->clientID = $clientID;
$this->clientSecret = $clientSecret;
}

public function RequestCode() {
Expand Down

0 comments on commit 3bdbbb6

Please sign in to comment.