我想使用FOSFacebookBundle和FOSUserBundle来管理:
我使用Propel作为ORM,使用AdminGeneratorGeneratorBundle来管理后台。 我已经覆盖了FOSUserBundle的propel的schema.yml文件来添加特定的“facebook字段”。
该过程适用于前端,但是当我尝试访问“/ admin”URL时,它无法正常工作。我有“登录”页面但是当我输入登录名/密码时,我正在重定向到Facebook连接页面...
它只是配置文件配置错误还是我的错误方式满足了我的需求?
这是我的配置文件:
security.yml
security:
providers:
fos_userbundle:
id: fos_user.user_provider.username
fos_facebook_provider:
id: my.facebook.user
encoders:
FOS\UserBundle\Model\UserInterface: sha512
firewalls:
# Firewall public / FB Connect
public:
# since anonymous is allowed users will not be forced to login
pattern: ^/.*
fos_facebook:
provider: fos_facebook_provider
app_url: "http://apps.facebook.com/fb-localhost-testing/"
server_url: "http://localhost/fb-localhost-testing/"
anonymous: true
# Firewall zone admin
admin_area:
pattern: ^/admin
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: /admin/login
check_path: /admin/login_check
default_target_path: /admin/
logout:
path: /admin/logout
target: /admin/login
anonymous: true
access_control:
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/connected/.*, role: [ROLE_FACEBOOK] }
- { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
config.yml
# FOSUser Configuration
fos_user:
user_class: FOS\UserBundle\Propel\User
db_driver: propel
firewall_name: main
# FOSFacebook Configuration
fos_facebook:
alias: fb-localhost-testing
app_id: mmyid
secret: mysecret
cookie: true
permissions: [email, user_birthday, user_location]
services:
my.facebook.user:
class: MyProject\Security\User\Provider\FacebookProvider
arguments:
facebook: "@fos_facebook.api"
userManager: "@fos_user.user_manager"
validator: "@validator"
答案 0 :(得分:0)
解决方案:我们需要在全局模式之前定义特定模式。
要解决我的问题,我只需将2个防火墙块切换为公共和admin_area: