保护您的数据层在C#应用程序 [英] Securing your Data Layer in a C# Application

查看:191
本文介绍了保护您的数据层在C#应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想如何在C#应用程序保护数据层,该层能在这种情况下是不是一个LINQ到SQL模型图存储与containg连接字符串到SQL Server数据库的应用程序本身。

I was thinking about how to secure the Data Layer in a C# Application, the layer could in this case be either a LINQ to SQL Model Diagram stored with the Application itself containg the connection string to the SQL Server Database.

或者,它可能是应用程序和Web服务之间的连接。

Or it could be connectivity between the application and webservices.

要么需要impement某种安全的,例如,在一个应用程序的连接字符串可以容易地反向工程和WEBSERVICES可以很容易地跟踪和用于其它原因比应用最初目的。

Either you need to impement some sort of security, for instance, the Connection String in a Application can easily be reverse engineered and Webservices can easily be tracked and used for other reasons than the applications original purpose.

所以我的问题是在较短的方式:处理Web服务时,你如何解决安全性问题和/或直接连接到SQL Server从Windows窗体应用程序

So my question is in a shorter way: How do you solve the security issues when handling Webservices and/or direct connection to a SQL Server From a Windows Forms Application?

推荐答案

在你的情况主要有两种攻击的可能性:

In your case there are two main attack possibilities:


  • 偷的连接字符串,然后直接访问数据库

  • 呼叫方法在C#code的情况下直接使用UI

有关,你需要将它存储在一个加密的形式在配置文件中的连接字符串。问题是,有需要在WinForms应用程序足够的信息,以便它可以解密和使用它

For the connection string you need to store it in an encrypted form in a config file. Problem is that there need to be enough information in the winforms app so that it can decrypt and use it.

有关访问code,直接可以用code访问的安全性和模糊处理。

For accessing the code directly you can use code access security and obfuscation.

在你的情况,我不会给窗口应用直接访问数据库。让Windows应用程序调用WCF服务时,WCF服务将访问数据库。

In your case I would not give the windows app direct access to the database. Let the windows app call a WCF service, the the WCF service would access the database.

用户的用户帐户可以调用WCF服务,WCF服务是允许访问数据库的帐户下运行,用户的用户帐户具有对数据库的任何权利。

The user's user account is allowed to call the WCF service, the WCF service is running under an account that is allowed to access the database, the user's user account has no rights to the database.

Windows应用程序有3层:

Windows App with 3 Layers:


  • UI

  • 商务(安全检查什么UI应显示给用户)

  • 代理

WCF Service与2层:

WCF Service with 2 Layers:


  • 外观/业务层(安全检查是允许用户调用此方法与此数据)

  • 实体框架数据模型

常见的DLL到两个图层

Common dll's to both Layers


  • 合同/ WCF接口

  • 数据传输对象

有关代理,合同和DTO的看到这部影片信息:

For info on proxy, contracts and DTO's see this video:

<一个href=\"http://www.dnrtv.com/default.aspx?showNum=103\">http://www.dnrtv.com/default.aspx?showNum=103

这篇关于保护您的数据层在C#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