问题描述
我正在尝试保护从我的 chrome 扩展程序到我在 AWS 上托管的网站的 API 调用。到目前为止,我发布的 SO 帖子已经过时且无效。到目前为止,我发现的最新和最好的教程来自 Very Good Software,它需要通过以下方式获取用户的 google OAuth 访问令牌:
背景.js:
chrome.identity.getAuthToken({ 'interactive': true },function(token) {
if (token){alert('token is ' + token)}
else{alert('token not present')}
});
manifest.json
{
"manifest_version": 2,"name": "To be named","description": "This extension helps...","version": "0.1.0","browser_action":{
"default_popup":"popup.html"
},"permissions": [
"storage","identity","identity.email","http://127.0.0.1:5000/Time"
],"oauth2":{
"client_id":"1097711......apps.googleusercontent.com","scopes":["https://www.googleapis.com/auth/userinfo.profile"]
},"background": {
"scripts": ["background.js"],"persistent": false
},"content_scripts": [{
"matches": ["https://www.blank.org/"],"js": ["content.js"],"css": ["styles.css"]
}]
}
access_token 被传递到您的服务器以便您的服务器通过以下方式解密:
@blueprint.route('/verification')
def verification():
from firebase_admin import auth,credentials
import firebase_admin
cred = credentials.Certificate("Firebase.json")
firebase_admin.initialize_app(cred)
decoded_token = auth.verify_id_token("ya29.a0AfH6...AY")
uid = decoded_token['uid']
print(uid)
return str(uid)
在生成令牌时,我意识到 firebase-sdk 需要一个 verify_id 而不是访问令牌。因此,我想知道这种方式是否可以更正以用于保护带有 chrome 扩展的 API 调用? 如果不是,到目前为止,保护来自 chrome 扩展的 API 调用的最新和最佳方法是什么?鉴于可以查看源代码。
此外,我认为我无法发布访问令牌并查看它是否与我的服务器登录用户访问令牌匹配,因为我相信它们每次都会更改。
此外,速率限制对我的问题根本没有帮助,因为服务是个人的,不能共享,如果攻击者要闯入,它只需要几个电话就可以发动恶意攻击。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)