[英]Identification, authentification and redirection on Symfony 2.8
I have a problem concerning identification, authentication and redirection on Symfony2 (v2.8.9). 我在Symfony2(v2.8.9)上遇到有关标识,身份验证和重定向的问题。
I installed HWIOAuthBundle in order to use the Google Sign-in and based on a User Bundle handmade. 我安装了HWIOAuthBundle以便使用Google登录并基于手工制作的用户捆绑包。 The website is completely closed to anonymous users and you need to login to use it.
该网站完全禁止匿名用户访问,您需要登录后才能使用。
My problem is that in order to access a precise URL given by someone, and land on it after you logged in via the login page, I set in the app/config/config.yml the use_referer to true . 我的问题是,为了访问某人提供的精确URL,并在通过登录页面登录后登陆该URL,我在app / config / config.yml中将use_referer设置为true 。
Since then, when someone goes directly to the /login page, once he's authenticated, he's taken back to the /login page instead of being re-directed on the private homepage of the website (/hub defined by the route rnd_hub_homepage). 从那时起,当某人直接进入/ login页面时,一旦通过身份验证,他便被带回到/ login页面,而不是被重定向到网站的私有主页(/ nb_hub_homepage由路由rnd_hub_homepage定义)。 He's taken there properly identified and authenticated but I wish he shouldn't land there but on the /hub page.
他已被带到那里,经过适当的标识和认证,但我希望他不应该在那里,而是在/ hub页面上。
If I set the line always_use_default_target_path to true in app/config/security.yml , then the use_referer is no longer taken into account for others URLs... 如果我在app / config / security.yml中将always_use_default_target_path行设置为true ,则其他URL将不再考虑use_referer 。
Here is my extract for the file app/config/security.yml : 这是我提取的文件app / config / security.yml :
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/login$
anonymous: true
main:
pattern: ^/
anonymous: true
#logout: true
logout:
path: /logout
target: /login
oauth:
resource_owners:
google: "/login/check-google"
login_path: /login
always_use_default_target_path: false
failure_path: /login
oauth_user_provider:
service: ib_user.oauth_user_provider
access_control:
- { path: ^/hub, roles: IS_AUTHENTICATED_FULLY }
- { path: ^/user, roles: ROLE_USER }
- { path: ^/XXX, roles: ROLE_XXX }
- { path: ^/YYY, roles: ROLE_YYY }
- { path: ^/ZZZ, roles: ROLE_ZZZ }
- { path: ^/AAA, roles: ROLE_AAA }
- { path: ^/BBB, roles: ROLE_BBB }
- { path: ^/DDD, roles: ROLE_DDD }
- { path: ^/EEE, roles: ROLE_EEE }
- { path: ^/admin, roles: ROLE_ADMIN }
And here is the extract of my app/config/config.yml file: 这是我的app / config / config.yml文件的摘录 :
hwi_oauth:
firewall_names: [main]
target_path_parameter: rnd_hub_homepage
use_referer: true
resource_owners:
google:
type: google
#etc....
Thank you in advance for your various inputs on this question... (sorry for my english, I'm french born) 预先感谢您对这个问题的各种投入...(对不起,我的英语,我是法国出生的)
I think you have defined 2 times logout configuration. 我认为您已经定义了2次注销配置。 Try to remove:
尝试删除:
logout: true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.