diff --git a/app/AppKernel.php b/app/AppKernel.php
index f71a268..0f8e12f 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -19,6 +19,7 @@ class AppKernel extends Kernel
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new FOS\UserBundle\FOSUserBundle(),
+ new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
diff --git a/app/config/security.yml b/app/config/security.yml
index 45a873d..02a670e 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -11,6 +11,22 @@ security:
id: fos_user.user_provider.username_email
firewalls:
+ secured_area:
+ anonymous: ~
+ oauth:
+ resource_owners:
+ facebook: /login/check-facebook
+ google: /login/check-google
+ my_github: /login/check-github
+ login_path: /login
+ failure_path: /login
+ use_forward: false
+
+ oauth_user_provider:
+ service: my.custom.user_provider
+ logout:
+ path: /logout
+ target: /
main:
pattern: ^/
form_login:
@@ -22,7 +38,8 @@ security:
anonymous: true
access_control:
- - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: ^/play, role: ROLE_USER }
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
diff --git a/composer.json b/composer.json
index dac4c5b..2c0289a 100644
--- a/composer.json
+++ b/composer.json
@@ -33,7 +33,8 @@
"doctrine/doctrine-migrations-bundle": "^1.0",
"symfony/assetic-bundle": "^2.8",
"predis/predis": "^1.0",
- "snc/redis-bundle": "^2.0"
+ "snc/redis-bundle": "^2.0",
+ "hwi/oauth-bundle": "^0.5.1"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
diff --git a/composer.lock b/composer.lock
index 5f03e00..a38a9b8 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "7c1e046373c318178e58c9617d9c6931",
- "content-hash": "b09b605e8d336a4e0bf774ce6f486957",
+ "hash": "9ab894ab9dec6a53088c8bea70e8ee9a",
+ "content-hash": "06afd75cc129d2765a6803d384805417",
"packages": [
{
"name": "doctrine/annotations",
@@ -1560,6 +1560,155 @@
"abandoned": "guzzle/guzzle",
"time": "2014-05-01 21:36:02"
},
+ {
+ "name": "hwi/oauth-bundle",
+ "version": "0.5.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/hwi/HWIOAuthBundle.git",
+ "reference": "429ae3fe1641a54ea0934bb06dac355affc41f8d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/hwi/HWIOAuthBundle/zipball/429ae3fe1641a54ea0934bb06dac355affc41f8d",
+ "reference": "429ae3fe1641a54ea0934bb06dac355affc41f8d",
+ "shasum": ""
+ },
+ "require": {
+ "kriswallsmith/buzz": "~0.13",
+ "php": ">=5.3.3",
+ "symfony/form": "~2.3|~3.0",
+ "symfony/framework-bundle": "~2.3|~3.0",
+ "symfony/options-resolver": "~2.3|~3.0",
+ "symfony/security-bundle": "~2.3|~3.0",
+ "symfony/yaml": "~2.3|~3.0"
+ },
+ "conflict": {
+ "twig/twig": "<1.12"
+ },
+ "require-dev": {
+ "doctrine/orm": "~2.3",
+ "fabpot/php-cs-fixer": "~1.11",
+ "friendsofsymfony/user-bundle": "~1.3|~2.0",
+ "phpunit/phpunit": "~4.8|~5.0",
+ "symfony/phpunit-bridge": "~2.7|~3.0",
+ "symfony/property-access": "~2.3|~3.0",
+ "symfony/stopwatch": "~2.5|~3.0",
+ "symfony/twig-bundle": "~2.3|~3.0",
+ "symfony/validator": "~2.3|~3.0"
+ },
+ "suggest": {
+ "doctrine/doctrine-bundle": "to use Doctrine user provider",
+ "friendsofsymfony/user-bundle": "to connect FOSUB with this bundle",
+ "symfony/property-access": "to use FOSUB integration with this bundle",
+ "symfony/twig-bundle": "to use the Twig hwi_oauth_* functions"
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "HWI\\Bundle\\OAuthBundle\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/hwi/HWIOAuthBundle/contributors"
+ },
+ {
+ "name": "Joseph Bielawski",
+ "email": "stloyd@gmail.com"
+ },
+ {
+ "name": "Alexander",
+ "email": "iam.asm89@gmail.com"
+ },
+ {
+ "name": "Geoffrey Bachelet",
+ "email": "geoffrey.bachelet@gmail.com"
+ }
+ ],
+ "description": "Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony2.",
+ "homepage": "http://github.com/hwi/HWIOAuthBundle",
+ "keywords": [
+ "37signals",
+ "Authentication",
+ "Deezer",
+ "EVE Online",
+ "amazon",
+ "asana",
+ "auth0",
+ "azure",
+ "bitbucket",
+ "bitly",
+ "box",
+ "bufferapp",
+ "clever",
+ "dailymotion",
+ "deviantart",
+ "discogs",
+ "disqus",
+ "dropbox",
+ "eventbrite",
+ "facebook",
+ "firewall",
+ "fiware",
+ "flickr",
+ "foursquare",
+ "github",
+ "google",
+ "hubic",
+ "instagram",
+ "jawbone",
+ "jira",
+ "linkedin",
+ "mail.ru",
+ "oauth",
+ "oauth1",
+ "oauth2",
+ "odnoklassniki",
+ "paypal",
+ "qq",
+ "reddit",
+ "runkeeper",
+ "salesforce",
+ "security",
+ "sensio connect",
+ "sina weibo",
+ "slack",
+ "sound cloud",
+ "spotify",
+ "stack exchange",
+ "stereomood",
+ "strava",
+ "toshl",
+ "trakt",
+ "trello",
+ "twitch",
+ "twitter",
+ "vkontakte",
+ "wechat",
+ "windows live",
+ "wordpress",
+ "wunderlist",
+ "xing",
+ "yahoo",
+ "yandex",
+ "youtube"
+ ],
+ "time": "2016-10-03 14:27:17"
+ },
{
"name": "incenteev/composer-parameter-handler",
"version": "v2.1.2",
@@ -1738,6 +1887,54 @@
],
"time": "2015-11-12 13:51:40"
},
+ {
+ "name": "kriswallsmith/buzz",
+ "version": "v0.15",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/kriswallsmith/Buzz.git",
+ "reference": "d4041666c3ffb379af02a92dabe81c904b35fab8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/kriswallsmith/Buzz/zipball/d4041666c3ffb379af02a92dabe81c904b35fab8",
+ "reference": "d4041666c3ffb379af02a92dabe81c904b35fab8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.7.*"
+ },
+ "suggest": {
+ "ext-curl": "*"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Buzz": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Kris Wallsmith",
+ "email": "kris.wallsmith@gmail.com",
+ "homepage": "http://kriswallsmith.net/"
+ }
+ ],
+ "description": "Lightweight HTTP client",
+ "homepage": "https://github.com/kriswallsmith/Buzz",
+ "keywords": [
+ "curl",
+ "http client"
+ ],
+ "time": "2015-06-25 17:26:56"
+ },
{
"name": "monolog/monolog",
"version": "1.21.0",
diff --git a/src/Jotunheimr/UserBundle/Entity/User.php b/src/Jotunheimr/UserBundle/Entity/User.php
index ff15d04..7761f8f 100644
--- a/src/Jotunheimr/UserBundle/Entity/User.php
+++ b/src/Jotunheimr/UserBundle/Entity/User.php
@@ -21,8 +21,58 @@ class User extends BaseUser
*/
protected $id;
+ /**
+ * @ORM\Column(name="facebook_id", type="string", length=255, nullable=true)
+ */
+ private $facebookId;
+
+ private $facebookAccessToken;
+
public function __construct()
{
parent::__construct();
}
+
+ /**
+ * Set facebookId
+ *
+ * @param string $facebookId
+ *
+ * @return User
+ */
+ public function setFacebookId($facebookId)
+ {
+ $this->facebookId = $facebookId;
+
+ return $this;
+ }
+
+ /**
+ * Get facebookId
+ *
+ * @return string
+ */
+ public function getFacebookId()
+ {
+ return $this->facebookId;
+ }
+
+ /**
+ * @param string $facebookAccessToken
+ * @return User
+ */
+ public function setFacebookAccessToken($facebookAccessToken)
+ {
+ $this->facebookAccessToken = $facebookAccessToken;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFacebookAccessToken()
+ {
+ return $this->facebookAccessToken;
+ }
}
diff --git a/src/Jotunheimr/UserBundle/Entity/User.php~ b/src/Jotunheimr/UserBundle/Entity/User.php~
index ff15d04..a986803 100644
--- a/src/Jotunheimr/UserBundle/Entity/User.php~
+++ b/src/Jotunheimr/UserBundle/Entity/User.php~
@@ -21,8 +21,39 @@ class User extends BaseUser
*/
protected $id;
+ /**
+ * @ORM\Column(name="facebook_id", type="string", length=255, nullable=true)
+ */
+ private $facebookId;
+
+ private $facebookAccessToken;
+
public function __construct()
{
parent::__construct();
}
+
+ /**
+ * Set facebookId
+ *
+ * @param string $facebookId
+ *
+ * @return User
+ */
+ public function setFacebookId($facebookId)
+ {
+ $this->facebookId = $facebookId;
+
+ return $this;
+ }
+
+ /**
+ * Get facebookId
+ *
+ * @return string
+ */
+ public function getFacebookId()
+ {
+ return $this->facebookId;
+ }
}
diff --git a/src/Jotunheimr/UserBundle/Resources/config/config.yml b/src/Jotunheimr/UserBundle/Resources/config/config.yml
index 8a76787..0771f04 100644
--- a/src/Jotunheimr/UserBundle/Resources/config/config.yml
+++ b/src/Jotunheimr/UserBundle/Resources/config/config.yml
@@ -7,3 +7,16 @@ twig:
project_name: 'MineSeeker'
project_shortname: 'Mine'
project_monogram: 'MS'
+
+hwi_oauth:
+ firewall_names: [secured_area]
+ resource_owners:
+ facebook:
+ type: facebook
+ client_id: 320599508311862
+ client_secret: 18d4f48cdd274bccee2678e5eff3f557
+ scope: ""
+ options:
+ display: popup
+ auth_type: rerequest
+ csrf: true
diff --git a/src/Jotunheimr/UserBundle/Resources/config/routing.yml b/src/Jotunheimr/UserBundle/Resources/config/routing.yml
index e69de29..7517bee 100644
--- a/src/Jotunheimr/UserBundle/Resources/config/routing.yml
+++ b/src/Jotunheimr/UserBundle/Resources/config/routing.yml
@@ -0,0 +1,16 @@
+hwi_oauth_redirect:
+ resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
+ prefix: /connect
+
+hwi_oauth_login:
+ resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
+ prefix: /login
+
+facebook_login:
+ path: /login/check-facebook
+
+google_login:
+ path: /login/check-google
+
+github_login:
+ path: /login/check-github
diff --git a/src/Jotunheimr/UserBundle/Resources/config/services.yml b/src/Jotunheimr/UserBundle/Resources/config/services.yml
index 3087406..d7de31f 100644
--- a/src/Jotunheimr/UserBundle/Resources/config/services.yml
+++ b/src/Jotunheimr/UserBundle/Resources/config/services.yml
@@ -1,4 +1,4 @@
services:
-# jotunheimr_user.example:
-# class: Jotunheimr\UserBundle\Example
-# arguments: ["@service_id", "plain_value", %parameter%]
+ my.custom.user_provider:
+ class: Jotunheimr\UserBundle\Security\Core\User\MyFOSUBUserProvider
+ arguments: ['@fos_user.user_manager', { facebook: facebookId }]
diff --git a/src/Jotunheimr/UserBundle/Resources/views/Security/login.html.twig b/src/Jotunheimr/UserBundle/Resources/views/Security/login.html.twig
index e7e3a6b..ec7f77d 100644
--- a/src/Jotunheimr/UserBundle/Resources/views/Security/login.html.twig
+++ b/src/Jotunheimr/UserBundle/Resources/views/Security/login.html.twig
@@ -3,6 +3,46 @@
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
+
+
+ Facebook Connect Button (Dialog)
+
{% if error %}
{{ error.messageKey|trans(error.messageData, 'security') }}
{% endif %}
@@ -12,11 +52,11 @@
+ autofocus/>
+ />
diff --git a/src/Jotunheimr/UserBundle/Security/Core/User/MyFOSUBUserProvider.php b/src/Jotunheimr/UserBundle/Security/Core/User/MyFOSUBUserProvider.php
new file mode 100644
index 0000000..ecfd30d
--- /dev/null
+++ b/src/Jotunheimr/UserBundle/Security/Core/User/MyFOSUBUserProvider.php
@@ -0,0 +1,51 @@
+getProperty($response);
+ $username = $response->getUsername();
+
+ $existingUser = $this->userManager->findUserBy(array($property => $username));
+
+ if (null !== $existingUser) {
+ $this->userManager->updateUser($existingUser);
+ }
+
+ $this->userManager->updateUser($user);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function loadUserByOAuthUserResponse(UserResponseInterface $response)
+ {
+ $userEmail = $response->getEmail();
+ $user = $this->userManager->findUserByEmail($userEmail);
+
+ if (null === $user) {
+ $username = $response->getRealName();
+ $user = new User();
+ $user->setUsername($username);
+
+ return $user;
+ }
+
+ $serviceName = $response->getResourceOwner()->getName();
+ $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
+ $user->$setter($response->getAccessToken());
+
+ return $user;
+ }
+}
diff --git a/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig b/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig
index 7b2f1e8..acc60be 100644
--- a/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig
+++ b/src/Mine/SeekerBundle/Resources/views/Game/index.html.twig
@@ -1 +1,5 @@
-Bazmeg index.
\ No newline at end of file
+{% extends "::base.html.twig" %}
+
+{% block body %}
+ Bazmeg index.
+{% endblock %}