我已经按照这篇文章并使用 Github 实现了 OAuth2,成功验证后,我遇到了以下错误。
找不到路径“/secure_area/login/check-github”的控制器。也许您忘记在路由配置中添加匹配的路由?
配置.yml
hwi_oauth:
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: secure_area
connect:
confirmation: true
#account_connector: hwi_oauth.user.provider.fosub_bridge
#registration_form_handler: hwi_oauth.registration.form.handler.fosub_bridge
#registration_form: fos_user.registration.form
resource_owners:
github:
type: github
client_id: a8b7e3e35e46271d10a5
client_secret: 6abca3ded9a19d9e2bf52b42f017d23a745bd540
scope: "user:email"
fosub:
# try 30 times to check if a username is available (foo, foo1, foo2 etc)
username_iterations: 30
# mapping between resource owners (see below) and properties
properties:
github: githubID
安全.yml
# app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
secure_area:
pattern: ^/secure_area
oauth:
failure_path: /secure_area/connect
login_path: /secure_area/connect
check_path: /secure_area/connect
provider: fos_userbundle
resource_owners:
github: "/secure_area/login/check-github"
oauth_user_provider:
service: hwi_oauth.user.provider.fosub_bridge
anonymous: true
logout:
path: /secure_area/logout
target: /secure_area/connect #where to go after logout
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/secure_area/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secure_area/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secure_area, roles: ROLE_USER }