简体   繁体   English

使用Android保护RESTful服务的最佳方法

[英]Best way to secure RESTful service using from Android

I am devoloping online store android standalone app(not in webview). 我正在开发在线商店android独立应用程序(不在webview中)。 I have PHP engine on the server and implemented REST API. 我在服务器上安装了PHP引擎,并实现了REST API。 But the problem is security between android app and server. 但是问题是Android应用程序与服务器之间的安全性。
The secure requests shoud be purchase item, view purchased history, cancel order. 安全请求应为购买商品,查看购买历史记录,取消订单。
My app will let user to enter login and password to login into the app checking data correctness from the server and than user will have an ability to send secure requests. 我的应用程序将允许用户输入登录名和密码以登录到应用程序,以检查服务器中的数据正确性,然后用户便可以发送安全请求。
So the question is how to secure connection ? 那么问题是如何保护连接? And how to implement this on the server and client side. 以及如何在服务器和客户端上实现这一点。
Please give advices how to implement this, and important, what is the best practise to do this to build robust application. 请提供有关如何实施此建议的建议,重要的是,执行此操作以构建健壮的应用程序的最佳实践是什么。
I would be grateful for any help. 我将不胜感激。

You can use OAuth to secure your response - request cycle. 您可以使用OAuth保护您的响应-请求周期。

What exactly is OAuth (Open Authorization)? OAuth(开放授权)到底是什么?

Generally with RESTful applications, you should leverage the header Authorization . 通常,对于RESTful应用程序,应利用标头Authorization There are several levels of security you can implement: 您可以实现几种安全级别:

  • Basic authentication . 基本认证 It simply corresponds to set a based64-encoded string containing identifier and password 它仅对应于设置一个包含标识符和密码的基于base64编码的字符串
  • Token-based authentication . 基于令牌的身份验证 It involves a token resource that provides tokens with expiration and that are used instead of actual identifier / password for authentication. 它涉及一个令牌资源,该资源为令牌提供到期时间,并且使用令牌资源代替实际的标识符/密码进行身份验证。

This link provides more details about the way to use these mechanisms: https://templth.wordpress.com/2015/01/05/implementing-authentication-with-tokens-for-restful-applications/ . 该链接提供了有关使用这些机制的方式的更多详细信息: https : //templth.wordpress.com/2015/01/05/implementing-authentication-with-tokens-for-restful-applications/

Hope it helps you, Thierry 希望对您有帮助,蒂埃里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM