【发布时间】:2018-03-14 19:38:18
【问题描述】:
我在使用具有自定义身份验证(不使用 FOSUserBundle)的当前应用程序为 google 登录/注册实现 HWIOAuthBundle 时遇到问题。
首先,我在尝试连接到“xxxx/connect/google”时遇到 404 错误。在哪里可以看到列出的 HWIOAuthBundle 路径,可以在我的 twig 文件中使用?
登录树枝:
<a href="{{ path('hwi_oauth_service_redirect', {'service' : 'google'}) }}"
class="google-login">Google</a>
routing.yml:
google_login:
path: /login/check-google
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
config.yml
hwi_oauth:
firewall_names: [main]
resource_owners:
google:
type: google
client_id: ?
client_secret: ?
scope: "email profile"
security.yml:
security:
providers:
db_provider:
entity:
class: AppBundle:User
property: email
my_custom_hwi_provider:
id: ib_user.oauth_user_provider
firewalls:
main:
oauth:
resource_owners:
google: "/login/check-google"
login_path: /login
failure_path: /login
oauth_user_provider:
service: ib_user.oauth_user_provider
用户.php:
class User extends OAuthUser implements UserInterface {
//added googleId attribute and setters/getter
//also added the "extends OAuthUser"
}
OAuthProvider.php 也是我新增的一个类。
【问题讨论】:
-
bin/console debug:router 应该显示可用的路由。
-
如何获得需要重定向到谷歌的 HWIOAuth 路由。我以为我在 routing.yml 上导入了它?
标签: php symfony authentication google-plus-signin hwioauthbundle