Symfony:路由不适用于安全模块

发布于 2024-11-09 07:01:21 字数 3950 浏览 2 评论 0原文

我的 symfony 项目部署在子域共享托管上。

所有不安全的模块都工作正常,但没有任何安全模块加载,并且路由失败并抛出空模块和/或操作...错误。对于未经身份验证的模块,路由工作正常。 我在日志中找不到太多内容,只是 sfBasicSecurityFilter 没有被调用。

为了解决这个问题,

  1. 我遵循了 ticket 中的解决方案,并将“POST”添加到 sfRequestRoute我
  2. 也尝试过 将 sf_method 要求添加到路由中
  3. Auth 模块之前被称为默认模块,因此为了避免名称冲突,我什至更改了模块名称,
  4. 我已多次重置缓存
  5. 它在所有本地环境中都可以正常工作。

任何解决方案?

[编辑]另一个实验 的路由/定价时与 index.php index.php 中的日志进行了比较

我在设置中使用了 frontend_dev.php 控制器,并在请求来自不安全模块

May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signin" (/guard/login)
May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signout" (/guard/logout)
May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_forgot_password" (/guard/forgot_password)
May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfDoctrineRoute "sf_guard_forgot_password_change" (/guard/forgot_password/:unique_key)
May 23 12:37:38 symfony [info] {sfPatternRouting} Match route "home_pricing" (/pricing) for /pricing with parameters array (  'module' => 'home',  'action' => 'pricing',)
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfRenderingFilter"
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfCacheFilter"
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfCommonFilter"
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfExecutionFilter"
May 23 12:37:38 symfony [info] {homeActions} Call "homeActions->executePricing()"
....
May 23 12:37:38 symfony [info] {sfWebResponse} Send status "HTTP/1.1 200 OK"
May 23 12:37:38 symfony [info] {sfWebResponse} Send header "Content-Type: text/html; charset=utf-8"
May 23 12:37:38 symfony [info] {sfWebResponse} Send content (6444 o)

frontend_dev.php strong> 当请求来自不安全模块的路由/定价时,

May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signin" (/guard/login)
May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signout" (/guard/logout)
May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_forgot_password" (/guard/forgot_password)
May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfDoctrineRoute "sf_guard_forgot_password_change" (/guard/forgot_password/:unique_key)
May 24 08:14:28 symfony [err] {sfError404Exception} Empty module and/or action after parsing the URL "/frontend_dev.php/pricing" (/).
May 24 08:14:28 symfony [info] {sfWebResponse} Send status "HTTP/1.0 404 Not Found"

我使用 HTACCESS 来启用路由 /public_html/.htaccess(空)

/public_html/demo/.htaccess

#RewriteEngine on
#RewriteBase /

#RewriteCond %{REQUEST_URI} !^/web/ 
#RewriteRule .* /web/%1 [QSA]

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # we skip all files in /web
  RewriteCond %{REQUEST_URI} ^/web/
  RewriteRule .* - [L]

  # we rewrite all other files with .something to /web
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule ^(.*)$ /web/$1 [L]

  # !!! UNTESTED !!! ##################################
  # we check if the .html version is in /web (caching)
  #RewriteRule ^$ /web/index.html [QSA]
  #RewriteRule ^([^.]+)$ /web/$1.html [QSA]
  #####################################################

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ /web/index.php [QSA,L]

</IfModule>

# big crash from our front web controller
ErrorDocument 500 "<h2>Application error</h2>symfony application failed to start properly"

/public_html/demo/web/.htaccess(空)

My symfony project is deployed on shared hosting on a sub-domain.

All un-secured modules work fine, but none of the secure modules load, and the routing fails throwing a Empty module and/or action... error. The routing is working fine for unauthenticated modules.
I couldn't find much in the logs, just that the sfBasicSecurityFilter was not getting called.

