firebase / firebase/firebase-admin-node

Firebase Auth's `verifyIdToken` ignores proxy setting

未关闭
#1,455 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
api: auth
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
3 天 10 小时
30 天内合并 PR
16

描述

### [REQUIRED] Step 2: Describe your environment

* Operating System version: Windows Server 2016 Datacenter
* Firebase SDK version: 9.12.0
* Firebase Product: Auth
* Node.js version: 14.18.0
* NPM version: 6.14.15

### [REQUIRED] Step 3: Describe the problem
I tried to use `admin.auth().verifyIdToken(...)` but it doesn't work with error message `Error while making request: connect ETMEDOUT 142.250.4.95:443`. Weirdly enough, other method like `admin.auth().createCustomToken(...)` works just fine by setting env var `https_proxy`. I've tried both methods in the same function and `verifyIdToken` indeed doesn't work. I use the logger described in https://github.com/firebase/firebase-admin-node/issues/690. and it seems Firebase Auth doesn't use httpAgent at all.

#### Steps to reproduce:

Run the code below, replacing serviceAccountKey with any serviceAccountKey for your project, and a valid JWT generated from your project.

Every http and https request made should go through the request logger. For admin.auth() calls, options.agent is undefined, even though we pass one in.

#### Relevant Code:

```
// Initial variables here
const serviceAccountKey = "" // replace with serviceAccountKey.json
const token = "" // replace with a valid token from your project
const PROXY_URL = "http://1.1.1.1:123"; // Dummy proxy URL

process.env["https_proxy"] = PROXY_URL;

// Setup the firebase-admin app
const admin = require('firebase-admin');
const HttpsProxyAgent = require('https-proxy-agent');
const config = {
credential: admin.credential.cert(serviceAccountKey),
httpAgent: new HttpsProxyAgent(PROXY_URL )
}
admin.initializeApp(config)

// Setup hooks for logging
function requestLogger(httpModule) {
var original = httpModule.request
httpModule.request = function (options, callback) {
console.log(options.agent)
return original(options, callback)
}
}

requestLogger(require('http'))
requestLogger(require('https'))

// Make the API request
const dummyToken = await auth.createCustomToken('XXX')
// dummyToken is successfully generated

admin.auth().verifyIdToken(token)
// failed at verifying the token from users
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。