reactjs - Most secure way to pass Laravel passport access_token from Laravel blade to React component
问题描述
I'm building chat application with ReactJS and Laravel, we are using Laravel Echo. API needs an access_token to be authenticated so we need to pass the access_token in the component.
How can do it securely?
解决方案
access_token 可以由 Laravel Passport (LP) 生成。由于 LP 只是集成到 PHP 联盟的 OAuth 2 中,因此默认发布 JSON Web 令牌 (JWT)。这些令牌存储在客户端非常安全。
如果您查看文档,您将能够为用户生成令牌,而无需通过正常的 OAuth 2 流程。
使用浏览器的LocalStorage,您可以存储此令牌以供将来使用。
推荐阅读
- windows - 从另一个区域复制 EC2 实例会带来错误的路由表
- formal-verification - TLA+ 中的咖啡罐问题:无法表达任务
- github-pages - 雨果 github 动作 404
- .htaccess - 如何使用 htaccess 从 URL 中查找和替换特定单词
- javascript - 具有前瞻性的正则表达式不像我期望的那样工作
- python - Python Watermarking - 防止图像大小和质量降低
- apache-kafka - Kafka Connect MQTT:是否可以在 MQTT 和 Kafka 主题之间进行 1:1 映射?
- java - 控制器无法映射对象并带来列表结果
- sql - 如何从日期检查日期名称。但是从程序来看,我的日期错误,所以请帮助我
- node.js - nodejs中的参数问题