我想安装Symfony2.1与HWIOAuthBundle来处理谷歌oauth身份验证。Symfony2.1 - HWIOAuthBundle和谷歌oauth身份验证
我已经按照包中的手册说明进行了描述,但仍然缺少一些东西。当我访问需要经过身份验证的用户的操作时(或者只输入url/connect/google),我将被重定向到Google身份验证页面 - 此部分正在工作。但在重定向后(在登录Google并同意共享我的数据后),新用户不会在数据库中创建,并且我被重定向到连接/失败操作。 Google认证应该只是认证用户的一种方式。任何想法可能是错的?
这是我的路由:
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
google_login:
pattern: /login/check-google
security.yml
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
secured_area:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: /connect/google
check_path: /login/login_check
logout: true
anonymous: true
oauth:
resource_owners:
google: "/login/check-google"
login_path: /connect/google
failure_path: /connect-fail
# FOSUB integration
oauth_user_provider:
service: hwi_oauth.user.provider.fosub_bridge
和配置
hwi_oauth:
firewall_name: secured_area
resource_owners:
google:
type: google
client_id: ....
client_secret: ......
scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
fosub:
username_iterations: 5
properties:
google: googleId
谷歌的redirectUrl
http://xxxx/login/check-google
我的用户实体:
class User extends BaseUser
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var integer $id
*
* @ORM\Column(name="google_id", type="integer")
*/
protected $googleId;
//编辑 - 更新
我只是在Symfony的日志,我已经从谷歌一个请求重定向发现: GET http://xxxxx.dk/login/check-google?code=4%2F8tiDAhI45D2g7BvrdtwoF7wJ.Eu7i2fmkYOl05ti8ZT3YDrXXXXXfakeXXXE4hcwI之前重定向到/连接文件
不幸的是,它看起来该请求只试图从我的数据库中检索用户google_id SELECT * FROM app_user t0 WHERE t0.googleId =?限制1:['123456789']但该用户在那里不存在。
我是否应该创建用户befor我试图验证他/她?