java - 在 Android 应用程序中存储 MongoDB 数据库凭据

标签 java android mongodb apk dalvik

我开发了一个 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/

相关文章:

java - 在 Java 中比较两个集合

php - 将数组传递给 BasicNameValuePair?

java - Android:列出已安装的卷

javascript - 通过 Fetch Api 发布请求时 Req.body 未定义

node.js - mongo native ensureIndex 不创建索引

java - 在 TCP 网关中发送响应后向 Spring Integration 中的 serviceActivator 发送消息

java - 无法让 OnTouchListner 工作

java - 通过 ID 查找元素无法识别 - Selenium

java - 发布值并将图像上传到android中的php服务器

MongoDB:自动捕获数据库(而不是应用程序)中的创建/更新时间