认证的桌面应用程序应用程序、桌面

2023-09-07 09:06:18 作者:尽揽少女心

首先,我接过来一看就她的每一个相关主题的这个问题。但非他们成功地完全回答我的问题。

First of all, I took a look to every related topic on her about this issue. However non of them was successful in answering my question fully.

目前我工作的一个桌面应用程序,codeD在C#/ WPF中,这既需要进行身份验证和存储用户自定义列表MySQL连接等。

Currently I am working on a desktop app, coded in C#/wpf, that requires MySQL connection both for authentication and storing user custom lists etc.

然而,问题是,显然让每个人都可以远程连接到MySQL数据库是不是好的做法。此外,我目前的主机需要IP地址被列入白名单,才可以连接到数据库。

However, the problem is that apparently allowing everyone to remotely connect to MySQL db is not good practice. Also, my current host requires IPs to be whitelisted before they can connect to the db.

我的选择是对的?

感谢你在前进

推荐答案

您应该考虑创建一个Web服务(SOAP),HTTP网络API(REST)或其他一些中间件抽象的数据存储。

You should look into creating a web service (SOAP), http web-api (REST) or some other middleware to abstract your data storage.

这具有的优点:

允许您将大部分的业务逻辑,你的桌面应用程序,进入中间件 可以让你保持业务逻辑出的SQL这可能是一个瓶颈 允许您无需重新分配你的桌面应用程序(更容易,如果你没有直接控制的所有桌面),更新的业务逻辑。 允许您控制认证(许多Web服务器都有自己的模块,认证方法)。您的应用程序将控制在它自己的服务帐户访问和访问存储。 允许您完成更改您的数据存储(比方说,将来你储存一些在SQL中,一些在MongoDB中,一些云存储 - 再一次,而无需更新所有桌面 允许你扩展你的前端,甚至可能扩展你的后端存储(例如,读取/写入数据库副本)

如果你已经用C#的工作,那么新的MVC4网络API,应该是一个不错的选择。在这里阅读更多:

If you're already working with C#, then the new MVC4 web-api should be a good fit. Read more here:

http://www.asp.net/web-api

如果你走这条路线,你可以控制你的业务接入和你的服务访问数据库或者通过在连接字符串凭据,或者如果您使用IIS,在应用程序池的凭据映射到你的网站。

If you go that route you could control access in your service and have your service access the database either via credentials in a connection string or if you use IIS, credentials on the application pool mapped to your site.

如果你正在运送你的桌面应用程序(你没有托管DB),那么你也可以自行主机网络API在它自己的exe文件,如果你的客户不希望安装/管理IIS。

If you're shipping your desktop app (you're not hosting the DB) then you can also self host web-api in it's own exe if your customers don't want to install/manage IIS.

最后,如果你的mysql是在线,您的中间件可以在云中(天蓝色等)

Finally, if your mysql is online, your middleware could be in the cloud (azure etc...)