我开发了一个 Android 应用程序,可以直接与 MongoDB 交互以插入和获取数据。
我在 Android 应用程序的配置文件中存储了凭据,我在应用程序中读取了该文件。
mongoDBConnection:
credentials:
username: "test"
password: "test"
database: "admin"
connectionString: "mongodb://localhost:27017"
该应用程序安装在手机上后可以按预期工作,我担心的是,如果我发布该应用程序,任何人都可以反编译该应用程序并取回凭据吗?
为了解决这个问题,Android 应用程序可以与后端交互,该后端将请求路由到 mongoDB,并且 monogo 凭证存储在该后端。
我想在实现后端之前了解是否需要后端,或者 Android 应用程序本身是否有任何方法来存储凭据,以便在反编译时不会暴露?
最佳答案
if I ship the app can anyone decompile the app and retrieve the credentials back?
是的。
is there any way in android app itself to store the credentials such that it does not get exposed when decompiled?
不,这是不可能的。您可以混淆它们以使其变得更加困难,但如果应用程序拥有它们,则不可能阻止足够熟练/坚定的攻击者检索它们。
To solve the issue, the android app can interact with a backend which will route requests to mongoDB and monogo credential are stored in that backend.
这是执行此操作的唯一方法,也是正确的解决方案。
关于java - 在 Android 应用程序中存储 MongoDB 数据库凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60085261/