diff --git a/README.md b/README.md index 13ef44d6..5cbf3b53 100644 --- a/README.md +++ b/README.md @@ -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] diff --git a/autoload_classmap.php b/autoload_classmap.php index 37ccacc1..c4a829a9 100644 --- a/autoload_classmap.php +++ b/autoload_classmap.php @@ -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', diff --git a/config/scn-social-auth.global.php.dist b/config/scn-social-auth.global.php.dist index 20cb9a59..7c569374 100644 --- a/config/scn-social-auth.global.php.dist +++ b/config/scn-social-auth.global.php.dist @@ -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 * diff --git a/config/scn-social-auth.local.php.dist b/config/scn-social-auth.local.php.dist index 419b52d6..68401989 100644 --- a/config/scn-social-auth.local.php.dist +++ b/config/scn-social-auth.local.php.dist @@ -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 * diff --git a/src/ScnSocialAuth/Authentication/Adapter/HybridAuth.php b/src/ScnSocialAuth/Authentication/Adapter/HybridAuth.php index 932e4dda..a3771bee 100644 --- a/src/ScnSocialAuth/Authentication/Adapter/HybridAuth.php +++ b/src/ScnSocialAuth/Authentication/Adapter/HybridAuth.php @@ -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)) { diff --git a/src/ScnSocialAuth/HybridAuth/Provider/BitBucket.php b/src/ScnSocialAuth/HybridAuth/Provider/BitBucket.php new file mode 100644 index 00000000..2b4dc0f5 --- /dev/null +++ b/src/ScnSocialAuth/HybridAuth/Provider/BitBucket.php @@ -0,0 +1,14 @@ +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; + } } diff --git a/src/ScnSocialAuth/Service/HybridAuthFactory.php b/src/ScnSocialAuth/Service/HybridAuthFactory.php index 8f4df705..16b26ee3 100644 --- a/src/ScnSocialAuth/Service/HybridAuthFactory.php +++ b/src/ScnSocialAuth/Service/HybridAuthFactory.php @@ -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(