简体   繁体   English

Symfony 2.6通过主机限制URL,但允许特定的IP访问它

[英]Symfony 2.6 restrict url by host but allow a specific IP to access it

I am trying to allow a specific IP to access a restricted path defined in security.yml with no success. 我试图允许特定IP访问security.yml中定义的受限路径,但没有成功。

I have these 2 lines in my security.yml: 我的security.yml中有以下两行:

access_control:
        - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY,  ip: "127.0.0.1" }
        - { path: ^/.*, role: IS_AUTHENTICATED_FULLY, host: "test.loc" }

However, I am redirected to the login page when I try to access the project on my local. 但是,当我尝试在本地访问该项目时,我被重定向到登录页面。

How can I achieve it? 我该如何实现?

My guess is that you're running afoul of Chrome's aggressive 301 redirect caching. 我的猜测是您正在使用Chrome积极的301重定向缓存。 See a discussion here . 在这里查看讨论。 Try in another browser such as Firefox. 在其他浏览器(例如Firefox)中尝试。

The problem should go away if you clear Chrome's browsing data. 如果您清除Chrome的浏览数据,该问题应会消失。 You can also pop in to incognito mode to test. 您也可以进入隐身模式进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM