android - 如何将敏感数据从 Android 应用程序传递到 Google Cloud Endpoints?

标签 android python google-app-engine google-cloud-endpoints

我正在尝试在 Google Endpoints 中创建一种简单的最小 session 管理系统。

我在我的 Android 应用程序上对用户进行身份验证。为了进行经过身份验证的 Endpoint API 调用,我计划通过在从 Android 应用程序首次调用 Endpoints API 时传递 idToken 来在 Endpoint 服务器上验证用户一次。

然后,我会为该用户分配一个 session_id(比如说一个数字)。此 session_id 将传回给该 Android 应用。 Cloud Endpoint 服务器在接下来的 24 小时内不会验证用户。

当 Android 应用程序使用该 session_id 调用端点 API 时,我会假设它来自经过身份验证的用户来执行所需的操作。

担忧
如果有人嗅探到 session_id,他将能够执行经过身份验证的用户的操作。

问题 1 将敏感数据(如 session_id)从 Android 应用程序传递到 Google Cloud Endpoints 是否安全(且正确)?

问题 2 即使我的网站没有启用 HTTPS,Android 应用程序和 Cloud Endpoints 之间的所有通信都默认通过 HTTPS 完成吗? Official doc说:

Important: Google Cloud Endpoints requires SSL. If you need to access your backend API in a system not supporting SSL, you'll need to either update the system to support SSL or use a proxy.

另一个Official doc说:

In both method decorators, we supply the path to specify a location at which the method serves requests. The value specified is appended to the API path, for example, if the value hellogreeting is specified, the path is https://your-app-id.appspot.com/_ah/api/helloworld/v1/hellogreeting. For greetings.getGreeting, the path is hellogreeting/{id} where {id} is required or else your API method won't receive the incoming request argument.

注意: 我的网站没有启用 SSL (HTTPS)。我在网络和 Android/Java 上使用 GAE Python。我有网站和一个 Android 应用程序,我正在从 Google 身份验证迁移到 Google Identity Toolkit基于多个提供商身份验证(如 Facebook、Google 等)。

最佳答案

Q1。如果它仅通过 HTTPS 传递,则可以假定它是安全的(通过嗅探),尽管我不确定它是否是正确的方法,这取决于您的实现。你提到它会是一个数字。什么样的数字?随机生成?顺序?

此外,您是否使用 Users API/webapp2?我喜欢内置的 create_auth_token函数可以节省你一些时间并替换你的情况下的 session_id,然后你可以使用 get_by_auth_tokenvalidate_token 来获取相应的用户或简单地验证 token 和 delete_auth_token 使 token 无效。

如果您不使用 Users API/webapp2,最好不要对 token 使用随机数或序号,而是像 token = HMAC('A_VERY_LONG_AND_SECRET_KEY', user_id + todays_date) 这样的东西,它是唯一的,有效期为 24 小时(从午夜开始,而不是从创建时间开始)并且只要 key 是 secret 的,它就是 secret 的,这是一个更好、更安全的选择。

Q2。即使您的自定义域没有 SSL 证书,您的 APPID.appspot.com 也有(尝试通过 httpS:// 访问您的项目,您会看到)。

Cloud Endpoints 始终通过 SSL 提供 API(实际上无法更改它)。

Google 给您的警告是关于客户端不支持 SSL 连接的可能情况,这种情况在现实世界中不会经常发生。

关于android - 如何将敏感数据从 Android 应用程序传递到 Google Cloud Endpoints?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26045117/

相关文章:

java - 如何使用 JSON 数组制作 ExpandableListView

java - 如果可以对源代码进行逆向工程,那么在 Android(或 Java)中加密任何内容有什么意义?

Python : INPUT a microtime float, 结果格式化日期时间

python - IPython 指向错误的 Python 版本

java - 如何在端点类上实现自定义 @JsonDeserialize 方法?

python - 在 google app engine python 中设置 cron 作业

Android 身份验证错误 : "GetToken failed with status code: INVALID_AUDIENCE"

android - Ionic 的 native "Push"插件导致错误

Python 等效于 PHP mysql_fetch_array

eclipse - 恢复到旧的 Google Cloud SDK shell 版本