有没有人能提供一个Swagger安全定义的工作示例?
在后端,使用firebase管理SDK验证firebase ID令牌:
import * as admin from 'firebase-admin';
await admin.auth().verifyIdToken(idToken);
Swagger安全性定义中的值应该是什么,才能为firebase获取正确的ID令牌?
"securityDefinitions": {
"firebase": {
"authorizationUrl": "https://accounts.google.com/o/oauth2/v2/auth",
"flow": "implicit",
"type": "oauth2",
"x-google-issuer": "https://securetoken.google.com/MY-PROJECT-ID",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com",
"x-google-audiences": "MY-CLIENT-ID",
"scopes": {
"https://www.googleapis.com/auth/firebase": "Firebase scope"
}
}
}
我确实取回了令牌,但是,firebase admin SDK说它无效:
解码Firebase ID标记失败。请确保传递了表示ID标记的完整字符串JWT
不确定这是因为作用域错误还是标记类型错误...
2条答案
按热度按时间svmlkihl1#
使用Firebase对用户进行身份验证/Configuring your OpenAPI document对此进行了说明。
给定的示例肯定没有任何
authorizationUrl
或scopes
部分:此外,还需要将此
firebase
安全性定义添加到security
部分中,无论是在API级别还是在方法级别:读取troubleshooting JWT validation可能会有所帮助。
bsxbgnwa2#
我把这个放在这里只是为了参考
https://github.com/swagger-api/swagger-ui/pull/7699
我已经启动了一个PR,它将启用swagger使用的登录/弹出窗口
使用执行
firebase
特定逻辑的自定义扩展插件