3

I'm thinking of using application roles in SQL Server I've read the following on the Microsoft MSDN site: http://msdn.microsoft.com/en-us/library/ms190998.aspx

Connecting with an Application Role The following steps make up the process by which an application role switches security contexts:

A user executes a client application.

The client application connects to an instance of SQL Server as the user.

The application then executes the sp_setapprole stored procedure with a password known only to the application.

If the application role name and password are valid, the application role is enabled.

At this point the connection loses the permissions of the user and assumes the permissions of the application role.

I'm wondering, if the application must know the password, how best to achieve this. I would assume storing the password in source code is a security risk. Is there another secure way to deploy the password with the application (note this is a windows client application that will be deployed to user machines).

4

2 回答 2

2

实际上还有另一种方法可以在应用程序中部署密码。

您可以将密码作为机密存储在数据库本身中。

例如,使用返回此“秘密”的存储过程或标量函数。这是您描述的逻辑中的一个附加步骤,将在应用程序使用用户凭据建立连接后立即执行。

这是可能的,因为无论如何用户都可以使用 Windows 身份验证访问数据库。需要设置权限,以便授予用户连接数据库和可编程对象的访问权限。

要“混淆”(不安全)密码,您可以将加密版本存储在数据库中并使用简单的加密/解密(如this one)。

这种方法具有以下优点:

  • 密码不会以明文形式存储在任何地方(请注意,如果您不使用 SSL 加密,它将以明文形式在网络上传播)
  • 应用程序的用户无需提供任何输入
  • 应用程序源代码不包含密码
  • 应用部署不包含密码
  • 密码可以很容易地重置,例如按计划
于 2014-01-13T18:03:49.297 回答
0

没有办法在没有本地管理员能够发现它的用户工作站上部署密码。您只能将标准提高这么高,但如果价格值得,他们会找到的。

您应该依靠提供密码的用户,如果可能的话,最终归结为使用 Windows 身份验证。您应该始终假设应用程序拥有任何特权,用户也拥有这些特权,并且他/她可以使用替代访问 API(即任何查询工具)来行使这些特权。如果您不能信任具有某些特权的用户,则不得在他/她的计算机上部署应用程序。例如,使用将数据库与用户隔离的多层解决方案,并在此中间层中添加任何必要的验证(如果正确完成,大多数 ASP.Net 和/或 WCF 应用程序将符合这种多层)。

于 2013-05-28T08:35:45.620 回答