我正在嘗試爲我的Symfony 2應用程序的一部分(稱爲/secret
)設置基本的HTTP browser-based authentication。在我的Symfony 2應用程序中配置基本的基於HTTP瀏覽器的身份驗證 - 不顯示HTTP身份驗證登錄
我希望/secret
頁面可以公開訪問,但任何低於/secret
的頁面(如/secret/landing
)都應位於SF2防火牆後面。
當我去/secret
(或其任何子頁面),我被重定向到我的應用程序的/login
頁面,而我不明白爲什麼?
security:
providers:
sylius_user_provider:
id: sylius.user_provider.name_or_email
in_memory:
memory:
users:
secret:
password: secret
roles: 'ROLE_SECRET'
encoders:
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
main:
switch_user: { role: ROLE_ADMINISTRATION_ACCESS }
context: user
pattern: /.*
form_login:
provider: sylius_user_provider
login_path: /login
check_path: /login_check
failure_path: /login
default_target_path:/
use_forward: false
use_referer: true
remember_me:
key: %sylius.secret%
name: APP_REMEMBER_ME
lifetime: 31536000
always_remember_me: true
remember_me_parameter: _remember_me
oauth:
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
amazon: "/login/check-amazon"
login_path: /login
failure_path: /login
oauth_user_provider:
service: sylius.oauth.user_provider
logout: true
anonymous: true
secret:
pattern: ^/secret/.*
http_basic: ~
provider: in_memory
context: secret
access_control:
- { path: ^/secret/.*, roles: ROLE_SECRET }