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

时间:2011-05-23 07:55:33

标签: authentication symfony1 routing hosting

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

所有未受保护的模块都可以正常工作,但没有任何安全模块加载,并且路由无法抛出 空模块和/或操作... 错误。路由适用于未经身份验证的模块。 我在日志中找不到多少,只是没有调用sfBasicSecurityFilter。

要解决它,

  1. 我按照此ticket中的解决方案添加'POST'到sfRequestRoute类
  2. 我也试过了 将sf_method要求添加到路径
  3. Auth模块之前被称为默认模块,因此为了避免名称冲突,我甚至更改了模块名称
  4. 我已多次重置缓存
  5. 适用于所有本地环境。
  6. 任何解决方案?

    [编辑]另一项实验 我在设置中使用了frontend_dev.php控制器,并与index.php中的日志进行了比较

    请求来自不安全模块的路由/定价时

    index.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

    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 (空)

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

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

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