oauth google
This commit is contained in:
parent
dfb4fbd340
commit
936a8febe6
|
@ -111,7 +111,16 @@
|
|||
|
||||
|
||||
{% else %}
|
||||
|
||||
{#<a class="btn btn-default btn-block btn-twitter" href="{{ hwi_oauth_login_url('disqus') }}">#}
|
||||
{#<i class="fa fa-google"></i>#}
|
||||
{#Via {{ 'disqus' | trans({}, 'HWIOAuthBundle') }}#}
|
||||
{#</a>#}
|
||||
<h1 class="text-right">
|
||||
<a class="btn btn-default" href="{{ hwi_oauth_login_url('google') }}">
|
||||
<i class="fa fa-google"></i>
|
||||
Via {{ 'google' | trans({}, 'HWIOAuthBundle') }}
|
||||
</a>
|
||||
<a class="btn btn-primary"
|
||||
href="{{ path('fos_user_security_login') }}">
|
||||
<i class="fa fa-key"></i>
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
hwi_oauth_redirect:
|
||||
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
|
||||
prefix: /connect
|
||||
|
||||
hwi_oauth_connect:
|
||||
resource: "@HWIOAuthBundle/Resources/config/routing/connect.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
|
||||
|
||||
disqus_login:
|
||||
path: /login/check-disqus
|
||||
|
||||
twitter_login:
|
||||
path: /login/check-twitter
|
||||
|
||||
## app specific stuff
|
||||
app_festival:
|
||||
resource: "@AppBundle/Controller/FestivalController.php"
|
||||
type: annotation
|
||||
|
@ -14,29 +39,6 @@ app_sell_record:
|
|||
resource: "@AppBundle/Controller/SellRecordController.php"
|
||||
type: annotation
|
||||
|
||||
hwi_oauth_redirect:
|
||||
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
|
||||
prefix: /connect
|
||||
|
||||
hwi_oauth_connect:
|
||||
resource: "@HWIOAuthBundle/Resources/config/routing/connect.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
|
||||
|
||||
custom_login:
|
||||
path: /login/check-custom
|
||||
|
||||
twitter_login:
|
||||
path: /login/check-twitter
|
||||
|
||||
app:
|
||||
resource: '@AppBundle/Controller/'
|
||||
type: annotation
|
||||
|
|
|
@ -34,6 +34,7 @@ security:
|
|||
resource_owners:
|
||||
facebook: "/login/check-facebook"
|
||||
google: "/login/check-google"
|
||||
disqus: "/login/check-disqus"
|
||||
# my_custom_provider: "/login/check-custom"
|
||||
twitter: "/login/check-twitter"
|
||||
login_path: /login
|
||||
|
|
|
@ -33,8 +33,13 @@ services:
|
|||
# AppBundle\Service\ExampleService:
|
||||
# arguments:
|
||||
# $someArgument: 'some_value'
|
||||
# OAUTH
|
||||
my.oauth_aware.user_provider.service:
|
||||
class: HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider
|
||||
arguments:
|
||||
- '@fos_user.user_manager'
|
||||
- ['pass properties as array']
|
||||
|
||||
my.custom.user_provider:
|
||||
class: MyBundle\Security\Core\User\MyFOSUBUserProvider
|
||||
arguments: ['@fos_user.user_manager', { facebook: facebook_id }]
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
"doctrine/doctrine-bundle": "^1.6",
|
||||
"doctrine/orm": "^2.5",
|
||||
"friendsofsymfony/user-bundle": "~2.0",
|
||||
"hwi/oauth-bundle": "^0.6.1",
|
||||
"hwi/oauth-bundle": "^0.6.2",
|
||||
"incenteev/composer-parameter-handler": "^2.0",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"php-http/httplug-bundle": "^1.9",
|
||||
"php-http/httplug-bundle": "^1.10",
|
||||
"sensio/distribution-bundle": "^5.0.19",
|
||||
"sensio/framework-extra-bundle": "^5.0.0",
|
||||
"symfony/monolog-bundle": "^3.1.0",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c18164d1db85ea9fbbe32f2bfbea9ebc",
|
||||
"content-hash": "340327e74f4d3713baf607c9a61fc0e9",
|
||||
"packages": [
|
||||
{
|
||||
"name": "clue/stream-filter",
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Security\Core\User;
|
||||
|
||||
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
|
||||
use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseFOSUBProvider;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class MyFOSUBUserProvider extends BaseFOSUBProvider {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect( UserInterface $user, UserResponseInterface $response ) {
|
||||
// get property from provider configuration by provider name
|
||||
// , it will return `facebook_id` in that case (see service definition below)
|
||||
$property = $this->getProperty( $response );
|
||||
$username = $response->getUsername(); // get the unique user identifier
|
||||
|
||||
//we "disconnect" previously connected users
|
||||
$existingUser = $this->userManager->findUserBy( [ $property => $username ] );
|
||||
if ( null !== $existingUser ) {
|
||||
// set current user id and token to null for disconnect
|
||||
// ...
|
||||
|
||||
$this->userManager->updateUser( $existingUser );
|
||||
}
|
||||
// we connect current user, set current user id and token
|
||||
// ...
|
||||
$this->userManager->updateUser( $user );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadUserByOAuthUserResponse( UserResponseInterface $response ) {
|
||||
$userEmail = $response->getEmail();
|
||||
$user = $this->userManager->findUserByEmail( $userEmail );
|
||||
|
||||
// if null just create new user and set it properties
|
||||
if ( null === $user ) {
|
||||
$username = $response->getRealName();
|
||||
$user = new User();
|
||||
$user->setUsername( $username );
|
||||
|
||||
// ... save user to database
|
||||
|
||||
return $user;
|
||||
}
|
||||
// else update access token of existing user
|
||||
$serviceName = $response->getResourceOwner()->getName();
|
||||
$setter = 'set' . ucfirst( $serviceName ) . 'AccessToken';
|
||||
$user->$setter( $response->getAccessToken() );//update access token
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
|
@ -148,7 +148,7 @@ class PhpIniRequirement extends Requirement
|
|||
}
|
||||
|
||||
if (null === $helpHtml) {
|
||||
$helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a class="btn btn-primary" href="#phpini">*</a>.',
|
||||
$helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a href="#phpini">*</a>.',
|
||||
$cfgName,
|
||||
$evaluation ? 'on' : 'off'
|
||||
);
|
||||
|
@ -419,7 +419,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
$this->addRequirement(
|
||||
is_dir(__DIR__.'/../vendor/composer'),
|
||||
'Vendor libraries must be installed',
|
||||
'Vendor libraries are missing. Install composer following instructions from <a class="btn btn-primary" href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
|
||||
'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
|
||||
'Then run "<strong>php composer.phar install</strong>" to install them.'
|
||||
);
|
||||
|
||||
|
@ -443,7 +443,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
$this->addPhpIniRequirement(
|
||||
'date.timezone', true, false,
|
||||
'date.timezone setting must be set',
|
||||
'Set the "<strong>date.timezone</strong>" setting in php.ini<a class="btn btn-primary" href="#phpini">*</a> (like Europe/Paris).'
|
||||
'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
$this->addRequirement(
|
||||
isset($timezones[@date_default_timezone_get()]),
|
||||
sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()),
|
||||
'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a class="btn btn-primary" href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.'
|
||||
'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'),
|
||||
false,
|
||||
'suhosin.executor.include.whitelist must be configured correctly in php.ini',
|
||||
'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a class="btn btn-primary" href="#phpini">*</a>.'
|
||||
'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
create_function('$cfgValue', 'return $cfgValue > 100;'),
|
||||
true,
|
||||
'xdebug.max_nesting_level should be above 100 in php.ini',
|
||||
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a class="btn btn-primary" href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.'
|
||||
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
create_function('$cfgValue', 'return (int) $cfgValue === 0;'),
|
||||
true,
|
||||
'string functions should not be overloaded',
|
||||
'Set "<strong>mbstring.func_overload</strong>" to <strong>0</strong> in php.ini<a class="btn btn-primary" href="#phpini">*</a> to disable function overloading by the mbstring extension.'
|
||||
'Set "<strong>mbstring.func_overload</strong>" to <strong>0</strong> in php.ini<a href="#phpini">*</a> to disable function overloading by the mbstring extension.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
create_function('$cfgValue', 'return (int) $cfgValue === 0;'),
|
||||
true,
|
||||
'intl.error_level should be 0 in php.ini',
|
||||
'Set "<strong>intl.error_level</strong>" to "<strong>0</strong>" in php.ini<a class="btn btn-primary" href="#phpini">*</a> to inhibit the messages when an error occurs in ICU functions.'
|
||||
'Set "<strong>intl.error_level</strong>" to "<strong>0</strong>" in php.ini<a href="#phpini">*</a> to inhibit the messages when an error occurs in ICU functions.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -735,7 +735,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
$this->addRecommendation(
|
||||
$this->getRealpathCacheSize() >= 5 * 1024 * 1024,
|
||||
'realpath_cache_size should be at least 5M in php.ini',
|
||||
'Setting "<strong>realpath_cache_size</strong>" to e.g. "<strong>5242880</strong>" or "<strong>5M</strong>" in php.ini<a class="btn btn-primary" href="#phpini">*</a> may improve performance on Windows significantly in some cases.'
|
||||
'Setting "<strong>realpath_cache_size</strong>" to e.g. "<strong>5242880</strong>" or "<strong>5M</strong>" in php.ini<a href="#phpini">*</a> may improve performance on Windows significantly in some cases.'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -410,7 +410,7 @@ $hasMinorProblems = (bool) count($minorProblems);
|
|||
|
||||
<ul class="symfony-install-continue">
|
||||
<?php if ($hasMajorProblems || $hasMinorProblems): ?>
|
||||
<li><a class="btn btn-primary" href="config.php">Re-check configuration</a></li>
|
||||
<li><a href="config.php">Re-check configuration</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue