在我的典型应用中,用户单击aspx页面中的按钮,调用C#业务对象,然后运行存储过程。在调用堆栈中应该进行角色检查?
如果角色检查可以在堆栈的顶部进行,每一级堆栈或底部?看起来,如果恶意用户可以调用一种方法,他可以调用任何方法,所以为了有效的安全性,您需要检查每种方法(并且这是很多额外的代码来编写的)。
下面是一个典型的调用堆栈来说明我的问题:
Page_Load()
{
if(p.IsInRole("Managers")) //or equivalent attribute
{
AddAccount.Visible =true;
}
}
AddAccount_OnClick()
{
if(p.IsInRole("Managers")) //or equivalent attribute
{
//Add the account
Account.Add(...); //and maybe another role check...
}
}
-- TSQL doesn't understand .NET authorization, this call is in a 'trusted' subsystem
create proc Add_Account @user, @account_name
If @user in (Select user from role_table where role='manager')
-- Add the account