Php symfony上security.yml的问题

Php symfony上security.yml的问题,php,security,symfony1,symfony-1.4,sfguard,Php,Security,Symfony1,Symfony 1.4,Sfguard,我正在尝试在使用sfGuardPlugin 5.0.0在Symfony 1.4上开发的应用程序中配置一些安全性 要求是管理员用户可以做任何事情,而查看者只能列出和查看记录 这是我在模块的目录配置中使用的security.yml: index: is_secure: true credentials: [[ admin, viewer ]] show: is_secure: true credentials: [[ admin, viewer ]] all:

我正在尝试在使用sfGuardPlugin 5.0.0在Symfony 1.4上开发的应用程序中配置一些安全性

要求是管理员用户可以做任何事情,而查看者只能列出和查看记录

这是我在模块的目录配置中使用的security.yml:

index:
    is_secure: true
    credentials: [[ admin, viewer ]]

show:
    is_secure: true
    credentials: [[ admin, viewer ]]

all:
    is_secure: true
    credentials: [ admin ]
但我不知道为什么当我试图让一个允许的观众的行动,它停止与消息“不允许”

以下是堆栈跟踪:

1    sfPatternRouting   Connect sfRoute "sf_guard_signin" (/guard/login)
2    sfPatternRouting   Connect sfRoute "sf_guard_signout" (/guard/logout)
3    sfPatternRouting   Match route "homepage" (/) for / with parameters 
  array ( 'module' => 'strain', 'action' => 'index',)
4    sfFilterChain  Executing filter "sfRenderingFilter"
5    sfFilterChain  Executing filter "sfBasicSecurityFilter"
6    Doctrine_Connection_Mysql  exec : SET NAMES 'UTF8' - ()
7    Doctrine_Connection_Statement  execute : SELECT s.id AS s__id, s.first_name AS 
 s__first_name, s.last_name AS s__last_name, s.email_address AS s__email_address, s.username 
 AS s__username, s.algorithm AS s__algorithm, s.salt AS s__salt, s.password AS s__password, 
 s.is_active AS s__is_active, s.is_super_admin AS s__is_super_admin, s.last_login AS 
 s__last_login, s.avatar AS s__avatar, s.token AS s__token, s.notify_new_order AS 
 s__notify_new_order, s.notify_ready_order AS s__notify_ready_order, s.initials AS 
 s__initials, s.created_at AS s__created_at, s.updated_at AS s__updated_at FROM sf_guard_user 
 s WHERE (s.id = ?) LIMIT 1 - (25)
8    sfBasicSecurityFilter  Action "strain/index" requires credentials 
  "[admin, viewer]", forwarding to "sfGuardAuth/secure"
9    sfFilterChain  Executing filter "sfRenderingFilter"
10   sfFilterChain  Executing filter "InboxFilter"
11   Doctrine_Connection_Statement  execute : DELETE FROM notification WHERE 
   (status = ? AND updated_at < ?) - (2, 2012-05-19 14:21:05)
12   sfFilterChain  Executing filter "sfExecutionFilter"
13   sfGuardAuthActions Call "sfGuardAuthActions->executeSecure()"
14   sfPHPView  Render "sf_app_dir/modules/sfGuardAuth/templates/secureSuccess.php"
15   main   Call "sfGuardAuth->executeSignin_form()"
16   sfPartialView  Render "sf_app_dir/modules/sfGuardAuth/templates/_signin_form.php"
17   main   Set slot "error_message"
18   sfPHPView  Decorate content with "sf_app_dir/templates/login.php"
19   sfPHPView  Render "sf_app_dir/templates/login.php"
20   main   Get slot "error_message"
21   sfWebResponse  Send status "HTTP/1.1 403 Forbidden"
22   sfWebResponse  Send header "Content-Type: text/html; charset=utf-8"
1 sfpattern路由连接sfRoute“sf\u guard\u sign”(/guard/login)
2 SFPattern路由连接sfRoute“sf_guard_signout”(/guard/logout)
3.将路线“主页”(/)与参数匹配
数组('module'=>'strain','action'=>'index',)
4 sfFilterChain执行过滤器“sfRenderingFilter”
5 sfFilterChain执行过滤器“SFBasicSecurity过滤器”
6原则\u连接\u Mysql执行:设置名称“UTF8”-()
7条令\u连接\u语句执行:选择s.id作为s\u id,选择s.first\u name作为
s__姓氏,s.last_姓氏,s.email_地址,s.username
作为s__用户名,s.algorithm作为s__算法,s.salt作为s__salt,s.password作为s__密码,
s、 当s\u处于活动状态时,s\u处于活动状态,s.is\u超级管理员作为s\u超级管理员,s.last\u登录为
s__上次登录,s.avatar作为s__化身,s.token作为s__令牌,s.notify_new_order作为
s.通知新订单,s.通知准备就绪订单,s.通知准备就绪订单,s.首字母缩写为
s__首字母,s.created_at AS s__created_at,s.updated_at AS s__updated_at FROM sf_guard_user
其中(s.id=?)限制1-(25)
8 SFBasicSecurity过滤器操作“应变/指数”需要凭证
“[管理员,查看器]”,正在转发到“sfGuardAuth/secure”
9 sfFilterChain执行过滤器“sfRenderingFilter”
10 sfFilterChain执行过滤器“InboxFilter”
11条令连接语句执行:从通知中删除,其中
(状态=?和更新时间<?)-(2012-05-1914:21:05)
12 sfFilterChain执行过滤器“sfExecutionFilter”
13 sfGuardAuthActions调用“sfGuardAuthActions->executeSecure()
14 sfPHPView呈现“sf_app_dir/modules/sfGuardAuth/templates/secureSuccess.php”
15主调用“sfGuardAuth->executeSignin_form()”
16 sfPartialView呈现“sf_app_dir/modules/sfGuardAuth/templates/_sign_form.php”
17主机插槽“错误信息”
18 sfPHPView用“sf_app_dir/templates/login.php”装饰内容
19 sfPHPView呈现“sf_app_dir/templates/login.php”
20主获取插槽“错误消息”
21 sfWebResponse发送状态“HTTP/1.1 403禁止”
22 sfWebResponse发送标题“内容类型:text/html;字符集=utf-8”

有什么线索吗?

根据stacktrace,用户需要同时拥有管理员
查看者
凭证

如果不是这样,错误应该是(注意[[&]):

操作“应变/索引”需要凭据“[[admin,viewer]]”,并转发到“sfGuardAuth/secure”


重新检查security.yml或将完整文件粘贴到问题中。

最后我发现了问题,不是应用程序要求两个凭据,问题是Symfony正在查看表权限,而我正在使用组


非常感谢你的回答

能否将stacktrace添加到消息中(以查看调用了哪个模块/操作)?我已编辑消息以添加stacktrace。调试工具栏=>Config=>Globals=>session=>symfony/user/sfUser/credentials:['?'],如果已设置或未设置,请尝试使用其他操作查看凭据。它是
viewer
admin
或空白?sfBasicSecurityFilter检查
[admin,viewer]
凭据(admin和viewer),而不是
[[admin,viewer]]
(admin或viewer)是否已清除缓存
/symfony cc