[英]HWIOAuthBundle without FOSUserBundle
我在使用具有自定义身份验证的当前应用程序(不使用FOSUserBundle)时无法为Google登录/注册实现HWIOAuthBundle。
首先,尝试连接到“ xxxx / connect / google”时出现404错误。 在哪里可以看到在树枝文件中可以使用的HWIOAuthBundle列出的路径?
登录树枝:
<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
配置文件
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
User.php:
class User extends OAuthUser implements UserInterface {
//added googleId attribute and setters/getter
//also added the "extends OAuthUser"
}
OAuthProvider.php也是我添加的新类。
如第一条评论所述,debugging routing命令为:
php bin/console debug:router
一个问题可能是缺少security.yml中用于连接的访问控制路径:
access_control:
- { path: ^/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.