gpt4 book ai didi

android - 我是否应该在参数中传递数据库用户和密码来调用 Web 服务以从数据库中获取数据

转载 作者:行者123 更新时间:2023-11-29 16:04:45 24 4
gpt4 key购买 nike

这是一个基本问题。我正在编写一个 Android 应用程序,它使用 Web 服务从数据库中获取数据。我将一些参数传递给 Web 服务,它以 JSON/XML 格式向我返回数据。我的问题是我应该将数据库用户名和密码作为参数传递以打开数据库连接,还是应该将这些凭据保留在 Web 服务中?如果我将这些凭据保存在服务中,任何知道我的 Web 服务位置和我传递的参数的人都可以访问我的数据库并获取数据。如果我请求调用方将这些凭据作为参数传递,那么在从移动应用程序调用 Web 服务时通过互联网发送此信息是否安全。

我找到了 this有关在调用 Web 服务时保护您的数据的示例,这很好地解释了即使您使用 https,发送纯文本仍然不安全。

谢谢

最佳答案

我认为this答案将解释您要问的问题。

'silverback' 是对的。永远不要从客户端请求这些凭据,这是不安全的。您可以简单地使用某种加密方式对客户端进行身份验证...

Here is an example from to generate authentication token:

(day * 10) + (month * 100) + (year (last 2 digits) * 1000)
for example: 3 June 2011

(3 * 10) + (6 * 100) + (11 * 1000) =
30 + 600 + 11000 = 11630
then concatenate with user password, example "my4wesomeP4ssword!"

11630my4wesomeP4ssword!
Then do MD5 of that string:

05a9d022d621b64096160683f3afe804
When do you call a request, always use this token,

https://mywebservice.com/?token=05a9d022d621b64096160683f3afe804&op=getdata
This token is always unique everyday, so I guess this kind of protection is more than sufficient to always protect ur service.

关于android - 我是否应该在参数中传递数据库用户和密码来调用 Web 服务以从数据库中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20092405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com