2012-06-18 28 views
2

我試圖在Symfony 1.4上開發的應用程序中配置一些安全措施,使用sfGuardPlugin 5.0.0。symfony上security.yml的問題

要求說管理員用戶可以做所有事情,查看者只能列出並查看記錄。

這是我使用的模塊的目錄配置的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

您可以將堆棧跟蹤添加到消息(以查看調用哪個模塊/操作)? – j0k

+0

我編輯了消息來添加堆棧跟蹤。 – graffiacane

+1

調試工具欄=> Config => Globals => session => symfony/user/sfUser/credentials:['?'],嘗試使用其他操作查看憑證(如果已設置)。它是'查看器'還是'管理員'或空白? – Sanjay

回答

0

根據堆棧跟蹤,用戶需要有adminviewer憑據。

如果不是的情況下,誤差應(注意[[ & ]):

行動 「應變/索引」 要求憑證「[[管理員,觀看者]]「,轉發至」sfGuardAuth/secure「

重新檢查security.yml或將完整的文件粘貼到您的問題中。

1

最後,我發現問題,並不是應用程序要求提供兩個憑據,問題在於Symfony正在查看錶權限,而我正在使用該組。

非常感謝您的答覆。