在 security.yml 中:
providers:
chain_provider:
chain:
providers: [my_fos_facebook_provider, fos_userbundle]
my_fos_facebook_provider:
id: my.facebook.user
fos_userbundle:
id: fos_user.user_manager
firewalls:
admin:
pattern: /admin(.*)
form_login:
provider: fos_userbundle
login_path: /admin/login
use_forward: false
check_path: /admin/login_check
failure_path: null
logout:
path: /admin/logout
anonymous: true
public:
# since anonymous is allowed users will not be forced to login
pattern: ^/.*
fos_facebook:
provider: my_fos_facebook_provider
app_url: "http://www.facebook.com/apps/application.php?id=your_app_id"
server_url: "http://localhost/facebookApp/"
login_path: /
check_path: /login_check_fb
default_target_path: /moi
anonymous: true
logout:
handlers: ["fos_facebook.logout_handler"]
这个想法是通过运行磨坊用户名和密码访问管理员,普通用户通过 Facebook 登录。
现在,关键部分是定义多个提供者(我有),但也许最重要的是在每个防火墙中指定“提供者”。fos_userbundle 用于管理员,my_fos_facebook_provider 用于公共