简体   繁体   English

使用 Laravel 保护我的 REST API 的过程

[英]Process to secure my REST API with Laravel

I am in process to design an application for a customer where the User Interface will be in Angular 6 and the back-end will be in the API.Now as I am using angular (SPA) I communicate with server though JSON and REST API.我正在为客户设计一个应用程序,其中用户界面将在 Angular 6 中,后端将在 API 中。现在,当我使用 angular (SPA) 时,我通过 JSON 和 REST API 与服务器进行通信。 Now need your suggestions on the process to secure my API.现在需要您对保护我的 API 的过程提出建议。

My Analysis -我的分析——

1) Personal Access Token is not a good idea as the tokens are always long lived. 1)个人访问令牌不是一个好主意,因为令牌总是长期存在的。 I have already done a demo on the same.我已经做了一个演示。

2) Consuming Your API With JavaScript is may be a good option but it used cookies and it will be good approach or not I am not sure. 2) 使用 JavaScript 使用 API可能是一个不错的选择,但它使用了 cookie,我不确定这是否是好方法。

I am open for any good suggestions including other approach like JWT also if it's proves logical.如果证明合乎逻辑,我也愿意接受任何好的建议,包括 JWT 等其他方法。

Thans in Advance.比提前。

I suggest you to use Laravel - Passport .我建议你使用Laravel - Passport Its is a build in system in laravel framework.它是laravel框架中的内置系统。 So you can get user personal token and save it in your local storage .因此,您可以获得用户个人令牌并将其保存在您的local storage There is a lot of way to secure you RESTful api , but before that you need to understand exactly which systems will interact with you api.有很多方法可以保护您的RESTful api,但在此之前您需要准确了解哪些系统将与您的 api 交互。

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

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