我使用HWIOAuthBundle设置Facebook登录信息但我正在运行路径:
http://localhost:8000/connect或
http://localhost:8000/connect/check-facebook
他无法加载页面而没有错误消息只是网页浏览器错误
:ERR_TOO_MANY_REDIRECTS
的routing.yml
api:
resource: '.'
type: 'api_platform'
app:
resource: '@AppBundle/Action/'
type: 'annotation'
api_login_check:
path: /api/login_check
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: /connect
facebook_login:
path: /connect/check-facebook
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /account/register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_READER: ROLE_USER
ROLE_ADMIN: ROLE_READER
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
login:
pattern: ^/login
stateless: true
anonymous: true
provider: fos_userbundle
form_login:
check_path: /login_check
username_parameter: _username
password_parameter: _password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_id: form.csrf_provider
login_path: /login
check_path: /login_check
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
oauth:
resource_owners:
facebook: "/connect/check-facebook"
login_path: /connect
use_forward: false
failure_path: /connect
default_target_path: /
oauth_user_provider:
service: hwi_oauth.user.provider.fosub_bridge
lexik_jwt: ~
logout:
path: /logout
target: /login
anonymous: true
stateless: true
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
access_control:
- { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/books, roles: [ ROLE_READER ] }
- { path: ^/, roles: [ ROLE_READER ] }
- { path: ^/logout, role: IS_AUTHENTICATED_ANONYMOUSLY }
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
php_errors:
log: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
# Nelmio CORS
nelmio_cors:
defaults:
allow_origin: ["%cors_allow_origin%"]
allow_methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS"]
allow_headers: ["content-type", "authorization"]
expose_headers: ["link"]
max_age: 3600
paths:
'^/': ~
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
use_username_form_type: false
lexik_jwt_authentication:
private_key_path: '%jwt_private_key_path%'
public_key_path: '%jwt_public_key_path%'
pass_phrase: '%jwt_key_pass_phrase%'
token_ttl: '%jwt_token_ttl%'
hwi_oauth:
connect:
confirmation: true
registration_form: fos_user.registration.form.factory
firewall_names: [main]
fosub:
username_iterations: 30
properties:
facebook: facebookID
resource_owners:
# Facebook Access
facebook:
type: facebook
client_id: '%oauth.facebook.id%'
client_secret: '%oauth.facebook.secret%'
scope: "email"
options:
display: popup
csrf: true
答案 0 :(得分:1)
我不确定这是问题的原因,但初看起来我认为你忘了configure the OAuth Firewall使/connect
和/connect/check-facebook
路线可以通过匿名用户。
因此,您应该添加security.yml
:
access_control:
- { path: ^/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/connect/check-facebook, role: IS_AUTHENTICATED_ANONYMOUSLY }
为防止意外冲突,我们还建议他们进口&#34;导入&#34;所有OAuth路线位于app/config/routing.yml
的第一个位置:
为了防止出现奇怪的问题,我们应该在您之前导入此路线 自定义的。