To solve it,

  1. I followed the solution in this ticket and added 'POST' to the sfRequestRoute class
  2. I also tried
    adding the sf_method requirement to the routes
  3. The Auth module was earlier called default, so to avoid a name conflict I even changed the module name
  4. I have reset the cache multiple times
  5. It works fine on all local environments.

Any solutions?

[EDIT] Another experiment
I used the frontend_dev.php controller on the setup, and compared with the log from index.php

index.php when requesting the route /pricing that comes from an unsecure module

May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signin" (/guard/login)
May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signout" (/guard/logout)
May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_forgot_password" (/guard/forgot_password)
May 23 12:37:38 symfony [info] {sfPatternRouting} Connect sfDoctrineRoute "sf_guard_forgot_password_change" (/guard/forgot_password/:unique_key)
May 23 12:37:38 symfony [info] {sfPatternRouting} Match route "home_pricing" (/pricing) for /pricing with parameters array (  'module' => 'home',  'action' => 'pricing',)
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfRenderingFilter"
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfCacheFilter"
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfCommonFilter"
May 23 12:37:38 symfony [info] {sfFilterChain} Executing filter "sfExecutionFilter"
May 23 12:37:38 symfony [info] {homeActions} Call "homeActions->executePricing()"
....
May 23 12:37:38 symfony [info] {sfWebResponse} Send status "HTTP/1.1 200 OK"
May 23 12:37:38 symfony [info] {sfWebResponse} Send header "Content-Type: text/html; charset=utf-8"
May 23 12:37:38 symfony [info] {sfWebResponse} Send content (6444 o)

frontend_dev.php when requesting the route /pricing that comes from an unsecure module

May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signin" (/guard/login)
May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_signout" (/guard/logout)
May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfRoute "sf_guard_forgot_password" (/guard/forgot_password)
May 24 08:14:28 symfony [info] {sfPatternRouting} Connect sfDoctrineRoute "sf_guard_forgot_password_change" (/guard/forgot_password/:unique_key)
May 24 08:14:28 symfony [err] {sfError404Exception} Empty module and/or action after parsing the URL "/frontend_dev.php/pricing" (/).
May 24 08:14:28 symfony [info] {sfWebResponse} Send status "HTTP/1.0 404 Not Found"

I'm using HTACCESS to enable routing
/public_html/.htaccess (empty)

/public_html/demo/.htaccess

#RewriteEngine on
#RewriteBase /

#RewriteCond %{REQUEST_URI} !^/web/ 
#RewriteRule .* /web/%1 [QSA]

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # we skip all files in /web
  RewriteCond %{REQUEST_URI} ^/web/
  RewriteRule .* - [L]

  # we rewrite all other files with .something to /web
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule ^(.*)$ /web/$1 [L]

  # !!! UNTESTED !!! ##################################
  # we check if the .html version is in /web (caching)
  #RewriteRule ^$ /web/index.html [QSA]
  #RewriteRule ^([^.]+)$ /web/$1.html [QSA]
  #####################################################

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ /web/index.php [QSA,L]

</IfModule>

# big crash from our front web controller
ErrorDocument 500 "<h2>Application error</h2>symfony application failed to start properly"

/public_html/demo/web/.htaccess (empty)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

稀香 2024-11-16 07:01:21

您在使用 sfGuardAuht 吗?您是否在部署中执行了“php symfony plugin:publish-assets”?

Are you using sfGuardAuht? Did you executed "php symfony plugin:publish-assets" in the deployment?

铜锣湾横着走 2024-11-16 07:01:21

这完全是我的错。在 Windows 上开发它后,我在 sfGuard 模块中包含的路径之一中使用了 / 。这造成了致命错误。

在 index.php 中进行某种回显或骰子以突出显示此类错误。

This was totally my bad. Having developed it on Windows, I had used / in one of the paths included in the sfGuard module. That created a fatal error.

Do some sort of an echo in the index.php or a die to highlight such errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文