Skip to content

Commit

Permalink
Merge branch 'gabrielsomoza-bitbucket'
Browse files Browse the repository at this point in the history
  • Loading branch information
SocalNick committed Apr 13, 2015
2 parents 60588d1 + 582df67 commit 7862cbb
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Features
* Login with Facebook [COMPLETE]
* Login with Foursquare [COMPLETE]
* Login with Github [COMPLETE]
* Login with BitBucket [COMPLETE]
* Login with Google [COMPLETE]
* Login with LinkedIn [COMPLETE]
* Login with Live [INCOMPLETE]
Expand Down
1 change: 1 addition & 0 deletions autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'ScnSocialAuth\Controller\UserController' => __DIR__ . '/src/ScnSocialAuth/Controller/UserController.php',
'ScnSocialAuth\Entity\UserProvider' => __DIR__ . '/src/ScnSocialAuth/Entity/UserProvider.php',
'ScnSocialAuth\Entity\UserProviderInterface' => __DIR__ . '/src/ScnSocialAuth/Entity/UserProviderInterface.php',
'ScnSocialAuth\HybridAuth\Provider\BitBucket' => __DIR__ . '/src/ScnSocialAuth/HybridAuth/Provider/BitBucket.php',
'ScnSocialAuth\HybridAuth\Provider\GitHub' => __DIR__ . '/src/ScnSocialAuth/HybridAuth/Provider/GitHub.php',
'ScnSocialAuth\HybridAuth\Provider\Tumblr' => __DIR__ . '/src/ScnSocialAuth/HybridAuth/Provider/Tumblr.php',
'ScnSocialAuth\HybridAuth\Provider\Mailru' => __DIR__ . '/src/ScnSocialAuth/HybridAuth/Provider/Mailru.php',
Expand Down
7 changes: 7 additions & 0 deletions config/scn-social-auth.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ $settings = array(
*/
//'user_provider_entity_class' => 'ScnSocialAuth\Entity\UserProvider',

/**
* BitBucket Enabled
*
* Please specify if BitBucket is enabled
*/
//'bitbucket_enabled' => true,

/**
* Facebook Enabled
*
Expand Down
10 changes: 10 additions & 0 deletions config/scn-social-auth.local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
* drop this config file in it and change the values as you wish.
*/
$settings = array(
/**
* BitBucket Client ID
*/
//'bitbucket_key' => 'your-bitbucket-client-id',

/**
* BitBucket Secret
*/
//'bitbucket_secret' => 'your-bitbucket-client-secret',

/**
* Facebook Client ID
*
Expand Down
16 changes: 16 additions & 0 deletions src/ScnSocialAuth/Authentication/Adapter/HybridAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ protected function instantiateLocalUser()

// Provider specific methods

/**
* BitBucket to Local User
* @param $userProfile
* @return mixed
*/
protected function bitbucketToLocalUser($userProfile)
{
$localUser = $this->instantiateLocalUser();
$localUser->setDisplayName($userProfile->displayName)
->setPassword(__FUNCTION__)
->setEmail($userProfile->email);
$this->insert($localUser, 'github', $userProfile);

return $localUser;
}

protected function facebookToLocalUser($userProfile)
{
if (!isset($userProfile->emailVerified) || empty($userProfile->emailVerified)) {
Expand Down
14 changes: 14 additions & 0 deletions src/ScnSocialAuth/HybridAuth/Provider/BitBucket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: gabrielsomoza
* Date: 02/03/15
* Time: 09:22
*/

namespace ScnSocialAuth\HybridAuth\Provider;

/**
* This is simply to trigger autoloading as a hack for poor design in HybridAuth.
*/
class BitBucket extends \Hybrid_Providers_BitBucket {}
63 changes: 63 additions & 0 deletions src/ScnSocialAuth/Options/ModuleOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ModuleOptions extends AbstractOptions
protected $__strictMode__ = false;

protected $providers = array(
'bitbucket',
'facebook',
'foursquare',
'github',
Expand Down Expand Up @@ -281,6 +282,21 @@ class ModuleOptions extends AbstractOptions
*/
protected $debugFile = "/tmp/hybridauth.log";

/**
* @var string
*/
protected $bitbucketEnabled = false;

/**
* @var string
*/
protected $bitbucketKey;

/**
* @var string
*/
protected $bitbucketSecret;

/**
* get an array of enabled providers
*
Expand Down Expand Up @@ -1342,4 +1358,51 @@ public function setDebugFile($debugFile)
$this->debugFile = (string) $debugFile;
}

/**
* @return boolean
*/
public function getBitbucketEnabled()
{
return $this->bitbucketEnabled;
}

/**
* @param boolean $bitbucketEnabled
*/
public function setBitbucketEnabled($bitbucketEnabled)
{
$this->bitbucketEnabled = $bitbucketEnabled;
}

/**
* @return string
*/
public function getBitbucketKey()
{
return $this->bitbucketKey;
}

/**
* @param string $bitbucketKey
*/
public function setBitbucketKey($bitbucketKey)
{
$this->bitbucketKey = $bitbucketKey;
}

/**
* @return string
*/
public function getBitbucketSecret()
{
return $this->bitbucketSecret;
}

/**
* @param string $bitbucketSecret
*/
public function setBitbucketSecret($bitbucketSecret)
{
$this->bitbucketSecret = $bitbucketSecret;
}
}
12 changes: 12 additions & 0 deletions src/ScnSocialAuth/Service/HybridAuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ public function createService(ServiceLocatorInterface $services)
"debug_mode" => $options->getDebugMode(),
"debug_file" => $options->getDebugFile(),
'providers' => array(
'BitBucket' => array(
'enabled' => $options->getBitbucketEnabled(),
'keys' => array(
'key' => $options->getBitbucketKey(),
'secret' => $options->getBitbucketSecret(),
),
'scope' => '',
'wrapper' => array(
'class' => 'Hybrid_Providers_BitBucket',
'path' => realpath(__DIR__ . '/../HybridAuth/Provider/BitBucket.php'),
),
),
'Facebook' => array(
'enabled' => $options->getFacebookEnabled(),
'keys' => array(
Expand Down

0 comments on commit 7862cbb

Please sign in to comment.