gpt4 book ai didi

javascript - 在 Chrome 扩展程序中安全存储 Django REST API token

转载 作者:行者123 更新时间:2023-11-28 04:50:31 25 4
gpt4 key购买 nike

我正在制作一个 Chrome 扩展程序,该扩展程序应允许用户在弹出界面中输入用户名和密码,通过 AJAX 将其发布到服务器,并接收 Chrome 扩展程序可用于交互的 Django REST API token 使用 Django 应用程序(获取用户信息、创建新记录等 - 所以它应该是安全的)。

现在,我已经让 Chrome 扩展程序发出请求并接收 API token ,但我正在努力解决如何安全地存储 API token 的问题。

我知道 chrome.storage 已经过时了,因为文档说它不安全。这里可以使用cookie吗?该扩展程序需要在多个域上运行,因此我不确定是否可以安全地使用 cookie。

我不想要求用户每次使用 Chrome 时都登录,但我不确定如何存储 API 数据。

最佳答案

您应该使用chrome.identity :

Developers can leverage chrome.identity API to store user credentials. A Chrome extension usually makes API requests to external resources. A best practice is to store an OAuth API token. Such tokens can perform authorized requests on behalf of users without user names / passwords, and can be revoked by the user anytime.

Chrome API provides a chrome.identity service, which provides a secure way for an extension to authenticate, fetch and refresh tokens. This API enables a user to perform authentication against a third-party service. Chrome can interactively display a popup UI, which:

这是official docs .

关于javascript - 在 Chrome 扩展程序中安全存储 Django REST API token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42964056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com