firebase / firebase/firebase-admin-node

Firebase Auth's `verifyIdToken` ignores proxy setting

Abierto
#1,455 0 comentarios 1 reacción 0 asignados Ver en GitHub
api: auth
Lenguaje dominante
TypeScript
Estrellas
1.7k
Forks
419
Merge medio
3 d 10 h
PR fusionados (30 d)
16

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.