firebase / firebase/firebase-admin-node

Firebase Auth's `verifyIdToken` ignores proxy setting

Đang mở
#1,455 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
api: auth
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
16

Mô tả

### [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
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.