数据库密码保护移动应用iPhone/Android

发布于 2025-01-06 01:09:14 字数 210 浏览 1 评论 0原文

我对有关外部服务器上的数据库连接的整个移动应用程序开发场景很陌生。

它在存储用户和密码数据以及执行方面到底是如何工作的?我的一种平行思维是像 php/asp 这样的动态网络语言是如何工作的。当包含数据库用户名和密码的文件在Web服务器上存储和执行时。

应用程序也一样吗?有人有关于此的文章的链接吗?最好是它如何适用于 iPhone 和 Android。

问候

I'm new to the whole mobile app development scene regarding database connection on a external server.

How is it working exactly regarding storing user and password data and execution? One parallell mindset I have is how dynamic web languages like php/asp works. When the file contaning the database username and password are stored and executed on the web server.

Is it the same for apps? Somebody who has a link to an article about this? Preferably how this work for both iPhone and Android.

Greetings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤凫 2025-01-13 01:09:14

我会为此使用诸如 Restful Webservices 之类的东西。

您的网络服务器上将有(例如)php,然后您的应用程序将向该服务器发出请求(就像请求网页一样)。然后将访问数据库并对数据库进行读写。您的数据库用户名和密码将在您的服务器上的 php 代码中受到保护。

如果您有个人用户名和密码,那么您将需要某种方式让他们“登录”您的服务器。为此,您可能有一个 Web 服务,它获取用户名和密码,验证它们,然后返回令牌。该令牌存储在您的设备上,然后包含在您向服务器发出的每个请求中,并在每个请求时进行验证。

例子...
http://myserver.com/login.php - 您的应用程序请求此并发送用户名和密码帖子请求。 login.php 将从传入的参数中获取用户名和密码,并将它们与您的用户名/密码数据库进行比较。如果经过验证,php 将返回一个令牌,然后该令牌将返回到您的调用应用程序。

http://myserver.com/getData.php - 您的应用程序请求此并发送所需的任何参数查询并发送令牌。

在服务器上,php 代码将获取传入的令牌并检查它是否仍然有效,如果有效,则使用仅在 php 代码中的连接,使用提供的参数在数据库上运行查询,并返回您的应用程序随后显示的数据。

这适用于任何设备,如果您将来也想编写它,也可以与桌面客户端一起使用。

您可能想研究的事情......
PHP(或 ASP.net 或任何你觉得舒服的)
JSON(用于将数据传输到服务器或从服务器传输数据)
SQL注入和安全技术
RESTFUL Webservices(比 SOAP 容易得多)

I would use something like restful webservices for this.

Your web server will have (for example) php on it, then your app will make a request to that server (just like requesting a web page). That will then access the database and read and write from/to the database. Your database username and password would be secured on your server in the php code.

If you have individual username and passwords, then you will need to have some way for them to "log in" to your server. For this you might have a webservice that takes the username and password, validates them and then returns a token. This token is stored on your device and is then included in every request you make to your server and is then validated at each request.

Example...
http://myserver.com/login.php - your app requests this and sends the username and password in the post request. login.php would take the username and password from the passed-in parameters and compare them against your username/password database. If validated, the php would then return a token which will then be returned to your calling app.

http://myserver.com/getData.php - your app requests this and sends any parameters required for the query and also sends the token.

On the server, the php code would take the token passed in and check that it is still valid and if so, it then runs the query on the database with the parameters supplied, using a connection that is only within your php code and returns the data which your app then displays.

This would work for any device, and would also be usable with a desktop client if you wanted to write that in the future also.

Things you might want to research....
PHP (or ASP.net or whatever you feel comfortable with)
JSON (for transferring data to/from the server)
SQL Injection and security techniques
RESTFUL Webservices (MUCH easier than SOAP)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文