Skip to content

Commit fb3e359

Browse files
authored
Fix more issues related to admin auth and appcheck. (#5146)
* Pass auth token to the connection, and use Bearer in the header value * Add changeset. * Don't use lastSessionId as transportSessionId.
1 parent cca8d4b commit fb3e359

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.changeset/wet-pets-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/database': patch
3+
---
4+
5+
Fix sending of auth tokens on node.

packages/database/src/realtime/Connection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export class Connection {
122122
this.repoInfo_,
123123
this.applicationId_,
124124
this.appCheckToken_,
125+
this.authToken_,
126+
null,
125127
this.lastSessionId
126128
);
127129

packages/database/src/realtime/WebSocketConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class WebSocketConnection implements Transport {
172172
// Note that this header is just used to bypass appcheck, and the token should still be sent
173173
// through the websocket connection once it is established.
174174
if (this.authToken) {
175-
options.headers['Authorization'] = this.authToken;
175+
options.headers['Authorization'] = `Bearer ${this.authToken}`;
176176
}
177177
if (this.appCheckToken) {
178178
options.headers['X-Firebase-AppCheck'] = this.appCheckToken;
@@ -238,7 +238,7 @@ export class WebSocketConnection implements Transport {
238238
/**
239239
* No-op for websockets, we don't need to do anything once the connection is confirmed as open
240240
*/
241-
start() { }
241+
start() {}
242242

243243
static forceDisallow_: boolean;
244244

0 commit comments

Comments
 (0)