从网络地址找不到 FOSUserBundle 的登录表单的路由
FOSUserBundle's login form's route not found from network address
在 Windows 10.
的 WampServer 上使用 Symfony(使用 FOSUserbundle)进行开发
我必须通过本地网络 IP(不是计算机的本地 IP,即 127.0.0.1)访问我的应用程序,因为在 registration/authentication 过程中的某个时刻,必须调用外部(国家)身份验证服务.
当我使用 http://[my_network_ip]:81/ as well as http://127.0.0.1:81/ , except for FOSUserBundle's login form. The excepted page is showing when using http://127.0.0.1:81/login , but when using http://[my_network_ip]:81/login 时我的应用程序工作正常,我得到
No route found for "GET /login/"
部分配置:
security.yml
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
logout: ~
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
#http_basic: ~
# https://symfony.com/doc/current/security/form_login_setup.html
form_login: ~
#login_path: fos_user_security_login
#check_path: fos_user_security_check
#provider: fos_userbundle
#csrf_token_generator: security.csrf.token_manager
#default_target_path: /
encoders:
AppBundle\Entity\FasUser: bcrypt
routing.yml
app:
resource: '@AppBundle/Controller/'
type: annotation
singlesingon_view:
path: '/authentication/singlesignon/'
defaults: { _controller: AppBundle:AuthenticationSingleSignOn:view }
singlesingout_view:
path: '/authentication/singlesignout/'
defaults: { _controller: AppBundle:AuthenticationSingleSignOut:view }
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
app_dev.php
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'],['[my_network_ip]','127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
如何让登录表单与 http://[my_network_ip]:81/login
一起使用
我通过如下编辑主要 routing.yml 设法使该页面正常工作:
(...)
fos_user_manual:
path: '/login/'
defaults: { _controller: FOSUserBundle:Security:login }
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
如果试过 path: '/login'
但那个没用。
所以,这似乎可行,如果有更清洁的解决方案,我仍然欢迎提出意见或建议。
在 Windows 10.
的 WampServer 上使用 Symfony(使用 FOSUserbundle)进行开发我必须通过本地网络 IP(不是计算机的本地 IP,即 127.0.0.1)访问我的应用程序,因为在 registration/authentication 过程中的某个时刻,必须调用外部(国家)身份验证服务.
当我使用 http://[my_network_ip]:81/ as well as http://127.0.0.1:81/ , except for FOSUserBundle's login form. The excepted page is showing when using http://127.0.0.1:81/login , but when using http://[my_network_ip]:81/login 时我的应用程序工作正常,我得到
No route found for "GET /login/"
部分配置:
security.yml
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
logout: ~
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
#http_basic: ~
# https://symfony.com/doc/current/security/form_login_setup.html
form_login: ~
#login_path: fos_user_security_login
#check_path: fos_user_security_check
#provider: fos_userbundle
#csrf_token_generator: security.csrf.token_manager
#default_target_path: /
encoders:
AppBundle\Entity\FasUser: bcrypt
routing.yml
app:
resource: '@AppBundle/Controller/'
type: annotation
singlesingon_view:
path: '/authentication/singlesignon/'
defaults: { _controller: AppBundle:AuthenticationSingleSignOn:view }
singlesingout_view:
path: '/authentication/singlesignout/'
defaults: { _controller: AppBundle:AuthenticationSingleSignOut:view }
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
app_dev.php
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'],['[my_network_ip]','127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
如何让登录表单与 http://[my_network_ip]:81/login
一起使用我通过如下编辑主要 routing.yml 设法使该页面正常工作:
(...)
fos_user_manual:
path: '/login/'
defaults: { _controller: FOSUserBundle:Security:login }
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
如果试过 path: '/login'
但那个没用。
所以,这似乎可行,如果有更清洁的解决方案,我仍然欢迎提出意见或建议。