简体   繁体   English

适用于移动应用的Laravel RESTful API身份验证

[英]Laravel RESTful API authentication for mobile app

I would like to discuss what is the best way to secure your API's in order to be used from a mobile application. 我想讨论什么是保护API的最佳方法,以便从移动应用程序中使用。

Since there is not third-party I guess OAuth is not a good choice? 既然没有第三方我觉得OAuth不是一个好选择?
Would JWT be a good choice? JWT会是个不错的选择吗?

The hard part for me to understand is how can I authenticate so I can protect the data in my API's unless someone is authorized to call them. 我要理解的难点是如何进行身份验证,以便我可以保护我的API中的数据,除非有人被授权调用它们。

I use Laravel 5.1 in server side and the mobile application that I want to call the API's is an android one. 我在服务器端使用Laravel 5.1,而我想调用API的移动应用程序是一个安卓程序。

I hope that I didn't forget to mention any important information. 我希望我不忘记提及任何重要信息。 Any kind of help will be appreciated. 任何形式的帮助将不胜感激。

Use OAuth2 使用OAuth2

Consider using OAuth 2 with Client Credentials Grant. 考虑将OAuth 2与客户端凭据授予一起使用。

You can request an access token using your Client's credentials. 您可以使用客户的凭据请求访问令牌。

Use OAuth 2 Server Laravel: 使用OAuth 2服务器Laravel:

Implementing an Authorization Server with the Client Credentials Grant using Luca's package: 使用Luca的包实现具有客户端凭据授权的授权服务器:

Take a look at JSON Web Token Authentication for Laravel & Lumen 看看Laravel和Lumen的JSON Web令牌认证

It provides security and protection to data and routes. 它为数据和路由提供安全性和保护。

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

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